Contents of /trunk/busybox/patches/busybox-1.20.2-f2fs.patch
Parent Directory | Revision Log
Revision 2125 -
(show annotations)
(download)
Tue Mar 19 19:52:33 2013 UTC (11 years, 6 months ago) by niro
File size: 6268 byte(s)
Tue Mar 19 19:52:33 2013 UTC (11 years, 6 months ago) by niro
File size: 6268 byte(s)
-add f2fs support to volumeid
1 | diff -Naur busybox-1.20.2/util-linux/Config.src busybox-1.20.2-magellan/util-linux/Config.src |
2 | --- busybox-1.20.2/util-linux/Config.src 2012-06-26 13:35:45.000000000 +0000 |
3 | +++ busybox-1.20.2-magellan/util-linux/Config.src 2013-03-19 21:59:32.917000000 +0000 |
4 | @@ -762,6 +762,16 @@ |
5 | help |
6 | TODO |
7 | |
8 | +config FEATURE_VOLUMEID_F2FS |
9 | + bool "f2fs filesystem" |
10 | + default y |
11 | + depends on VOLUMEID |
12 | + help |
13 | + F2FS (aka Flash-Friendly File System) is a log-structured file system, |
14 | + which is adapted to newer forms of storage. F2FS also remedies some |
15 | + known issues of the older log structured file systems, such as high |
16 | + cleaning overhead. |
17 | + |
18 | config FEATURE_VOLUMEID_NTFS |
19 | bool "ntfs filesystem" |
20 | default y |
21 | diff -Naur busybox-1.20.2/util-linux/volume_id/f2fs.c busybox-1.20.2-magellan/util-linux/volume_id/f2fs.c |
22 | --- busybox-1.20.2/util-linux/volume_id/f2fs.c 1970-01-01 00:00:00.000000000 +0000 |
23 | +++ busybox-1.20.2-magellan/util-linux/volume_id/f2fs.c 2013-03-19 21:54:19.100000000 +0000 |
24 | @@ -0,0 +1,81 @@ |
25 | +/* |
26 | + * volume_id - reads filesystem label and uuid |
27 | + * |
28 | + * Copyright (C) 2012 S-G Bergh <sgb@systemasis.org> |
29 | + * |
30 | + * Licensed under GPLv2, see file LICENSE in this source tree. |
31 | + */ |
32 | + |
33 | +#include "volume_id_internal.h" |
34 | + |
35 | +#define F2FS_MAGIC 0xF2F52010 // F2FS Magic Number |
36 | +#define F2FS_UUID_SIZE 16 |
37 | +#define F2FS_LABEL_SIZE 512 |
38 | +#define F2FS_LABEL_BYTES 1024 |
39 | +#define F2FS_SB1_OFFSET 0x400 // offset for 1:st super block |
40 | +/* |
41 | +#define F2FS_SB2_OFFSET 0x1400 // offset for 2:nd super block |
42 | +*/ |
43 | + |
44 | +struct f2fs_super_block { // According to version 1.1 |
45 | +/* 0x00 */ uint32_t magic; // Magic Number |
46 | +/* 0x04 */ uint16_t major_ver; // Major Version |
47 | +/* 0x06 */ uint16_t minor_ver; // Minor Version |
48 | +/* 0x08 */ uint32_t log_sectorsize; // log2 sector size in bytes |
49 | +/* 0x0C */ uint32_t log_sectors_per_block; // log2 # of sectors per block |
50 | +/* 0x10 */ uint32_t log_blocksize; // log2 block size in bytes |
51 | +/* 0x14 */ uint32_t log_blocks_per_seg; // log2 # of blocks per segment |
52 | +/* 0x18 */ uint32_t segs_per_sec; // # of segments per section |
53 | +/* 0x1C */ uint32_t secs_per_zone; // # of sections per zone |
54 | +/* 0x20 */ uint32_t checksum_offset; // checksum offset inside super block |
55 | +/* 0x24 */ uint64_t block_count; // total # of user blocks |
56 | +/* 0x2C */ uint32_t section_count; // total # of sections |
57 | +/* 0x30 */ uint32_t segment_count; // total # of segments |
58 | +/* 0x34 */ uint32_t segment_count_ckpt; // # of segments for checkpoint |
59 | +/* 0x38 */ uint32_t segment_count_sit; // # of segments for SIT |
60 | +/* 0x3C */ uint32_t segment_count_nat; // # of segments for NAT |
61 | +/* 0x40 */ uint32_t segment_count_ssa; // # of segments for SSA |
62 | +/* 0x44 */ uint32_t segment_count_main; // # of segments for main area |
63 | +/* 0x48 */ uint32_t segment0_blkaddr; // start block address of segment 0 |
64 | +/* 0x4C */ uint32_t cp_blkaddr; // start block address of checkpoint |
65 | +/* 0x50 */ uint32_t sit_blkaddr; // start block address of SIT |
66 | +/* 0x54 */ uint32_t nat_blkaddr; // start block address of NAT |
67 | +/* 0x58 */ uint32_t ssa_blkaddr; // start block address of SSA |
68 | +/* 0x5C */ uint32_t main_blkaddr; // start block address of main area |
69 | +/* 0x60 */ uint32_t root_ino; // root inode number |
70 | +/* 0x64 */ uint32_t node_ino; // node inode number |
71 | +/* 0x68 */ uint32_t meta_ino; // meta inode number |
72 | +/* 0x6C */ uint8_t uuid[F2FS_UUID_SIZE]; // 128-bit uuid for volume |
73 | +/* 0x7C */ uint16_t volume_name[F2FS_LABEL_SIZE]; // volume name |
74 | +//* 0x47C */ uint32_t extension_count; // # of extensions below |
75 | +//* 0x480 */ uint8_t extension_list[64][8]; // extension array |
76 | +} PACKED; |
77 | + |
78 | + |
79 | +int FAST_FUNC volume_id_probe_f2fs(struct volume_id *id /*,uint64_t off*/) |
80 | +{ |
81 | + struct f2fs_super_block *sb; |
82 | + |
83 | + // Go for primary super block (ignore second sb) |
84 | + dbg("f2fs: probing at offset 0x%x", F2FS_SB1_OFFSET); |
85 | + sb = volume_id_get_buffer(id, F2FS_SB1_OFFSET, sizeof(*sb)); |
86 | + |
87 | + if (!sb) |
88 | + return -1; |
89 | + |
90 | + if (sb->magic != cpu_to_le32(F2FS_MAGIC)) |
91 | + return -1; |
92 | + |
93 | + IF_FEATURE_BLKID_TYPE(id->type = "f2fs"); |
94 | + |
95 | + // For version 1.0 we cannot know the correct sb structure... |
96 | + if (le16_to_cpu(sb->major_ver) == 1 && le16_to_cpu(sb->minor_ver) == 0) |
97 | + return 0; |
98 | + |
99 | + volume_id_set_label_unicode16(id, (uint8_t *)sb->volume_name, |
100 | + LE, MIN(F2FS_LABEL_BYTES, VOLUME_ID_LABEL_SIZE)); |
101 | + |
102 | + volume_id_set_uuid(id, sb->uuid, UUID_DCE); |
103 | + |
104 | + return 0; |
105 | +} |
106 | diff -Naur busybox-1.20.2/util-linux/volume_id/Kbuild.src busybox-1.20.2-magellan/util-linux/volume_id/Kbuild.src |
107 | --- busybox-1.20.2/util-linux/volume_id/Kbuild.src 2012-06-26 13:35:45.000000000 +0000 |
108 | +++ busybox-1.20.2-magellan/util-linux/volume_id/Kbuild.src 2013-03-19 22:01:09.378000000 +0000 |
109 | @@ -31,6 +31,7 @@ |
110 | ### lib-$(CONFIG_FEATURE_VOLUMEID_LVM) += lvm.o |
111 | ### lib-$(CONFIG_FEATURE_VOLUMEID_MAC) += mac.o |
112 | ### lib-$(CONFIG_FEATURE_VOLUMEID_MSDOS) += msdos.o |
113 | +lib-$(CONFIG_FEATURE_VOLUMEID_F2FS) += f2fs.o |
114 | lib-$(CONFIG_FEATURE_VOLUMEID_NTFS) += ntfs.o |
115 | lib-$(CONFIG_FEATURE_VOLUMEID_REISERFS) += reiserfs.o |
116 | lib-$(CONFIG_FEATURE_VOLUMEID_UDF) += udf.o |
117 | diff -Naur busybox-1.20.2/util-linux/volume_id/volume_id.c busybox-1.20.2-magellan/util-linux/volume_id/volume_id.c |
118 | --- busybox-1.20.2/util-linux/volume_id/volume_id.c 2012-06-26 13:35:45.000000000 +0000 |
119 | +++ busybox-1.20.2-magellan/util-linux/volume_id/volume_id.c 2013-03-19 22:03:37.937000000 +0000 |
120 | @@ -130,6 +130,9 @@ |
121 | #if ENABLE_FEATURE_VOLUMEID_UFS |
122 | volume_id_probe_ufs, |
123 | #endif |
124 | +#if ENABLE_FEATURE_VOLUMEID_F2FS |
125 | + volume_id_probe_f2fs, |
126 | +#endif |
127 | #if ENABLE_FEATURE_VOLUMEID_NTFS |
128 | volume_id_probe_ntfs, |
129 | #endif |
130 | diff -Naur busybox-1.20.2/util-linux/volume_id/volume_id_internal.h busybox-1.20.2-magellan/util-linux/volume_id/volume_id_internal.h |
131 | --- busybox-1.20.2/util-linux/volume_id/volume_id_internal.h 2012-06-26 13:35:45.000000000 +0000 |
132 | +++ busybox-1.20.2-magellan/util-linux/volume_id/volume_id_internal.h 2013-03-19 22:04:33.223000000 +0000 |
133 | @@ -212,6 +212,8 @@ |
134 | |
135 | //int FAST_FUNC volume_id_probe_msdos_part_table(struct volume_id *id /*,uint64_t off*/); |
136 | |
137 | +int FAST_FUNC volume_id_probe_f2fs(struct volume_id *id /*,uint64_t off*/); |
138 | + |
139 | int FAST_FUNC volume_id_probe_ntfs(struct volume_id *id /*,uint64_t off*/); |
140 | |
141 | int FAST_FUNC volume_id_probe_ocfs2(struct volume_id *id /*,uint64_t off*/); |