[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: [PATCH] blkid: recognize nilfs2
From:       Sven-Göran_Bergh <svengbergh-busybox () yahoo ! com>
Date:       2012-06-27 11:40:01
Message-ID: 1340797201.93218.YahooMailNeo () web161905 ! mail ! bf1 ! yahoo ! com
[Download RAW message or body]

Revised patch attached!



Hi Dan,
and thank you for the feedback.

>>  Adds support for nilfs2 to blkid.

>>  Enabled with CONFIG_FEATURE_VOLUMEID_NILFS.
> 
> Since this is nilfs2, not nilfs1, most (all?) of the references to nilfs
> should probably say nilfs2 instead.

Hmm, I was not so concerned about nilfs1, since it is mostly experimental.
The idea was rather to look into the future and not require a config
change when/if nilfs3 shows up. Much the same way as ext2/3/4 is
implemented. Maybe a long shot, but anyway...

I have done some minor changes to the patch, so it is less general, but
still leaves the door to the future open, see attachment.

>>  +    // The scondary superblock is not always used, so ignore it for now.
> 
> s/scondary/secondary/

Fixed in attached patch.

Thanx
/S-G

["busybox-1.20.1-blkid-nilfs.patch" (application/octet-stream)]

diff -urN busybox-1.20.1/util-linux/Config.src \
                busybox-1.20.1-nilfs/util-linux/Config.src
--- busybox-1.20.1/util-linux/Config.src	2012-04-22 03:45:24.000000000 +0200
+++ busybox-1.20.1-nilfs/util-linux/Config.src	2012-06-24 19:47:35.564237920 +0200
@@ -762,6 +762,13 @@
 	help
 	  TODO
 
+config FEATURE_VOLUMEID_NILFS
+	bool "nilfs filesystem"
+	default y
+	depends on VOLUMEID
+	help
+	  TODO
+
 config FEATURE_VOLUMEID_NTFS
 	bool "ntfs filesystem"
 	default y
diff -urN busybox-1.20.1/util-linux/volume_id/Kbuild.src \
                busybox-1.20.1-nilfs/util-linux/volume_id/Kbuild.src
--- busybox-1.20.1/util-linux/volume_id/Kbuild.src	2012-04-22 03:45:24.000000000 \
                +0200
+++ busybox-1.20.1-nilfs/util-linux/volume_id/Kbuild.src	2012-06-24 \
19:14:24.096201804 +0200 @@ -31,6 +31,7 @@
 ### lib-$(CONFIG_FEATURE_VOLUMEID_LVM)              += lvm.o
 ### lib-$(CONFIG_FEATURE_VOLUMEID_MAC)              += mac.o
 ### lib-$(CONFIG_FEATURE_VOLUMEID_MSDOS)            += msdos.o
+lib-$(CONFIG_FEATURE_VOLUMEID_NILFS)            += nilfs.o
 lib-$(CONFIG_FEATURE_VOLUMEID_NTFS)             += ntfs.o
 lib-$(CONFIG_FEATURE_VOLUMEID_REISERFS)         += reiserfs.o
 lib-$(CONFIG_FEATURE_VOLUMEID_UDF)              += udf.o
diff -urN busybox-1.20.1/util-linux/volume_id/nilfs.c \
                busybox-1.20.1-nilfs/util-linux/volume_id/nilfs.c
--- busybox-1.20.1/util-linux/volume_id/nilfs.c	1970-01-01 01:00:00.000000000 +0100
+++ busybox-1.20.1-nilfs/util-linux/volume_id/nilfs.c	2012-06-27 12:55:59.127469840 \
+0200 @@ -0,0 +1,96 @@
+/*
+ * volume_id - reads filesystem label and uuid
+ *
+ * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
+ * Copyright (C) 2012 S-G Bergh <sgb@systemasis.org>
+ *
+ *	This library is free software; you can redistribute it and/or
+ *	modify it under the terms of the GNU Lesser General Public
+ *	License as published by the Free Software Foundation; either
+ *	version 2.1 of the License, or (at your option) any later version.
+ *
+ *	This library is distributed in the hope that it will be useful,
+ *	but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ *	Lesser General Public License for more details.
+ *
+ *	You should have received a copy of the GNU Lesser General Public
+ *	License along with this library; if not, write to the Free Software
+ *	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "volume_id_internal.h"
+
+#define NILFS_UUID_SIZE 16
+#define NILFS_LABEL_SIZE 80
+#define NILFS_SB1_OFFSET 0x400
+#define NILFS_SB2_OFFSET 0x1000
+#define NILFS_MAGIC 0x3434
+
+struct nilfs2_super_block {
+/* 0x00 */	uint32_t s_rev_level;				// Major revision level.
+/* 0x04 */	uint16_t s_minor_rev_level;			// Minor revision level.
+/* 0x06 */	uint16_t s_magic;				// Magic signature.
+/* 0x08 */	uint16_t s_bytes;
+/* 0x0A */	uint16_t s_flags;
+/* 0x0C */	uint32_t s_crc_seed;
+/* 0x10 */	uint32_t s_sum;
+/* 0x14 */	uint32_t s_log_block_size;
+/* 0x18 */	uint64_t s_nsegments;
+/* 0x20 */	uint64_t s_dev_size;				// Block device size in bytes.
+/* 0x28 */	uint64_t s_first_data_block;
+/* 0x30 */	uint32_t s_blocks_per_segment;
+/* 0x34 */	uint32_t s_r_segments_percentage;
+/* 0x38 */	uint64_t s_last_cno;
+/* 0x40 */	uint64_t s_last_pseg;
+/* 0x48 */	uint64_t s_last_seq;
+/* 0x50 */	uint64_t s_free_blocks_count;
+/* 0x58 */	uint64_t s_ctime;
+/* 0x60 */	uint64_t s_mtime;
+/* 0x68 */	uint64_t s_wtime;
+/* 0x70 */	uint16_t s_mnt_count;
+/* 0x72 */	uint16_t s_max_mnt_count;
+/* 0x74 */	uint16_t s_state;
+/* 0x76 */	uint16_t s_errors;
+/* 0x78 */	uint64_t s_lastcheck;
+/* 0x80 */	uint32_t s_checkinterval;
+/* 0x84 */	uint32_t s_creator_os;
+/* 0x88 */	uint16_t s_def_resuid;
+/* 0x8A */	uint16_t s_def_resgid;
+/* 0x8C */	uint32_t s_first_ino;
+/* 0x90 */	uint16_t s_inode_size;
+/* 0x92 */	uint16_t s_dat_entry_size;
+/* 0x94 */	uint16_t s_checkpoint_size;
+/* 0x96 */	uint16_t s_segment_usage_size;
+/* 0x98 */	uint8_t s_uuid[NILFS_UUID_SIZE];		// 128-bit UUID for volume.
+/* 0xA8 */	uint8_t s_volume_name[NILFS_LABEL_SIZE];	// Volume label.
+/* 0xF8 */	// ...
+} PACKED;
+
+int FAST_FUNC volume_id_probe_nilfs(struct volume_id *id /*,uint64_t off*/)
+{
+	struct nilfs2_super_block *sb;
+
+	// Primary super block
+	dbg("nilfs: probing at offset 0x%x", NILFS_SB1_OFFSET);
+
+	sb = volume_id_get_buffer(id, NILFS_SB1_OFFSET, sizeof(*sb));
+
+	if (sb == NULL)
+		return -1;
+
+	if (sb->s_magic != NILFS_MAGIC)
+		return -1;
+
+	// The secondary superblock is not always used, so ignore it for now.
+	// When used it is at 4K from the end of the partition (sb->s_dev_size - \
NILFS_SB2_OFFSET). +
+	volume_id_set_label_string(id, sb->s_volume_name, NILFS_LABEL_SIZE < \
VOLUME_ID_LABEL_SIZE ? +				   NILFS_LABEL_SIZE : VOLUME_ID_LABEL_SIZE);
+	volume_id_set_uuid(id, sb->s_uuid, UUID_DCE);
+
+	if (sb->s_rev_level == 2)
+		IF_FEATURE_BLKID_TYPE(id->type = "nilfs2";)
+
+	return 0;
+}
diff -urN busybox-1.20.1/util-linux/volume_id/volume_id.c \
                busybox-1.20.1-nilfs/util-linux/volume_id/volume_id.c
--- busybox-1.20.1/util-linux/volume_id/volume_id.c	2012-04-22 03:45:24.000000000 \
                +0200
+++ busybox-1.20.1-nilfs/util-linux/volume_id/volume_id.c	2012-06-24 \
19:27:51.772229662 +0200 @@ -130,6 +130,9 @@
 #if ENABLE_FEATURE_VOLUMEID_UFS
 	volume_id_probe_ufs,
 #endif
+#if ENABLE_FEATURE_VOLUMEID_NILFS
+	volume_id_probe_nilfs,
+#endif
 #if ENABLE_FEATURE_VOLUMEID_NTFS
 	volume_id_probe_ntfs,
 #endif
diff -urN busybox-1.20.1/util-linux/volume_id/volume_id_internal.h \
                busybox-1.20.1-nilfs/util-linux/volume_id/volume_id_internal.h
--- busybox-1.20.1/util-linux/volume_id/volume_id_internal.h	2012-04-22 \
                03:45:24.000000000 +0200
+++ busybox-1.20.1-nilfs/util-linux/volume_id/volume_id_internal.h	2012-06-25 \
09:39:35.628374166 +0200 @@ -212,6 +212,8 @@
 
 //int FAST_FUNC volume_id_probe_msdos_part_table(struct volume_id *id /*,uint64_t \
off*/);  
+int FAST_FUNC volume_id_probe_nilfs(struct volume_id *id /*,uint64_t off*/);
+
 int FAST_FUNC volume_id_probe_ntfs(struct volume_id *id /*,uint64_t off*/);
 
 int FAST_FUNC volume_id_probe_ocfs2(struct volume_id *id /*,uint64_t off*/);



_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic