[PATCH] volume_id update (NTFS support)

Kay Sievers kay.sievers at vrfy.org
Sat Jun 19 14:50:59 PDT 2004


Hi,
here is a update to the volume label/uuid sniffer. It now supports
reading of NTFS labels, without the need of mounting the volume.

The patch is damn big, cause I've run into trouble with the comparisone
of signed and unsigned chars while operating on the buffers. So I've
made it all unsigned. gcc-3.4 seems to align the fields in the structures,
so __packed__ was also needed.

Thanks,
Kay
-------------- next part --------------
Index: hal/hald/linux/volume_id/volume_id.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/volume_id/volume_id.c,v
retrieving revision 1.4
diff -u -r1.4 volume_id.c
--- hal/hald/linux/volume_id/volume_id.c	27 May 2004 19:13:39 -0000	1.4
+++ hal/hald/linux/volume_id/volume_id.c	19 Jun 2004 21:36:55 -0000
@@ -7,7 +7,7 @@
  *	the e2fsprogs. This is a simple straightforward implementation for
  *	reading the label strings of only the most common filesystems.
  *	If you need a full featured library with attribute caching, support for
- *	much more partition/media types or non-root data access, you may have
+ *	much more partition/media types or non-root disk access, you may have
  *	a look at:
  *		http://e2fsprogs.sourceforge.net.
  *
@@ -55,12 +55,23 @@
 			   (((__u32)(x) & 0x0000ff00u) <<  8) | \
 			   (((__u32)(x) & 0x000000ffu) << 24))
 
+#define bswap64(x) (__u64)((((__u64)(x) & 0xff00000000000000u) >> 56) | \
+			   (((__u64)(x) & 0x00ff000000000000u) >> 40) | \
+			   (((__u64)(x) & 0x0000ff0000000000u) >> 24) | \
+			   (((__u64)(x) & 0x000000ff00000000u) >>  8) | \
+			   (((__u64)(x) & 0x00000000ff000000u) >>  8) | \
+			   (((__u64)(x) & 0x0000000000ff0000u) >> 24) | \
+			   (((__u64)(x) & 0x000000000000ff00u) >> 40) | \
+			   (((__u64)(x) & 0x00000000000000ffu) >> 56))
+
 #if (__BYTE_ORDER == __LITTLE_ENDIAN) 
 #define le16_to_cpu(x) (x)
 #define le32_to_cpu(x) (x)
+#define le64_to_cpu(x) (x)
 #elif (__BYTE_ORDER == __BIG_ENDIAN)
 #define le16_to_cpu(x) bswap16(x)
 #define le32_to_cpu(x) bswap32(x)
+#define le64_to_cpu(x) bswap64(x)
 #endif
 
 /* size of superblock buffer, reiser block is at 64k */
@@ -69,20 +80,22 @@
 #define SEEK_BUFFER_SIZE			0x800
 
 
-static void set_label_raw(struct volume_id *id, char *buf, int count)
+static void set_label_raw(struct volume_id *id,
+			  const __u8 *buf, unsigned int count)
 {
 	memcpy(id->label_raw, buf, count);
 	id->label_raw_len = count;
 }
 
-static void set_label_string(struct volume_id *id, char *buf, int count)
+static void set_label_string(struct volume_id *id,
+			     const __u8 *buf, unsigned int count)
 {
-	int i;
+	unsigned int i;
 
 	memcpy(id->label_string, buf, count);
 
 	/* remove trailing whitespace */
-	i = strlen(id->label_string);
+	i = strnlen(id->label_string, count);
 	while (i--) {
 		if (! isspace(id->label_string[i]))
 			break;
@@ -90,9 +103,45 @@
 	id->label_string[i+1] = '\0';
 }
 
-static void set_uuid(struct volume_id *id, unsigned char *buf, int count)
+#define LE		0
+#define BE		1
+static void set_label_unicode16(struct volume_id *id,
+				const __u8 *buf,
+				unsigned int endianess,
+				unsigned int count)
+{
+	unsigned int i, j;
+	__u16 c;
+
+	j = 0;
+	for (i = 0; i <= count-2; i += 2) {
+		if (endianess == LE)
+			c = (buf[i+1] << 8) | buf[i];
+		else
+			c = (buf[i] << 8) | buf[i+1];
+
+		dbg("0x%x", c);
+
+		if (c == 0) {
+			id->label_string[j] = '\0';
+			break;
+		} else if (c < 0x80) {
+			id->label_string[j++] = (__u8) c;
+		} else if (c < 0x800) {
+			id->label_string[j++] = (__u8) (0xc0 | (c >> 6));
+			id->label_string[j++] = (__u8) (0x80 | (c & 0x3f));
+		} else {
+			id->label_string[j++] = (__u8) (0xe0 | (c >> 12));
+			id->label_string[j++] = (__u8) (0x80 | ((c >> 6) & 0x3f));
+			id->label_string[j++] = (__u8) (0x80 | (c & 0x3f));
+		}
+	}
+}
+
+static void set_uuid(struct volume_id *id,
+		     const __u8 *buf, unsigned int count)
 {
-	int i;
+	unsigned int i;
 
 	memcpy(id->uuid, buf, count);
 
@@ -121,14 +170,16 @@
 	}
 }
 
-static char *get_buffer(struct volume_id *id, size_t off, size_t len)
+static __u8 *get_buffer(struct volume_id *id,
+			unsigned long off, unsigned int len)
 {
-	size_t buf_len;
+	unsigned int buf_len;
 
 	/* check if requested area fits in superblock buffer */
 	if (off + len <= SB_BUFFER_SIZE) {
 		if (id->sbbuf == NULL) {
 			id->sbbuf = malloc(SB_BUFFER_SIZE);
+			dbg("--- %p", id->sbbuf);
 			if (id->sbbuf == NULL)
 				return NULL;
 		}
@@ -151,6 +202,7 @@
 		/* get seek buffer */
 		if (id->seekbuf == NULL) {
 			id->seekbuf = malloc(SEEK_BUFFER_SIZE);
+			dbg("--- %p", id->seekbuf);
 			if (id->seekbuf == NULL)
 				return NULL;
 		}
@@ -191,23 +243,23 @@
 static int probe_ext(struct volume_id *id)
 {
 	struct ext2_super_block {
-		__u32		inodes_count;
-		__u32		blocks_count;
-		__u32		r_blocks_count;
-		__u32		free_blocks_count;
-		__u32		free_inodes_count;
-		__u32		first_data_block;
-		__u32		log_block_size;
-		__u32		dummy3[7];
-		unsigned char	magic[2];
-		__u16		state;
-		__u32		dummy5[8];
-		__u32		feature_compat;
-		__u32		feature_incompat;
-		__u32		feature_ro_compat;
-		unsigned char	uuid[16];
-		char		volume_name[16];
-	} *es;
+		__u32	inodes_count;
+		__u32	blocks_count;
+		__u32	r_blocks_count;
+		__u32	free_blocks_count;
+		__u32	free_inodes_count;
+		__u32	first_data_block;
+		__u32	log_block_size;
+		__u32	dummy3[7];
+		__u8	magic[2];
+		__u16	state;
+		__u32	dummy5[8];
+		__u32	feature_compat;
+		__u32	feature_incompat;
+		__u32	feature_ro_compat;
+		__u8	uuid[16];
+		__u8	volume_name[16];
+	} __attribute__((__packed__)) *es;
 
 	es = (struct ext2_super_block *)
 	     get_buffer(id, EXT_SUPERBLOCK_OFFSET, 0x200);
@@ -239,20 +291,20 @@
 static int probe_reiser(struct volume_id *id)
 {
 	struct reiser_super_block {
-		__u32		blocks_count;
-		__u32		free_blocks;
-		__u32		root_block;
-		__u32		journal_block;
-		__u32		journal_dev;
-		__u32		orig_journal_size;
-		__u32		dummy2[5];
-		__u16		blocksize;
-		__u16		dummy3[3];
-		unsigned char	magic[12];
-		__u32		dummy4[5];
-		unsigned char	uuid[16];
-		char		label[16];
-	} *rs;
+		__u32	blocks_count;
+		__u32	free_blocks;
+		__u32	root_block;
+		__u32	journal_block;
+		__u32	journal_dev;
+		__u32	orig_journal_size;
+		__u32	dummy2[5];
+		__u16	blocksize;
+		__u16	dummy3[3];
+		__u8	magic[12];
+		__u32	dummy4[5];
+		__u8	uuid[16];
+		__u8	label[16];
+	} __attribute__((__packed__)) *rs;
 
 	rs = (struct reiser_super_block *)
 	     get_buffer(id, REISER_SUPERBLOCK_OFFSET, 0x200);
@@ -288,19 +340,19 @@
 static int probe_xfs(struct volume_id *id)
 {
 	struct xfs_super_block {
-		unsigned char	magic[4];
-		__u32		blocksize;
-		__u64		dblocks;
-		__u64		rblocks;
-		__u32		dummy1[2];
-		unsigned char	uuid[16];
-		__u32		dummy2[15];
-		char		fname[12];
-		__u32		dummy3[2];
-		__u64		icount;
-		__u64		ifree;
-		__u64		fdblocks;
-	} *xs;
+		__u8	magic[4];
+		__u32	blocksize;
+		__u64	dblocks;
+		__u64	rblocks;
+		__u32	dummy1[2];
+		__u8	uuid[16];
+		__u32	dummy2[15];
+		__u8	fname[12];
+		__u32	dummy3[2];
+		__u64	icount;
+		__u64	ifree;
+		__u64	fdblocks;
+	} __attribute__((__packed__)) *xs;
 
 	xs = (struct xfs_super_block *) get_buffer(id, 0, 0x200);
 	if (xs == NULL)
@@ -323,17 +375,17 @@
 static int probe_jfs(struct volume_id *id)
 {
 	struct jfs_super_block {
-		unsigned char	magic[4];
-		__u32		version;
-		__u64		size;
-		__u32		bsize;
-		__u32		dummy1;
-		__u32		pbsize;
-		__u32		dummy2[27];
-		unsigned char	uuid[16];
-		unsigned char	label[16];
-		unsigned char	loguuid[16];
-	} *js;
+		__u8	magic[4];
+		__u32	version;
+		__u64	size;
+		__u32	bsize;
+		__u32	dummy1;
+		__u32	pbsize;
+		__u32	dummy2[27];
+		__u8	uuid[16];
+		__u8	label[16];
+		__u8	loguuid[16];
+	} __attribute__((__packed__)) *js;
 
 	js = (struct jfs_super_block *)
 	     get_buffer(id, JFS_SUPERBLOCK_OFFSET, 0x200);
@@ -356,34 +408,34 @@
 static int probe_vfat(struct volume_id *id)
 {
 	struct vfat_super_block {
-		unsigned char	ignored[3];
-		unsigned char	sysid[8];
-		unsigned char	sector_size[2];
-		__u8		cluster_size;
-		__u16		reserved;
-		__u8		fats;
-		unsigned char	dir_entries[2];
-		unsigned char	sectors[2];
-		unsigned char	media;
-		__u16		fat_length;
-		__u16		secs_track;
-		__u16		heads;
-		__u32		hidden;
-		__u32		total_sect;
-		__u32		fat32_length;
-		__u16		flags;
-		__u8		version[2];
-		__u32		root_cluster;
-		__u16		insfo_sector;
-		__u16		backup_boot;
-		__u16		reserved2[6];
-		unsigned char	unknown[3];
-		unsigned char	serno[4];
-		char		label[11];
-		unsigned char	magic[8];
-		unsigned char	dummy2[164];
-		unsigned char	pmagic[2];
-	} *vs;
+		__u8	ignored[3];
+		__u8	sysid[8];
+		__u8	sector_size[2];
+		__u8	cluster_size;
+		__u16	reserved;
+		__u8	fats;
+		__u8	dir_entries[2];
+		__u8	sectors[2];
+		__u8	media;
+		__u16	fat_length;
+		__u16	secs_track;
+		__u16	heads;
+		__u32	hidden;
+		__u32	total_sect;
+		__u32	fat32_length;
+		__u16	flags;
+		__u8	version[2];
+		__u32	root_cluster;
+		__u16	insfo_sector;
+		__u16	backup_boot;
+		__u16	reserved2[6];
+		__u8	unknown[3];
+		__u8	serno[4];
+		__u8	label[11];
+		__u8	magic[8];
+		__u8	dummy2[164];
+		__u8	pmagic[2];
+	} __attribute__((__packed__)) *vs;
 
 	vs = (struct vfat_super_block *) get_buffer(id, 0, 0x200);
 	if (vs == NULL)
@@ -409,27 +461,27 @@
 static int probe_msdos(struct volume_id *id)
 {
 	struct msdos_super_block {
-		unsigned char	ignored[3];
-		unsigned char	sysid[8];
-		unsigned char	sector_size[2];
-		__u8		cluster_size;
-		__u16		reserved;
-		__u8		fats;
-		unsigned char	dir_entries[2];
-		unsigned char	sectors[2];
-		unsigned char	media;
-		__u16		fat_length;
-		__u16		secs_track;
-		__u16		heads;
-		__u32		hidden;
-		__u32		total_sect;
-		unsigned char	unknown[3];
-		unsigned char	serno[4];
-		char		label[11];
-		unsigned char	magic[8];
-		unsigned char	dummy2[192];
-		unsigned char	pmagic[2];
-	} *ms;
+		__u8	ignored[3];
+		__u8	sysid[8];
+		__u8	sector_size[2];
+		__u8	cluster_size;
+		__u16	reserved;
+		__u8	fats;
+		__u8	dir_entries[2];
+		__u8	sectors[2];
+		__u8	media;
+		__u16	fat_length;
+		__u16	secs_track;
+		__u16	heads;
+		__u32	hidden;
+		__u32	total_sect;
+		__u8	unknown[3];
+		__u8	serno[4];
+		__u8	label[11];
+		__u8	magic[8];
+		__u8	dummy2[192];
+		__u8	pmagic[2];
+	} __attribute__((__packed__)) *ms;
 
 	ms = (struct msdos_super_block *) get_buffer(id, 0, 0x200);
 	if (ms == NULL)
@@ -459,45 +511,43 @@
 {
 	struct volume_descriptor {
 		struct descriptor_tag {
-			__u16		id;
-			__u16		version;
-			unsigned char	checksum;
-			unsigned char	reserved;
-			__u16		serial;
-			__u16		crc;
-			__u16		crc_len;
-			__u32		location;
-		} tag;
+			__u16	id;
+			__u16	version;
+			__u8	checksum;
+			__u8	reserved;
+			__u16	serial;
+			__u16	crc;
+			__u16	crc_len;
+			__u32	location;
+		} __attribute__((__packed__)) tag;
 		union {
 			struct anchor_descriptor {
-				__u32		length;
-				__u32		location;
-			} anchor;
+				__u32	length;
+				__u32	location;
+			} __attribute__((__packed__)) anchor;
 			struct primary_descriptor {
-				__u32		seq_num;
-				__u32		desc_num;
+				__u32	seq_num;
+				__u32	desc_num;
 				struct dstring {
-					char		clen;
-					char		c[31];
-				} ident;
-			} primary;
-		} type;
-	} *vd;
+					__u8	clen;
+					__u8	c[31];
+				} __attribute__((__packed__)) ident;
+			} __attribute__((__packed__)) primary;
+		} __attribute__((__packed__)) type;
+	} __attribute__((__packed__)) *vd;
 
 	struct volume_structure_descriptor {
-		unsigned char	type;
-		char		id[5];
-		unsigned char	version;
+		__u8	type;
+		__u8	id[5];
+		__u8	version;
 	} *vsd;
 
-	size_t bs;
-	size_t b;
-	int type;
-	int count;
-	int loc;
-	int clen;
-	int i,j;
-	int c;
+	unsigned int bs;
+	unsigned int b;
+	unsigned int type;
+	unsigned int count;
+	unsigned int loc;
+	unsigned int clen;
 
 	vsd = (struct volume_structure_descriptor *)
 	      get_buffer(id, UDF_VSD_OFFSET, 0x200);
@@ -594,29 +644,10 @@
 
 	clen = vd->type.primary.ident.clen;
 	dbg("label string charsize=%i bit", clen);
-	if (clen == 8) {
+	if (clen == 8) 
 		set_label_string(id, vd->type.primary.ident.c, 31);
-	} else if (clen == 16) {
-		/* convert unicode OSTA dstring to UTF-8 */
-		j = 0;
-		for (i = 0; i < 32; i += 2) {
-			c = (vd->type.primary.ident.c[i] << 8) |
-			    vd->type.primary.ident.c[i+1];
-			if (c == 0) {
-				id->label_string[j] = '\0';
-				break;
-			}else if (c < 0x80U) {
-				id->label_string[j++] = (char) c;
-			} else if (c < 0x800U) {
-				id->label_string[j++] = (char) (0xc0 | (c >> 6));
-				id->label_string[j++] = (char) (0x80 | (c & 0x3f));
-			} else {
-				id->label_string[j++] = (char) (0xe0 | (c >> 12));
-				id->label_string[j++] = (char) (0x80 | ((c >> 6) & 0x3f));
-				id->label_string[j++] = (char) (0x80 | (c & 0x3f));
-			}
-		}
-	}
+	else if (clen == 16)
+		set_label_unicode16(id, vd->type.primary.ident.c, BE,31);
 
 found:
 	id->fs_type = UDF;
@@ -630,20 +661,20 @@
 {
 	union iso_super_block {
 		struct iso_header {
-			unsigned char	type;
-			char		id[5];
-			unsigned char	version;
-			unsigned char	unused1;
-			char		system_id[32];
-			char		volume_id[32];
-		} iso;
+			__u8	type;
+			__u8	id[5];
+			__u8	version;
+			__u8	unused1;
+			__u8		system_id[32];
+			__u8		volume_id[32];
+		} __attribute__((__packed__)) iso;
 		struct hs_header {
-			char		foo[8];
-			unsigned char	type;
-			char		id[4];
-			unsigned char	version;
-		} hs;
-	} *is;
+			__u8	foo[8];
+			__u8	type;
+			__u8	id[4];
+			__u8	version;
+		} __attribute__((__packed__)) hs;
+	} __attribute__((__packed__)) *is;
 
 	is = (union iso_super_block *)
 	     get_buffer(id, ISO_SUPERBLOCK_OFFSET, 0x200);
@@ -666,12 +697,73 @@
 	return 0;
 }
 
+#define MFT_RECORD_VOLUME			3
+#define MFT_RECORD_ATTR_VOLUME_NAME		0x60u
+#define MFT_RECORD_ATTR_OBJECT_ID		0x40u
+#define MFT_RECORD_ATTR_END			0xffffffffu
 static int probe_ntfs(struct volume_id *id)
 {
 	struct ntfs_super_block {
-		char jump[3];
-		char oem_id[4];
-	} *ns;
+		__u8	jump[3];
+		__u8	oem_id[8];
+		struct bios_param_block {
+			__u16	bytes_per_sector;
+			__u8	sectors_per_cluster;
+			__u16	reserved_sectors;
+			__u8	fats;
+			__u16	root_entries;
+			__u16	sectors;
+			__u8	media_type;		/* 0xf8 = hard disk */
+			__u16	sectors_per_fat;
+			__u16	sectors_per_track;
+			__u16	heads;
+			__u32	hidden_sectors;
+			__u32	large_sectors;
+		} __attribute__((__packed__)) bpb;
+		__u8 unused[4];
+		__u64	number_of_sectors;
+		__u64	mft_cluster_location;
+		__u64	mft_mirror_cluster_location;
+		__s8	cluster_per_mft_record;
+	} __attribute__((__packed__)) *ns;
+
+	struct master_file_table_record {
+		__u8	magic[4];
+		__u16	usa_ofs;
+		__u16	usa_count;
+		__u64	lsn;
+		__u16	sequence_number;
+		__u16	link_count;
+		__u16	attrs_offset;
+		__u16	flags;
+		__u32	bytes_in_use;
+		__u32	bytes_allocated;
+	} __attribute__((__packed__)) *mftr;
+
+	struct file_attribute {
+		__u32	type;
+		__u32	len;
+		__u8	non_resident;
+		__u8	name_len;
+		__u16	name_offset;
+		__u16	flags;
+		__u16	instance;
+		__u32	value_len;
+		__u16	value_offset;
+	} __attribute__((__packed__)) *attr;
+
+	unsigned int	sector_size;
+	unsigned int	cluster_size;
+	unsigned long	mft_cluster;
+	unsigned long	mft_off;
+	unsigned int	mft_record_size;
+	unsigned int	attr_type;
+	unsigned int	attr_off;
+	unsigned int	attr_len;
+	unsigned int	val_off;
+	unsigned int	val_len;
+	const __u8 *buf;
+	const __u8 *val;
 
 	ns = (struct ntfs_super_block *) get_buffer(id, 0, 0x200);
 	if (ns == NULL)
@@ -680,6 +772,72 @@
 	if (strncmp(ns->oem_id, "NTFS", 4) != 0)
 		return -1;
 
+	sector_size = le16_to_cpu(ns->bpb.bytes_per_sector);
+	cluster_size = ns->bpb.sectors_per_cluster * sector_size;
+	mft_cluster = le64_to_cpu(ns->mft_cluster_location);
+	mft_off = mft_cluster * cluster_size;
+
+	if (ns->cluster_per_mft_record < 0)
+		/* size = -log2(mft_record_size); normally 1024 Bytes */
+		mft_record_size = 1 << -ns->cluster_per_mft_record;
+	else
+		mft_record_size = ns->cluster_per_mft_record * cluster_size;
+
+	dbg("sectorsize  0x%x", sector_size);
+	dbg("clustersize 0x%x", cluster_size);
+	dbg("mftcluster  %li", mft_cluster);
+	dbg("cluster per record  %li", ns->cluster_per_mft_record);
+	dbg("mft record size  %i", mft_record_size);
+
+	buf = get_buffer(id, mft_off + (MFT_RECORD_VOLUME * mft_record_size),
+			 mft_record_size);
+	if (buf == NULL)
+		goto found;
+
+	mftr = (struct master_file_table_record*) buf;
+	if (strncmp(mftr->magic, "FILE", 4) != 0)
+		goto found;
+
+	attr_off = le16_to_cpu(mftr->attrs_offset);
+	dbg("file $Volume's attributes are at offset %i", attr_off);
+
+	while (1) {
+		attr = (struct file_attribute*) &buf[attr_off];
+		attr_type = le32_to_cpu(attr->type);
+		attr_len = le16_to_cpu(attr->len);
+		val_off = le16_to_cpu(attr->value_offset);
+		val_len = le32_to_cpu(attr->value_len);
+
+		if (attr_type == MFT_RECORD_ATTR_END)
+			break;
+
+		dbg("found attribute type 0x%x, len %i, at offset %i",
+		    attr_type, attr_len, attr_off);
+
+		if (attr_type == MFT_RECORD_ATTR_VOLUME_NAME) {
+			dbg("found label, len %i", val_len);
+			if (val_len > VOLUME_ID_LABEL_SIZE)
+				val_len = VOLUME_ID_LABEL_SIZE;
+
+			val = &((__u8 *) attr)[val_off];
+			set_label_raw(id, val, val_len);
+			set_label_unicode16(id, val, LE, val_len);
+		}
+
+		if (attr_type == MFT_RECORD_ATTR_OBJECT_ID) {
+			dbg("found uuid");
+			val = &((__u8 *) attr)[val_off];
+			set_uuid(id, val, 16);
+		}
+
+		if (attr_len == 0)
+			break;
+		attr_off += attr_len;
+		if (attr_off >= mft_record_size)
+			break;
+	}
+
+found:
 	id->fs_type = NTFS;
 	id->fs_name = "ntfs";
 
@@ -689,8 +847,8 @@
 #define LARGEST_PAGESIZE			0x4000
 static int probe_swap(struct volume_id *id)
 {
-	char *sig;
-	size_t page;
+	const __u8 *sig;
+	unsigned int page;
 
 	/* huhh, the swap signature is on the end of the PAGE_SIZE */
 	for (page = 0x1000; page <= LARGEST_PAGESIZE; page <<= 1) {
@@ -823,10 +981,8 @@
 		return NULL;
 
 	id = volume_id_open_fd(fd);
-	if (id == NULL) {
-		close (fd);
+	if (id == NULL)
 		return NULL;
-	}
 
 	/* close fd on device close */
 	id->fd_close = 1;
@@ -838,13 +994,14 @@
 struct volume_id *volume_id_open_dev_t(dev_t devt)
 {
 	struct volume_id *id;
-	char tmp_node[VOLUME_ID_PATH_MAX];
+	__u8 tmp_node[VOLUME_ID_PATH_MAX];
 
 	snprintf(tmp_node, VOLUME_ID_PATH_MAX,
-		 "/tmp/volume-%u-%u", major(devt), minor(devt));
+		 "/tmp/volume-%u-%u-%u", getpid(), major(devt), minor(devt));
 	tmp_node[VOLUME_ID_PATH_MAX] = '\0';
 
 	/* create tempory node to open the block device */
+	unlink(tmp_node);
 	if (mknod(tmp_node, (S_IFBLK | 0600), devt) != 0)
 		return NULL;
 
Index: hal/hald/linux/volume_id/volume_id.h
===================================================================
RCS file: /cvs/hal/hal/hald/linux/volume_id/volume_id.h,v
retrieving revision 1.2
diff -u -r1.2 volume_id.h
--- hal/hald/linux/volume_id/volume_id.h	4 May 2004 21:56:47 -0000	1.2
+++ hal/hald/linux/volume_id/volume_id.h	19 Jun 2004 21:36:55 -0000
@@ -21,9 +21,9 @@
 #ifndef _VOLUME_ID_H_
 #define _VOLUME_ID_H_
 
-#define VOLUME_ID_VERSION		002
+#define VOLUME_ID_VERSION		004
 
-#define VOLUME_ID_LABEL_SIZE		32
+#define VOLUME_ID_LABEL_SIZE		64
 #define VOLUME_ID_UUID_SIZE		16
 #define VOLUME_ID_UUID_STRING_SIZE	37
 #define VOLUME_ID_PATH_MAX		255
@@ -45,19 +45,19 @@
 };
 
 struct volume_id {
-	char		label_raw[VOLUME_ID_LABEL_SIZE];
-	size_t		label_raw_len;
+	unsigned char	label_raw[VOLUME_ID_LABEL_SIZE];
+	unsigned int	label_raw_len;
 	char		label_string[VOLUME_ID_LABEL_SIZE+1];
 	unsigned char	uuid[VOLUME_ID_UUID_SIZE];
 	char		uuid_string[VOLUME_ID_UUID_STRING_SIZE];
 	enum		filesystem_type fs_type;
 	char		*fs_name;
 	int		fd;
-	char		*sbbuf;
-	size_t		sbbuf_len;
-	char		*seekbuf;
-	size_t		seekbuf_off;
-	size_t		seekbuf_len;
+	unsigned char	*sbbuf;
+	unsigned int	sbbuf_len;
+	unsigned char	*seekbuf;
+	unsigned int	seekbuf_off;
+	unsigned int	seekbuf_len;
 	int		fd_close;
 };
 
-------------- next part --------------
_______________________________________________
hal mailing list
hal at freedesktop.org
http://freedesktop.org/mailman/listinfo/hal


More information about the Hal mailing list