aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSven-Göran Bergh <svengbergh-busybox@yahoo.com>2012-09-02 15:34:39 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2012-09-02 15:34:39 +0200
commitc5a9fa2d2ac0165eda4b862e99cfcb91a9380416 (patch)
tree6258ec08b97ea7d181c0224ba3f5df4b823a9533
parent8019b3a7aea51343f79922928c91ef833344b743 (diff)
downloadbusybox-w32-c5a9fa2d2ac0165eda4b862e99cfcb91a9380416.tar.gz
busybox-w32-c5a9fa2d2ac0165eda4b862e99cfcb91a9380416.tar.bz2
busybox-w32-c5a9fa2d2ac0165eda4b862e99cfcb91a9380416.zip
blkid: add support for nilfs2
function old new delta volume_id_probe_nilfs - 99 +99 fs2 52 56 +4 Signed-off-by: Sven-Göran Bergh <svengbergh-busybox@yahoo.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--util-linux/Config.src7
-rw-r--r--util-linux/volume_id/Kbuild.src1
-rw-r--r--util-linux/volume_id/nilfs.c96
-rw-r--r--util-linux/volume_id/volume_id.c3
-rw-r--r--util-linux/volume_id/volume_id_internal.h2
5 files changed, 109 insertions, 0 deletions
diff --git a/util-linux/Config.src b/util-linux/Config.src
index 57a52cefb..3355e9729 100644
--- a/util-linux/Config.src
+++ b/util-linux/Config.src
@@ -762,6 +762,13 @@ config FEATURE_VOLUMEID_XFS
762 help 762 help
763 TODO 763 TODO
764 764
765config FEATURE_VOLUMEID_NILFS
766 bool "nilfs filesystem"
767 default y
768 depends on VOLUMEID
769 help
770 TODO
771
765config FEATURE_VOLUMEID_NTFS 772config FEATURE_VOLUMEID_NTFS
766 bool "ntfs filesystem" 773 bool "ntfs filesystem"
767 default y 774 default y
diff --git a/util-linux/volume_id/Kbuild.src b/util-linux/volume_id/Kbuild.src
index 70da65482..39a2d8cf4 100644
--- a/util-linux/volume_id/Kbuild.src
+++ b/util-linux/volume_id/Kbuild.src
@@ -31,6 +31,7 @@ lib-$(CONFIG_FEATURE_VOLUMEID_LINUXSWAP) += linux_swap.o
31### lib-$(CONFIG_FEATURE_VOLUMEID_LVM) += lvm.o 31### lib-$(CONFIG_FEATURE_VOLUMEID_LVM) += lvm.o
32### lib-$(CONFIG_FEATURE_VOLUMEID_MAC) += mac.o 32### lib-$(CONFIG_FEATURE_VOLUMEID_MAC) += mac.o
33### lib-$(CONFIG_FEATURE_VOLUMEID_MSDOS) += msdos.o 33### lib-$(CONFIG_FEATURE_VOLUMEID_MSDOS) += msdos.o
34lib-$(CONFIG_FEATURE_VOLUMEID_NILFS) += nilfs.o
34lib-$(CONFIG_FEATURE_VOLUMEID_NTFS) += ntfs.o 35lib-$(CONFIG_FEATURE_VOLUMEID_NTFS) += ntfs.o
35lib-$(CONFIG_FEATURE_VOLUMEID_REISERFS) += reiserfs.o 36lib-$(CONFIG_FEATURE_VOLUMEID_REISERFS) += reiserfs.o
36lib-$(CONFIG_FEATURE_VOLUMEID_UDF) += udf.o 37lib-$(CONFIG_FEATURE_VOLUMEID_UDF) += udf.o
diff --git a/util-linux/volume_id/nilfs.c b/util-linux/volume_id/nilfs.c
new file mode 100644
index 000000000..ffa86d43c
--- /dev/null
+++ b/util-linux/volume_id/nilfs.c
@@ -0,0 +1,96 @@
1/*
2 * volume_id - reads filesystem label and uuid
3 *
4 * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
5 * Copyright (C) 2012 S-G Bergh <sgb@systemasis.org>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21
22#include "volume_id_internal.h"
23
24#define NILFS_UUID_SIZE 16
25#define NILFS_LABEL_SIZE 80
26#define NILFS_SB1_OFFSET 0x400
27#define NILFS_SB2_OFFSET 0x1000
28#define NILFS_MAGIC 0x3434
29
30struct nilfs2_super_block {
31/* 0x00 */ uint32_t s_rev_level; // Major revision level.
32/* 0x04 */ uint16_t s_minor_rev_level; // Minor revision level.
33/* 0x06 */ uint16_t s_magic; // Magic signature.
34/* 0x08 */ uint16_t s_bytes;
35/* 0x0A */ uint16_t s_flags;
36/* 0x0C */ uint32_t s_crc_seed;
37/* 0x10 */ uint32_t s_sum;
38/* 0x14 */ uint32_t s_log_block_size;
39/* 0x18 */ uint64_t s_nsegments;
40/* 0x20 */ uint64_t s_dev_size; // Block device size in bytes.
41/* 0x28 */ uint64_t s_first_data_block;
42/* 0x30 */ uint32_t s_blocks_per_segment;
43/* 0x34 */ uint32_t s_r_segments_percentage;
44/* 0x38 */ uint64_t s_last_cno;
45/* 0x40 */ uint64_t s_last_pseg;
46/* 0x48 */ uint64_t s_last_seq;
47/* 0x50 */ uint64_t s_free_blocks_count;
48/* 0x58 */ uint64_t s_ctime;
49/* 0x60 */ uint64_t s_mtime;
50/* 0x68 */ uint64_t s_wtime;
51/* 0x70 */ uint16_t s_mnt_count;
52/* 0x72 */ uint16_t s_max_mnt_count;
53/* 0x74 */ uint16_t s_state;
54/* 0x76 */ uint16_t s_errors;
55/* 0x78 */ uint64_t s_lastcheck;
56/* 0x80 */ uint32_t s_checkinterval;
57/* 0x84 */ uint32_t s_creator_os;
58/* 0x88 */ uint16_t s_def_resuid;
59/* 0x8A */ uint16_t s_def_resgid;
60/* 0x8C */ uint32_t s_first_ino;
61/* 0x90 */ uint16_t s_inode_size;
62/* 0x92 */ uint16_t s_dat_entry_size;
63/* 0x94 */ uint16_t s_checkpoint_size;
64/* 0x96 */ uint16_t s_segment_usage_size;
65/* 0x98 */ uint8_t s_uuid[NILFS_UUID_SIZE]; // 128-bit UUID for volume.
66/* 0xA8 */ uint8_t s_volume_name[NILFS_LABEL_SIZE]; // Volume label.
67/* 0xF8 */ // ...
68} PACKED;
69
70int FAST_FUNC volume_id_probe_nilfs(struct volume_id *id /*,uint64_t off*/)
71{
72 struct nilfs2_super_block *sb;
73
74 // Primary super block
75 dbg("nilfs: probing at offset 0x%x", NILFS_SB1_OFFSET);
76
77 sb = volume_id_get_buffer(id, NILFS_SB1_OFFSET, sizeof(*sb));
78
79 if (sb == NULL)
80 return -1;
81
82 if (sb->s_magic != NILFS_MAGIC)
83 return -1;
84
85 // The secondary superblock is not always used, so ignore it for now.
86 // When used it is at 4K from the end of the partition (sb->s_dev_size - NILFS_SB2_OFFSET).
87
88 volume_id_set_label_string(id, sb->s_volume_name, NILFS_LABEL_SIZE < VOLUME_ID_LABEL_SIZE ?
89 NILFS_LABEL_SIZE : VOLUME_ID_LABEL_SIZE);
90 volume_id_set_uuid(id, sb->s_uuid, UUID_DCE);
91
92 if (sb->s_rev_level == 2)
93 IF_FEATURE_BLKID_TYPE(id->type = "nilfs2");
94
95 return 0;
96}
diff --git a/util-linux/volume_id/volume_id.c b/util-linux/volume_id/volume_id.c
index f41d4e0d9..c1d615283 100644
--- a/util-linux/volume_id/volume_id.c
+++ b/util-linux/volume_id/volume_id.c
@@ -130,6 +130,9 @@ static const probe_fptr fs2[] = {
130#if ENABLE_FEATURE_VOLUMEID_UFS 130#if ENABLE_FEATURE_VOLUMEID_UFS
131 volume_id_probe_ufs, 131 volume_id_probe_ufs,
132#endif 132#endif
133#if ENABLE_FEATURE_VOLUMEID_NILFS
134 volume_id_probe_nilfs,
135#endif
133#if ENABLE_FEATURE_VOLUMEID_NTFS 136#if ENABLE_FEATURE_VOLUMEID_NTFS
134 volume_id_probe_ntfs, 137 volume_id_probe_ntfs,
135#endif 138#endif
diff --git a/util-linux/volume_id/volume_id_internal.h b/util-linux/volume_id/volume_id_internal.h
index 1c64046e5..1c2e0ffa6 100644
--- a/util-linux/volume_id/volume_id_internal.h
+++ b/util-linux/volume_id/volume_id_internal.h
@@ -212,6 +212,8 @@ int FAST_FUNC volume_id_probe_luks(struct volume_id *id /*,uint64_t off*/);
212 212
213//int FAST_FUNC volume_id_probe_msdos_part_table(struct volume_id *id /*,uint64_t off*/); 213//int FAST_FUNC volume_id_probe_msdos_part_table(struct volume_id *id /*,uint64_t off*/);
214 214
215int FAST_FUNC volume_id_probe_nilfs(struct volume_id *id /*,uint64_t off*/);
216
215int FAST_FUNC volume_id_probe_ntfs(struct volume_id *id /*,uint64_t off*/); 217int FAST_FUNC volume_id_probe_ntfs(struct volume_id *id /*,uint64_t off*/);
216 218
217int FAST_FUNC volume_id_probe_ocfs2(struct volume_id *id /*,uint64_t off*/); 219int FAST_FUNC volume_id_probe_ocfs2(struct volume_id *id /*,uint64_t off*/);