Magellan Linux

Annotation of /trunk/util-linux/patches/util-linux-2.22.2-f2fs.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2127 - (hide annotations) (download)
Tue Mar 19 20:37:21 2013 UTC (11 years, 3 months ago) by niro
File size: 5857 byte(s)
-support f2fs
1 niro 2127 From 7dcfc89e3061fc2276ce5b3b8d64db6d9eca8f8f Mon Sep 17 00:00:00 2001
2     From: Alejandro Martinez Ruiz <alex@nowcomputing.com>
3     Date: Tue, 05 Feb 2013 17:00:06 +0000
4     Subject: libblkid: add Flash-Friendly File System (f2fs) support
5    
6     This adds support for detecting Flash-Friendly File System (f2fs) to libblkid.
7     Based on work by Sven-Göran Bergh at http://www.mail-archive.com/busybox@busybox.net/msg17874.html
8    
9     Signed-off-by: Alejandro Martinez Ruiz <alex@nowcomputing.com>
10     Signed-off-by: Karel Zak <kzak@redhat.com>
11     ---
12     diff --git a/libblkid/src/Makemodule.am b/libblkid/src/Makemodule.am
13     index de60458..90efa3d 100644
14     --- a/libblkid/src/Makemodule.am
15     +++ b/libblkid/src/Makemodule.am
16     @@ -54,6 +54,7 @@ libblkid_la_SOURCES = \
17     libblkid/src/superblocks/drbdproxy_datalog.c \
18     libblkid/src/superblocks/exfat.c \
19     libblkid/src/superblocks/ext.c \
20     + libblkid/src/superblocks/f2fs.c \
21     libblkid/src/superblocks/gfs.c \
22     libblkid/src/superblocks/hfs.c \
23     libblkid/src/superblocks/highpoint_raid.c \
24     diff --git a/libblkid/src/superblocks/f2fs.c b/libblkid/src/superblocks/f2fs.c
25     new file mode 100644
26     index 0000000..1543a7a
27     --- /dev/null
28     +++ b/libblkid/src/superblocks/f2fs.c
29     @@ -0,0 +1,99 @@
30     +/*
31     + * Copyright (C) 2013 Alejandro Martinez Ruiz <alex@nowcomputing.com>
32     + *
33     + * This file may be redistributed under the terms of the
34     + * GNU Lesser General Public License
35     + */
36     +
37     +#include <stddef.h>
38     +#include <string.h>
39     +
40     +#include "superblocks.h"
41     +
42     +#define F2FS_MAGIC "\x10\x20\xF5\xF2"
43     +#define F2FS_MAGIC_OFF 0
44     +#define F2FS_UUID_SIZE 16
45     +#define F2FS_LABEL_SIZE 512
46     +#define F2FS_SB1_OFF 0x400
47     +#define F2FS_SB1_KBOFF (F2FS_SB1_OFF >> 10)
48     +#define F2FS_SB2_OFF 0x1400
49     +#define F2FS_SB2_KBOFF (F2FS_SB2_OFF >> 10)
50     +
51     +struct f2fs_super_block { /* According to version 1.1 */
52     +/* 0x00 */ uint32_t magic; /* Magic Number */
53     +/* 0x04 */ uint16_t major_ver; /* Major Version */
54     +/* 0x06 */ uint16_t minor_ver; /* Minor Version */
55     +/* 0x08 */ uint32_t log_sectorsize; /* log2 sector size in bytes */
56     +/* 0x0C */ uint32_t log_sectors_per_block; /* log2 # of sectors per block */
57     +/* 0x10 */ uint32_t log_blocksize; /* log2 block size in bytes */
58     +/* 0x14 */ uint32_t log_blocks_per_seg; /* log2 # of blocks per segment */
59     +/* 0x18 */ uint32_t segs_per_sec; /* # of segments per section */
60     +/* 0x1C */ uint32_t secs_per_zone; /* # of sections per zone */
61     +/* 0x20 */ uint32_t checksum_offset; /* checksum offset inside super block */
62     +/* 0x24 */ uint64_t block_count; /* total # of user blocks */
63     +/* 0x2C */ uint32_t section_count; /* total # of sections */
64     +/* 0x30 */ uint32_t segment_count; /* total # of segments */
65     +/* 0x34 */ uint32_t segment_count_ckpt; /* # of segments for checkpoint */
66     +/* 0x38 */ uint32_t segment_count_sit; /* # of segments for SIT */
67     +/* 0x3C */ uint32_t segment_count_nat; /* # of segments for NAT */
68     +/* 0x40 */ uint32_t segment_count_ssa; /* # of segments for SSA */
69     +/* 0x44 */ uint32_t segment_count_main; /* # of segments for main area */
70     +/* 0x48 */ uint32_t segment0_blkaddr; /* start block address of segment 0 */
71     +/* 0x4C */ uint32_t cp_blkaddr; /* start block address of checkpoint */
72     +/* 0x50 */ uint32_t sit_blkaddr; /* start block address of SIT */
73     +/* 0x54 */ uint32_t nat_blkaddr; /* start block address of NAT */
74     +/* 0x58 */ uint32_t ssa_blkaddr; /* start block address of SSA */
75     +/* 0x5C */ uint32_t main_blkaddr; /* start block address of main area */
76     +/* 0x60 */ uint32_t root_ino; /* root inode number */
77     +/* 0x64 */ uint32_t node_ino; /* node inode number */
78     +/* 0x68 */ uint32_t meta_ino; /* meta inode number */
79     +/* 0x6C */ uint8_t uuid[F2FS_UUID_SIZE]; /* 128-bit uuid for volume */
80     +/* 0x7C */ uint16_t volume_name[F2FS_LABEL_SIZE]; /* volume name */
81     +#if 0
82     +/* 0x47C */ uint32_t extension_count; /* # of extensions below */
83     +/* 0x480 */ uint8_t extension_list[64][8]; /* extension array */
84     +#endif
85     +} __attribute__((packed));
86     +
87     +static int probe_f2fs(blkid_probe pr, const struct blkid_idmag *mag)
88     +{
89     + struct f2fs_super_block *sb;
90     + uint16_t major, minor;
91     +
92     + sb = blkid_probe_get_sb(pr, mag, struct f2fs_super_block);
93     + if (!sb)
94     + return -1;
95     +
96     + major = le16_to_cpu(sb->major_ver);
97     + minor = le16_to_cpu(sb->minor_ver);
98     +
99     + /* For version 1.0 we cannot know the correct sb structure */
100     + if (major == 1 && minor == 0)
101     + return 0;
102     +
103     + if (*((unsigned char *) sb->volume_name))
104     + blkid_probe_set_utf8label(pr, (unsigned char *) sb->volume_name,
105     + sizeof(sb->volume_name),
106     + BLKID_ENC_UTF16LE);
107     +
108     + blkid_probe_set_uuid(pr, sb->uuid);
109     + blkid_probe_sprintf_version(pr, "%u.%u", major, minor);
110     + return 0;
111     +}
112     +
113     +const struct blkid_idinfo f2fs_idinfo =
114     +{
115     + .name = "f2fs",
116     + .usage = BLKID_USAGE_FILESYSTEM,
117     + .probefunc = probe_f2fs,
118     + .magics =
119     + {
120     + {
121     + .magic = F2FS_MAGIC,
122     + .len = 4,
123     + .kboff = F2FS_SB1_KBOFF,
124     + .sboff = F2FS_MAGIC_OFF
125     + },
126     + { NULL }
127     + }
128     +};
129     diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c
130     index 2929a5f..62aa662 100644
131     --- a/libblkid/src/superblocks/superblocks.c
132     +++ b/libblkid/src/superblocks/superblocks.c
133     @@ -140,7 +140,8 @@ static const struct blkid_idinfo *idinfos[] =
134     &vmfs_fs_idinfo,
135     &befs_idinfo,
136     &nilfs2_idinfo,
137     - &exfat_idinfo
138     + &exfat_idinfo,
139     + &f2fs_idinfo
140     };
141    
142     /*
143     diff --git a/libblkid/src/superblocks/superblocks.h b/libblkid/src/superblocks/superblocks.h
144     index 08f1438..887732a 100644
145     --- a/libblkid/src/superblocks/superblocks.h
146     +++ b/libblkid/src/superblocks/superblocks.h
147     @@ -69,6 +69,7 @@ extern const struct blkid_idinfo drbdproxy_datalog_idinfo;
148     extern const struct blkid_idinfo befs_idinfo;
149     extern const struct blkid_idinfo nilfs2_idinfo;
150     extern const struct blkid_idinfo exfat_idinfo;
151     +extern const struct blkid_idinfo f2fs_idinfo;
152    
153     /*
154     * superblock functions
155     --
156     cgit v0.9.1