From patchwork Mon Aug 24 11:11:55 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin Chary X-Patchwork-Id: 31905 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by bilbo.ozlabs.org (Postfix) with ESMTPS id 7F88CB7B63 for ; Mon, 24 Aug 2009 21:15:02 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1MfXTm-0007uA-94; Mon, 24 Aug 2009 11:12:50 +0000 Received: from smtp2e.orange.fr ([80.12.242.111]) by bombadil.infradead.org with esmtp (Exim 4.69 #1 (Red Hat Linux)) id 1MfXTd-0007ra-EL for linux-mtd@lists.infradead.org; Mon, 24 Aug 2009 11:12:47 +0000 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2e29.orange.fr (SMTP Server) with ESMTP id D1B608000199; Mon, 24 Aug 2009 13:12:39 +0200 (CEST) Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2e29.orange.fr (SMTP Server) with ESMTP id C684D8000198; Mon, 24 Aug 2009 13:12:39 +0200 (CEST) Received: from localhost.localdomain (ALyon-253-1-63-185.w86-193.abo.wanadoo.fr [86.193.206.185]) by mwinf2e29.orange.fr (SMTP Server) with ESMTP id 500408000199; Mon, 24 Aug 2009 13:12:39 +0200 (CEST) X-ME-UUID: 20090824111239327.500408000199@mwinf2e29.orange.fr From: Corentin Chary To: util-linux-ng@vger.kernel.org Subject: [PATCH 2/3] blkid: add ubifs support Date: Mon, 24 Aug 2009 13:11:55 +0200 Message-Id: <1251112316-18971-3-git-send-email-corentincj@iksaif.net> X-Mailer: git-send-email 1.6.4 In-Reply-To: <1251112316-18971-2-git-send-email-corentincj@iksaif.net> References: <1251112316-18971-1-git-send-email-corentincj@iksaif.net> <1251112316-18971-2-git-send-email-corentincj@iksaif.net> X-Spam-Score: 0.0 (/) Cc: Corentin Chary , linux-mtd@lists.infradead.org, dedekind1@gmail.com X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Signed-off-by: Corentin Chary --- shlibs/blkid/src/probe.c | 3 +- shlibs/blkid/src/probers/Makefile.am | 3 +- shlibs/blkid/src/probers/probers.h | 1 + shlibs/blkid/src/probers/ubifs.c | 122 ++++++++++++++++++++++++++++++++++ 4 files changed, 127 insertions(+), 2 deletions(-) create mode 100644 shlibs/blkid/src/probers/ubifs.c diff --git a/shlibs/blkid/src/probe.c b/shlibs/blkid/src/probe.c index fc293fc..51793e8 100644 --- a/shlibs/blkid/src/probe.c +++ b/shlibs/blkid/src/probe.c @@ -92,7 +92,8 @@ static const struct blkid_idinfo *idinfos[] = &vxfs_idinfo, &squashfs_idinfo, &netware_idinfo, - &btrfs_idinfo + &btrfs_idinfo, + &ubifs_idinfo }; #ifndef ARRAY_SIZE diff --git a/shlibs/blkid/src/probers/Makefile.am b/shlibs/blkid/src/probers/Makefile.am index 4591db6..5a5d8b6 100644 --- a/shlibs/blkid/src/probers/Makefile.am +++ b/shlibs/blkid/src/probers/Makefile.am @@ -40,4 +40,5 @@ libblkid_probers_la_SOURCES = \ sysv.c \ btrfs.c \ lvm.c \ - zfs.c + zfs.c \ + ubifs.c diff --git a/shlibs/blkid/src/probers/probers.h b/shlibs/blkid/src/probers/probers.h index 78dbd40..93be79f 100644 --- a/shlibs/blkid/src/probers/probers.h +++ b/shlibs/blkid/src/probers/probers.h @@ -56,6 +56,7 @@ extern const struct blkid_idinfo netware_idinfo; extern const struct blkid_idinfo sysv_idinfo; extern const struct blkid_idinfo xenix_idinfo; extern const struct blkid_idinfo btrfs_idinfo; +extern const struct blkid_idinfo ubifs_idinfo; extern const struct blkid_idinfo zfs_idinfo; #endif /* _BLKID_PROBE_H */ diff --git a/shlibs/blkid/src/probers/ubifs.c b/shlibs/blkid/src/probers/ubifs.c new file mode 100644 index 0000000..45157ae --- /dev/null +++ b/shlibs/blkid/src/probers/ubifs.c @@ -0,0 +1,122 @@ +/* + * Copyright (C) 2009 Corentin Chary + * + * This file may be redistributed under the terms of the + * GNU Lesser General Public License. + */ +#include +#include +#include +#include +#include + +#include "blkidP.h" + +/** + * struct ubifs_ch - common header node. + * @magic: UBIFS node magic number (%UBIFS_NODE_MAGIC) + * @crc: CRC-32 checksum of the node header + * @sqnum: sequence number + * @len: full node length + * @node_type: node type + * @group_type: node group type + * @padding: reserved for future, zeroes + * + * Every UBIFS node starts with this common part. If the node has a key, the + * key always goes next. + */ +struct ubifs_ch { + uint32_t magic; + uint32_t crc; + uint64_t sqnum; + uint32_t len; + uint8_t node_type; + uint8_t group_type; + uint8_t padding[2]; +} __attribute__ ((packed)); + +/** + * struct ubifs_sb_node - superblock node. + * @ch: common header + * @padding: reserved for future, zeroes + * @key_hash: type of hash function used in keys + * @key_fmt: format of the key + * @flags: file-system flags (%UBIFS_FLG_BIGLPT, etc) + * @min_io_size: minimal input/output unit size + * @leb_size: logical eraseblock size in bytes + * @leb_cnt: count of LEBs used by file-system + * @max_leb_cnt: maximum count of LEBs used by file-system + * @max_bud_bytes: maximum amount of data stored in buds + * @log_lebs: log size in logical eraseblocks + * @lpt_lebs: number of LEBs used for lprops table + * @orph_lebs: number of LEBs used for recording orphans + * @jhead_cnt: count of journal heads + * @fanout: tree fanout (max. number of links per indexing node) + * @lsave_cnt: number of LEB numbers in LPT's save table + * @fmt_version: UBIFS on-flash format version + * @default_compr: default compression algorithm (%UBIFS_COMPR_LZO, etc) + * @padding1: reserved for future, zeroes + * @rp_uid: reserve pool UID + * @rp_gid: reserve pool GID + * @rp_size: size of the reserved pool in bytes + * @padding2: reserved for future, zeroes + * @time_gran: time granularity in nanoseconds + * @uuid: UUID generated when the file system image was created + * @ro_compat_version: UBIFS R/O compatibility version + */ +struct ubifs_sb_node { + struct ubifs_ch ch; + uint8_t padding[2]; + uint8_t key_hash; + uint8_t key_fmt; + uint32_t flags; + uint32_t min_io_size; + uint32_t leb_size; + uint32_t leb_cnt; + uint32_t max_leb_cnt; + uint64_t max_bud_bytes; + uint32_t log_lebs; + uint32_t lpt_lebs; + uint32_t orph_lebs; + uint32_t jhead_cnt; + uint32_t fanout; + uint32_t lsave_cnt; + uint32_t fmt_version; + uint16_t default_compr; + uint8_t padding1[2]; + uint32_t rp_uid; + uint32_t rp_gid; + uint64_t rp_size; + uint32_t time_gran; + uint8_t uuid[16]; + uint32_t ro_compat_version; + uint8_t padding2[3968]; +} __attribute__ ((packed)); + + +static int probe_ubifs(blkid_probe pr, const struct blkid_idmag *mag) +{ + struct ubifs_sb_node *sb; + + sb = blkid_probe_get_sb(pr, mag, struct ubifs_sb_node); + if (!sb) + return -1; + + blkid_probe_set_uuid(pr, sb->uuid); + blkid_probe_sprintf_version(pr, "w%dr%d", + sb->fmt_version, sb->ro_compat_version); + + return 0; +} + +const struct blkid_idinfo ubifs_idinfo = +{ + .name = "ubifs", + .usage = BLKID_USAGE_FILESYSTEM, + .probefunc = probe_ubifs, + .magics = + { + { .magic = "\x31\x18\x10\x06", .len = 4 }, + { NULL } + } +};