hal/volume_id Makefile.am, 1.3, 1.4 cramfs.c, NONE, 1.1 cramfs.h, NONE, 1.1 dasd.c, 1.1, 1.2 dasd.h, 1.1, 1.2 ext.c, 1.1, 1.2 fat.c, 1.2, 1.3 hfs.c, 1.1, 1.2 highpoint.c, 1.1, 1.2 hpfs.c, NONE, 1.1 hpfs.h, NONE, 1.1 iso9660.c, 1.1, 1.2 jfs.c, 1.1, 1.2 linux_raid.c, 1.1, 1.2 linux_swap.c, 1.1, 1.2 lvm.c, 1.1, 1.2 mac.c, 1.1, 1.2 msdos.c, 1.1, 1.2 ntfs.c, 1.1, 1.2 reiserfs.c, 1.1, 1.2 romfs.c, NONE, 1.1 romfs.h, NONE, 1.1 sysv.c, NONE, 1.1 sysv.h, NONE, 1.1 udf.c, 1.1, 1.2 ufs.c, 1.1, 1.2 util.h, 1.1, 1.2 volume_id.c, 1.2, 1.3 volume_id.h, 1.3, 1.4 xfs.c, 1.1, 1.2

Kay Sievers kay at freedesktop.org
Wed Feb 16 14:40:50 PST 2005


Update of /cvs/hal/hal/volume_id
In directory gabe:/tmp/cvs-serv27474/volume_id

Modified Files:
	Makefile.am dasd.c dasd.h ext.c fat.c hfs.c highpoint.c 
	iso9660.c jfs.c linux_raid.c linux_swap.c lvm.c mac.c msdos.c 
	ntfs.c reiserfs.c udf.c ufs.c util.h volume_id.c volume_id.h 
	xfs.c 
Added Files:
	cramfs.c cramfs.h hpfs.c hpfs.h romfs.c romfs.h sysv.c sysv.h 
Log Message:
2005-02-16  Kay Sievers  <kay.sievers at vrfy.org>

        Update volume_id to version 34. Add support for hpfs, cramfs and romfs.
        some trivial cleanups.

        * volume_id/Makefile.am:

        * volume_id/cramfs.c: (volume_id_probe_cramfs):

        * volume_id/cramfs.h:

        * volume_id/dasd.c: (volume_id_probe_dasd):

        * volume_id/dasd.h:

        * volume_id/ext.c: (volume_id_probe_ext):

        * volume_id/fat.c: (volume_id_probe_vfat):

        * volume_id/hfs.c: (volume_id_probe_hfs_hfsplus):

        * volume_id/highpoint.c: (volume_id_probe_highpoint_ataraid):

        * volume_id/hpfs.c: (volume_id_probe_hpfs):

        * volume_id/hpfs.h:

        * volume_id/iso9660.c: (volume_id_probe_iso9660):

        * volume_id/jfs.c: (volume_id_probe_jfs):

        * volume_id/linux_raid.c: (volume_id_probe_linux_raid):

        * volume_id/linux_swap.c: (volume_id_probe_linux_swap):

        * volume_id/lvm.c: (volume_id_probe_lvm1), (volume_id_probe_lvm2):

        * volume_id/mac.c: (volume_id_probe_mac_partition_map):

        * volume_id/msdos.c: (volume_id_probe_msdos_part_table):

        * volume_id/ntfs.c: (volume_id_probe_ntfs):

        * volume_id/reiserfs.c: (volume_id_probe_reiserfs):

        * volume_id/romfs.c: (volume_id_probe_romfs):

        * volume_id/romfs.h:

        * volume_id/sysv.c: (volume_id_probe_sysv):

        * volume_id/sysv.h:

        * volume_id/udf.c: (volume_id_probe_udf):

        * volume_id/ufs.c: (volume_id_probe_ufs):

        * volume_id/util.h:

        * volume_id/volume_id.c: (volume_id_probe_all):

        * volume_id/volume_id.h:

        * volume_id/xfs.c: (volume_id_probe_xfs):



Index: Makefile.am
===================================================================
RCS file: /cvs/hal/hal/volume_id/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Makefile.am	16 Feb 2005 22:25:20 -0000	1.3
+++ Makefile.am	16 Feb 2005 22:40:47 -0000	1.4
@@ -22,6 +22,10 @@
 	udf.h			udf.c			\
 	ufs.h			ufs.c			\
 	xfs.h			xfs.c			\
+	hpfs.h			hpfs.c			\
+	romfs.h			romfs.c			\
+	sysv.h			sysv.c			\
+	cramfs.h		cramfs.c		\
 	logging.h					\
 	util.h			util.c			\
 	volume_id.h		volume_id.c

--- NEW FILE: cramfs.c ---
/*
 * volume_id - reads filesystem label and uuid
 *
 * Copyright (C) 2004 Kay Sievers <kay.sievers at vrfy.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
 */

#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <asm/types.h>

#include "volume_id.h"
#include "logging.h"
#include "util.h"
#include "cramfs.h"

struct cramfs_super {
	__u8	magic[4];
	__u32	size;
	__u32	flags;
	__u32	future;
	__u8	signature[16];
	struct cramfs_info {
		__u32	crc;
		__u32	edition;
		__u32	blocks;
		__u32	files;
	} __attribute__((__packed__)) info;
	__u8 name[16];
} __attribute__((__packed__));

int volume_id_probe_cramfs(struct volume_id *id, __u64 off)
{
	struct cramfs_super *cs;

	dbg("probing at offset %llu", off);

	cs = (struct cramfs_super *) volume_id_get_buffer(id, off, 0x200);
	if (cs == NULL)
		return -1;

	if (memcmp(cs->magic, "\x45\x3d\xcd\x28", 4) == 0) {
		volume_id_set_label_raw(id, cs->name, 16);
		volume_id_set_label_string(id, cs->name, 16);

		volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
		id->type = "cramfs";
		return 0;
	}

	return -1;
}

--- NEW FILE: cramfs.h ---
/*
 * volume_id - reads filesystem label and uuid
 *
 * Copyright (C) 2004 Kay Sievers <kay.sievers at vrfy.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
 */

#ifndef _VOLUME_ID_CRAMFS_
#define _VOLUME_ID_CRAMFS_

extern int volume_id_probe_cramfs(struct volume_id *id, __u64 off);

#endif

Index: dasd.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/dasd.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dasd.c	7 Feb 2005 21:24:16 -0000	1.1
+++ dasd.c	16 Feb 2005 22:40:47 -0000	1.2
@@ -35,6 +35,7 @@
 #include <asm/types.h>
 
 #include "volume_id.h"
+#include "logging.h"
 #include "util.h"
 #include "dasd.h"
 
@@ -160,7 +161,7 @@
 #define BIODASDINFO _IOR(DASD_IOCTL_LETTER,1,dasd_information_t)
 #define BLKSSZGET _IO(0x12,104)
 
-int probe_ibm_partition(struct volume_id *id)
+int volume_id_probe_dasd(struct volume_id *id)
 {
 	int blocksize;
 	dasd_information_t info;
@@ -168,6 +169,8 @@
 	__u8 *label_raw;
 	unsigned char name[7];
 
+	dbg("probing");
+
 	if (ioctl(id->fd, BIODASDINFO, &info) != 0)
 		return -1;
 

Index: dasd.h
===================================================================
RCS file: /cvs/hal/hal/volume_id/dasd.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- dasd.h	7 Feb 2005 21:24:16 -0000	1.1
+++ dasd.h	16 Feb 2005 22:40:47 -0000	1.2
@@ -21,6 +21,6 @@
 #ifndef _VOLUME_ID_DASDLABEL_
 #define _VOLUME_ID_DASDLABEL_
 
-extern int probe_ibm_partition(struct volume_id *id);
+extern int volume_id_probe_dasd(struct volume_id *id);
 
 #endif

Index: ext.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/ext.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ext.c	7 Feb 2005 21:24:16 -0000	1.1
+++ ext.c	16 Feb 2005 22:40:47 -0000	1.2
@@ -39,30 +39,34 @@
 #include "logging.h"
 #include "ext.h"
 
+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];
+	__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__));
+
 #define EXT3_FEATURE_COMPAT_HAS_JOURNAL		0x00000004
 #define EXT3_FEATURE_INCOMPAT_JOURNAL_DEV	0x00000008
 #define EXT_SUPERBLOCK_OFFSET			0x400
 
 int volume_id_probe_ext(struct volume_id *id, __u64 off)
 {
-	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];
-		__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;
+	struct ext2_super_block *es;
+
+	dbg("probing at offset %llu", off);
 
 	es = (struct ext2_super_block *) volume_id_get_buffer(id, off + EXT_SUPERBLOCK_OFFSET, 0x200);
 	if (es == NULL)

Index: fat.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/fat.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- fat.c	10 Feb 2005 17:03:57 -0000	1.2
+++ fat.c	16 Feb 2005 22:40:47 -0000	1.3
@@ -159,6 +159,8 @@
 	__u32 next;
 	int maxloop;
 
+	dbg("probing at offset %llu", off);
+
 	vs = (struct vfat_super_block *) volume_id_get_buffer(id, off, 0x200);
 	if (vs == NULL)
 		return -1;
@@ -166,22 +168,22 @@
 	/* believe only that's fat, don't trust the version
 	 * the cluster_count will tell us
 	 */
-	if (strncmp(vs->sysid, "NTFS", 4) == 0)
+	if (memcmp(vs->sysid, "NTFS", 4) == 0)
 		return -1;
 
-	if (strncmp(vs->type.fat32.magic, "MSWIN", 5) == 0)
+	if (memcmp(vs->type.fat32.magic, "MSWIN", 5) == 0)
 		goto valid;
 
-	if (strncmp(vs->type.fat32.magic, "FAT32   ", 8) == 0)
+	if (memcmp(vs->type.fat32.magic, "FAT32   ", 8) == 0)
 		goto valid;
 
-	if (strncmp(vs->type.fat.magic, "FAT16   ", 8) == 0)
+	if (memcmp(vs->type.fat.magic, "FAT16   ", 8) == 0)
 		goto valid;
 
-	if (strncmp(vs->type.fat.magic, "MSDOS", 5) == 0)
+	if (memcmp(vs->type.fat.magic, "MSDOS", 5) == 0)
 		goto valid;
 
-	if (strncmp(vs->type.fat.magic, "FAT12   ", 8) == 0)
+	if (memcmp(vs->type.fat.magic, "FAT12   ", 8) == 0)
 		goto valid;
 
 	/*
@@ -272,10 +274,10 @@
 	if (vs == NULL)
 		return -1;
 
-	if (label != NULL && strncmp(label, "NO NAME    ", 11) != 0) {
+	if (label != NULL && memcmp(label, "NO NAME    ", 11) != 0) {
 		volume_id_set_label_raw(id, label, 11);
 		volume_id_set_label_string(id, label, 11);
-	} else if (strncmp(vs->type.fat.label, "NO NAME    ", 11) != 0) {
+	} else if (memcmp(vs->type.fat.label, "NO NAME    ", 11) != 0) {
 		volume_id_set_label_raw(id, vs->type.fat.label, 11);
 		volume_id_set_label_string(id, vs->type.fat.label, 11);
 	}
@@ -333,10 +335,10 @@
 	if (vs == NULL)
 		return -1;
 
-	if (label != NULL && strncmp(label, "NO NAME    ", 11) != 0) {
+	if (label != NULL && memcmp(label, "NO NAME    ", 11) != 0) {
 		volume_id_set_label_raw(id, label, 11);
 		volume_id_set_label_string(id, label, 11);
-	} else if (strncmp(vs->type.fat32.label, "NO NAME    ", 11) != 0) {
+	} else if (memcmp(vs->type.fat32.label, "NO NAME    ", 11) != 0) {
 		volume_id_set_label_raw(id, vs->type.fat32.label, 11);
 		volume_id_set_label_string(id, vs->type.fat32.label, 11);
 	}

Index: hfs.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/hfs.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- hfs.c	7 Feb 2005 21:24:16 -0000	1.1
+++ hfs.c	16 Feb 2005 22:40:47 -0000	1.2
@@ -39,119 +39,119 @@
 #include "util.h"
 #include "hfs.h"
 
-#define HFS_SUPERBLOCK_OFFSET		0x400
-#define HFS_NODE_LEAF			0xff
-#define HFSPLUS_POR_CNID		1
-#define HFSPLUS_EXTENT_COUNT		8
+struct hfs_finder_info{
+	__u32	boot_folder;
+	__u32	start_app;
+	__u32	open_folder;
+	__u32	os9_folder;
+	__u32	reserved;
+	__u32	osx_folder;
+	__u8	id[8];
+} __attribute__((__packed__));
 
-int volume_id_probe_hfs_hfsplus(struct volume_id *id, __u64 off)
-{
-	struct hfs_finder_info{
-		__u32	boot_folder;
-		__u32	start_app;
-		__u32	open_folder;
-		__u32	os9_folder;
-		__u32	reserved;
-		__u32	osx_folder;
-		__u8	id[8];
-	} __attribute__((__packed__));
+struct hfs_mdb {
+	__u8	signature[2];
+	__u32	cr_date;
+	__u32	ls_Mod;
+	__u16	atrb;
+	__u16	nm_fls;
+	__u16	vbm_st;
+	__u16	alloc_ptr;
+	__u16	nm_al_blks;
+	__u32	al_blk_size;
+	__u32	clp_size;
+	__u16	al_bl_st;
+	__u32	nxt_cnid;
+	__u16	free_bks;
+	__u8	label_len;
+	__u8	label[27];
+	__u32	vol_bkup;
+	__u16	vol_seq_num;
+	__u32	wr_cnt;
+	__u32	xt_clump_size;
+	__u32	ct_clump_size;
+	__u16	num_root_dirs;
+	__u32	file_count;
+	__u32	dir_count;
+	struct hfs_finder_info finder_info;
+	__u8	embed_sig[2];
+	__u16	embed_startblock;
+	__u16	embed_blockcount;
+} __attribute__((__packed__)) *hfs;
 
-	struct hfs_mdb {
-		__u8	signature[2];
-		__u32	cr_date;
-		__u32	ls_Mod;
-		__u16	atrb;
-		__u16	nm_fls;
-		__u16	vbm_st;
-		__u16	alloc_ptr;
-		__u16	nm_al_blks;
-		__u32	al_blk_size;
-		__u32	clp_size;
-		__u16	al_bl_st;
-		__u32	nxt_cnid;
-		__u16	free_bks;
-		__u8	label_len;
-		__u8	label[27];
-		__u32	vol_bkup;
-		__u16	vol_seq_num;
-		__u32	wr_cnt;
-		__u32	xt_clump_size;
-		__u32	ct_clump_size;
-		__u16	num_root_dirs;
-		__u32	file_count;
-		__u32	dir_count;
-		struct hfs_finder_info finder_info;
-		__u8	embed_sig[2];
-		__u16	embed_startblock;
-		__u16	embed_blockcount;
-	} __attribute__((__packed__)) *hfs;
+struct hfsplus_bnode_descriptor {
+	__u32	next;
+	__u32	prev;
+	__u8	type;
+	__u8	height;
+	__u16	num_recs;
+	__u16	reserved;
+} __attribute__((__packed__));
 
-	struct hfsplus_bnode_descriptor {
-		__u32	next;
-		__u32	prev;
-		__u8	type;
-		__u8	height;
-		__u16	num_recs;
-		__u16	reserved;
-	} __attribute__((__packed__));
+struct hfsplus_bheader_record {
+	__u16	depth;
+	__u32	root;
+	__u32	leaf_count;
+	__u32	leaf_head;
+	__u32	leaf_tail;
+	__u16	node_size;
+} __attribute__((__packed__));
 
-	struct hfsplus_bheader_record {
-		__u16	depth;
-		__u32	root;
-		__u32	leaf_count;
-		__u32	leaf_head;
-		__u32	leaf_tail;
-		__u16	node_size;
-	} __attribute__((__packed__));
+struct hfsplus_catalog_key {
+	__u16	key_len;
+	__u32	parent_id;
+	__u16	unicode_len;
+	__u8	unicode[255 * 2];
+} __attribute__((__packed__));
 
-	struct hfsplus_catalog_key {
-		__u16	key_len;
-		__u32	parent_id;
-		__u16	unicode_len;
-		__u8	unicode[255 * 2];
-	} __attribute__((__packed__));
+struct hfsplus_extent {
+	__u32 start_block;
+	__u32 block_count;
+} __attribute__((__packed__));
 
-	struct hfsplus_extent {
-		__u32 start_block;
-		__u32 block_count;
-	} __attribute__((__packed__));
+#define HFSPLUS_EXTENT_COUNT		8
+struct hfsplus_fork {
+	__u64 total_size;
+	__u32 clump_size;
+	__u32 total_blocks;
+	struct hfsplus_extent extents[HFSPLUS_EXTENT_COUNT];
+} __attribute__((__packed__));
 
-	struct hfsplus_fork {
-		__u64 total_size;
-        	__u32 clump_size;
-		__u32 total_blocks;
-		struct hfsplus_extent extents[HFSPLUS_EXTENT_COUNT];
-	} __attribute__((__packed__));
+struct hfsplus_vol_header {
+	__u8	signature[2];
+	__u16	version;
+	__u32	attributes;
+	__u32	last_mount_vers;
+	__u32	reserved;
+	__u32	create_date;
+	__u32	modify_date;
+	__u32	backup_date;
+	__u32	checked_date;
+	__u32	file_count;
+	__u32	folder_count;
+	__u32	blocksize;
+	__u32	total_blocks;
+	__u32	free_blocks;
+	__u32	next_alloc;
+	__u32	rsrc_clump_sz;
+	__u32	data_clump_sz;
+	__u32	next_cnid;
+	__u32	write_count;
+	__u64	encodings_bmp;
+	struct hfs_finder_info finder_info;
+	struct hfsplus_fork alloc_file;
+	struct hfsplus_fork ext_file;
+	struct hfsplus_fork cat_file;
+	struct hfsplus_fork attr_file;
+	struct hfsplus_fork start_file;
+} __attribute__((__packed__)) *hfsplus;
 
-	struct hfsplus_vol_header {
-		__u8	signature[2];
-		__u16	version;
-		__u32	attributes;
-		__u32	last_mount_vers;
-		__u32	reserved;
-		__u32	create_date;
-		__u32	modify_date;
-		__u32	backup_date;
-		__u32	checked_date;
-		__u32	file_count;
-		__u32	folder_count;
-		__u32	blocksize;
-		__u32	total_blocks;
-		__u32	free_blocks;
-		__u32	next_alloc;
-		__u32	rsrc_clump_sz;
-		__u32	data_clump_sz;
-		__u32	next_cnid;
-		__u32	write_count;
-		__u64	encodings_bmp;
-		struct hfs_finder_info finder_info;
-		struct hfsplus_fork alloc_file;
-		struct hfsplus_fork ext_file;
-		struct hfsplus_fork cat_file;
-		struct hfsplus_fork attr_file;
-		struct hfsplus_fork start_file;
-	} __attribute__((__packed__)) *hfsplus;
+#define HFS_SUPERBLOCK_OFFSET		0x400
+#define HFS_NODE_LEAF			0xff
+#define HFSPLUS_POR_CNID		1
 
+int volume_id_probe_hfs_hfsplus(struct volume_id *id, __u64 off)
+{
 	unsigned int blocksize;
 	unsigned int cat_block;
 	unsigned int ext_block_start;
@@ -173,16 +173,18 @@
 	struct hfsplus_extent extents[HFSPLUS_EXTENT_COUNT];
 	const __u8 *buf;
 
+	dbg("probing at offset %llu", off);
+
 	buf = volume_id_get_buffer(id, off + HFS_SUPERBLOCK_OFFSET, 0x200);
 	if (buf == NULL)
                 return -1;
 
 	hfs = (struct hfs_mdb *) buf;
-	if (strncmp(hfs->signature, "BD", 2) != 0)
+	if (memcmp(hfs->signature, "BD", 2) != 0)
 		goto checkplus;
 
 	/* it may be just a hfs wrapper for hfs+ */
-	if (strncmp(hfs->embed_sig, "H+", 2) == 0) {
+	if (memcmp(hfs->embed_sig, "H+", 2) == 0) {
 		alloc_block_size = be32_to_cpu(hfs->al_blk_size);
 		dbg("alloc_block_size 0x%x", alloc_block_size);
 
@@ -216,9 +218,9 @@
 
 checkplus:
 	hfsplus = (struct hfsplus_vol_header *) buf;
-	if (strncmp(hfsplus->signature, "H+", 2) == 0)
+	if (memcmp(hfsplus->signature, "H+", 2) == 0)
 		goto hfsplus;
-	if (strncmp(hfsplus->signature, "HX", 2) == 0)
+	if (memcmp(hfsplus->signature, "HX", 2) == 0)
 		goto hfsplus;
 	return -1;
 

Index: highpoint.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/highpoint.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- highpoint.c	7 Feb 2005 21:24:16 -0000	1.1
+++ highpoint.c	16 Feb 2005 22:40:47 -0000	1.2
@@ -39,21 +39,23 @@
 #include "util.h"
 #include "highpoint.h"
 
+struct hpt37x {
+	__u8	filler1[32];
+	__u32	magic;
+	__u32	magic_0;
+	__u32	magic_1;
+} __attribute__((packed)) *hpt;
+
 #define HPT37X_CONFIG_OFF		0x1200
 #define HPT37X_MAGIC_OK			0x5a7816f0
 #define HPT37X_MAGIC_BAD		0x5a7816fd
 
 int volume_id_probe_highpoint_ataraid(struct volume_id *id, __u64 off)
 {
-	struct hpt37x {
-		__u8	filler1[32];
-		__u32	magic;
-		__u32	magic_0;
-		__u32	magic_1;
-	} __attribute__((packed)) *hpt;
-
 	const __u8 *buf;
 
+	dbg("probing at offset %llu", off);
+
 	buf = volume_id_get_buffer(id, off + HPT37X_CONFIG_OFF, 0x200);
 	if (buf == NULL)
 		return -1;

--- NEW FILE: hpfs.c ---
/*
 * volume_id - reads filesystem label and uuid
 *
 * Copyright (C) 2005 Kay Sievers <kay.sievers at vrfy.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
 */

#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <asm/types.h>

#include "volume_id.h"
#include "logging.h"
#include "util.h"
#include "hpfs.h"

struct hpfs_super
{
	__u8	magic[4];
	__u8	version;
} __attribute__((__packed__));

#define HPFS_SUPERBLOCK_OFFSET			0x2000

int volume_id_probe_hpfs(struct volume_id *id, __u64 off)
{
	struct hpfs_super *hs;

	dbg("probing at offset %llu", off);

	hs = (struct hpfs_super *) volume_id_get_buffer(id, off + HPFS_SUPERBLOCK_OFFSET, 0x200);
	if (hs == NULL)
		return -1;

	if (memcmp(hs->magic, "\x49\xe8\x95\xf9", 4) == 0) {
		snprintf(id->type_version, VOLUME_ID_FORMAT_SIZE-1, "%u", hs->version);

		volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
		id->type = "hpfs";
		return 0;
	}

	return -1;
}

--- NEW FILE: hpfs.h ---
/*
 * volume_id - reads filesystem label and uuid
 *
 * Copyright (C) 2005 Kay Sievers <kay.sievers at vrfy.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
 */

#ifndef _VOLUME_ID_HPFS_
#define _VOLUME_ID_HPFS_

extern int volume_id_probe_hpfs(struct volume_id *id, __u64 off);

#endif

Index: iso9660.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/iso9660.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- iso9660.c	7 Feb 2005 21:24:16 -0000	1.1
+++ iso9660.c	16 Feb 2005 22:40:47 -0000	1.2
@@ -47,30 +47,34 @@
 #define ISO_VD_END			0xff
 #define ISO_VD_MAX			16
 
+union iso_super_block {
+	struct iso_header {
+		__u8	type;
+		__u8	id[5];
+		__u8	version;
+		__u8	unused1;
+		__u8		system_id[32];
+		__u8		volume_id[32];
+	} __attribute__((__packed__)) iso;
+	struct hs_header {
+		__u8	foo[8];
+		__u8	type;
+		__u8	id[4];
+		__u8	version;
+	} __attribute__((__packed__)) hs;
+} __attribute__((__packed__));
+
 int volume_id_probe_iso9660(struct volume_id *id, __u64 off)
 {
-	union iso_super_block {
-		struct iso_header {
-			__u8	type;
-			__u8	id[5];
-			__u8	version;
-			__u8	unused1;
-			__u8		system_id[32];
-			__u8		volume_id[32];
-		} __attribute__((__packed__)) iso;
-		struct hs_header {
-			__u8	foo[8];
-			__u8	type;
-			__u8	id[4];
-			__u8	version;
-		} __attribute__((__packed__)) hs;
-	} __attribute__((__packed__)) *is;
+	union iso_super_block *is;
+
+	dbg("probing at offset %llu", off);
 
 	is = (union iso_super_block *) volume_id_get_buffer(id, off + ISO_SUPERBLOCK_OFFSET, 0x200);
 	if (is == NULL)
 		return -1;
 
-	if (strncmp(is->iso.id, "CD001", 5) == 0) {
+	if (memcmp(is->iso.id, "CD001", 5) == 0) {
 		char root_label[VOLUME_ID_LABEL_SIZE+1];
 		int vd_offset;
 		int i;
@@ -96,14 +100,14 @@
 		}
 
 		if (!found_svd ||
-		    (found_svd && !strncmp(root_label, id->label, 16)))
+		    (found_svd && !memcmp(root_label, id->label, 16)))
 		{
 			volume_id_set_label_raw(id, root_label, 32);
 			volume_id_set_label_string(id, root_label, 32);
 		}
 		goto found;
 	}
-	if (strncmp(is->hs.id, "CDROM", 5) == 0)
+	if (memcmp(is->hs.id, "CDROM", 5) == 0)
 		goto found;
 	return -1;
 

Index: jfs.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/jfs.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- jfs.c	7 Feb 2005 21:24:16 -0000	1.1
+++ jfs.c	16 Feb 2005 22:40:47 -0000	1.2
@@ -39,28 +39,32 @@
 #include "util.h"
 #include "jfs.h"
 
+struct jfs_super_block {
+	__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__));
+
 #define JFS_SUPERBLOCK_OFFSET			0x8000
 
 int volume_id_probe_jfs(struct volume_id *id, __u64 off)
 {
-	struct jfs_super_block {
-		__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;
+	struct jfs_super_block *js;
+
+	dbg("probing at offset %llu", off);
 
 	js = (struct jfs_super_block *) volume_id_get_buffer(id, off + JFS_SUPERBLOCK_OFFSET, 0x200);
 	if (js == NULL)
 		return -1;
 
-	if (strncmp(js->magic, "JFS1", 4) != 0)
+	if (memcmp(js->magic, "JFS1", 4) != 0)
 		return -1;
 
 	volume_id_set_label_raw(id, js->label, 16);

Index: linux_raid.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/linux_raid.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- linux_raid.c	7 Feb 2005 21:24:16 -0000	1.1
+++ linux_raid.c	16 Feb 2005 22:40:47 -0000	1.2
@@ -39,34 +39,36 @@
 #include "util.h"
 #include "linux_raid.h"
 
+struct mdp_super_block {
+	__u32	md_magic;
+	__u32	major_version;
+	__u32	minor_version;
+	__u32	patch_version;
+	__u32	gvalid_words;
+	__u32	set_uuid0;
+	__u32	ctime;
+	__u32	level;
+	__u32	size;
+	__u32	nr_disks;
+	__u32	raid_disks;
+	__u32	md_minor;
+	__u32	not_persistent;
+	__u32	set_uuid1;
+	__u32	set_uuid2;
+	__u32	set_uuid3;
+} __attribute__((packed)) *mdp;
+
 #define MD_RESERVED_BYTES		0x10000
 #define MD_MAGIC			0xa92b4efc
 
 int volume_id_probe_linux_raid(struct volume_id *id, __u64 off, __u64 size)
 {
-	struct mdp_super_block {
-		__u32	md_magic;
-		__u32	major_version;
-		__u32	minor_version;
-		__u32	patch_version;
-		__u32	gvalid_words;
-		__u32	set_uuid0;
-		__u32	ctime;
-		__u32	level;
-		__u32	size;
-		__u32	nr_disks;
-		__u32	raid_disks;
-		__u32	md_minor;
-		__u32	not_persistent;
-		__u32	set_uuid1;
-		__u32	set_uuid2;
-		__u32	set_uuid3;
-	} __attribute__((packed)) *mdp;
-
 	const __u8 *buf;
 	__u64 sboff;
 	__u8 uuid[16];
 
+	dbg("probing at offset %llu", off);
+
 	if (size < 0x10000)
 		return -1;
 

Index: linux_swap.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/linux_swap.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- linux_swap.c	7 Feb 2005 21:24:16 -0000	1.1
+++ linux_swap.c	16 Feb 2005 22:40:47 -0000	1.2
@@ -39,34 +39,36 @@
 #include "util.h"
 #include "linux_swap.h"
 
+struct swap_header_v1_2 {
+	__u8	bootbits[1024];
+	__u32	version;
+	__u32	last_page;
+	__u32	nr_badpages;
+	__u8	uuid[16];
+	__u8	volume_name[16];
+} __attribute__((__packed__)) *sw;
+
 #define LARGEST_PAGESIZE			0x4000
 
 int volume_id_probe_linux_swap(struct volume_id *id, __u64 off)
 {
-	struct swap_header_v1_2 {
-		__u8	bootbits[1024];
-		__u32	version;
-		__u32	last_page;
-		__u32	nr_badpages;
-		__u8	uuid[16];
-		__u8	volume_name[16];
-	} __attribute__((__packed__)) *sw;
-
 	const __u8 *buf;
 	unsigned int page;
 
+	dbg("probing at offset %llu", off);
+
 	/* the swap signature is at the end of the PAGE_SIZE */
 	for (page = 0x1000; page <= LARGEST_PAGESIZE; page <<= 1) {
 			buf = volume_id_get_buffer(id, off + page-10, 10);
 			if (buf == NULL)
 				return -1;
 
-			if (strncmp(buf, "SWAP-SPACE", 10) == 0) {
+			if (memcmp(buf, "SWAP-SPACE", 10) == 0) {
 				strcpy(id->type_version, "1");
 				goto found;
 			}
 
-			if (strncmp(buf, "SWAPSPACE2", 10) == 0) {
+			if (memcmp(buf, "SWAPSPACE2", 10) == 0) {
 				sw = (struct swap_header_v1_2 *) volume_id_get_buffer(id, off, sizeof(struct swap_header_v1_2));
 				if (sw == NULL)
 					return -1;

Index: lvm.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/lvm.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- lvm.c	7 Feb 2005 21:24:16 -0000	1.1
+++ lvm.c	16 Feb 2005 22:40:47 -0000	1.2
@@ -39,24 +39,35 @@
 #include "util.h"
 #include "lvm.h"
 
+struct lvm1_super_block {
+	__u8	id[2];
+} __attribute__((packed));
+
+struct lvm2_super_block {
+	__u8	id[8];
+	__u64	sector_xl;
+	__u32	crc_xl;
+	__u32	offset_xl;
+	__u8	type[8];
+} __attribute__((packed));
+
 #define LVM1_SB_OFF			0x400
 #define LVM1_MAGIC			"HM"
 
 int volume_id_probe_lvm1(struct volume_id *id, __u64 off)
 {
-	struct lvm2_super_block {
-		__u8	id[2];
-	} __attribute__((packed)) *lvm;
-
 	const __u8 *buf;
+	struct lvm1_super_block *lvm;
+
+	dbg("probing at offset %llu", off);
 
 	buf = volume_id_get_buffer(id, off + LVM1_SB_OFF, 0x800);
 	if (buf == NULL)
 		return -1;
 
-	lvm = (struct lvm2_super_block *) buf;
+	lvm = (struct lvm1_super_block *) buf;
 
-	if (strncmp(lvm->id, LVM1_MAGIC, 2) != 0)
+	if (memcmp(lvm->id, LVM1_MAGIC, 2) != 0)
 		return -1;
 
 	volume_id_set_usage(id, VOLUME_ID_RAID);
@@ -70,16 +81,11 @@
 
 int volume_id_probe_lvm2(struct volume_id *id, __u64 off)
 {
-	struct lvm2_super_block {
-		__u8	id[8];
-		__u64	sector_xl;
-		__u32	crc_xl;
-		__u32	offset_xl;
-		__u8	type[8];
-	} __attribute__((packed)) *lvm;
-
 	const __u8 *buf;
 	unsigned int soff;
+	struct lvm2_super_block *lvm;
+
+	dbg("probing at offset %llu", off);
 
 	buf = volume_id_get_buffer(id, off, LVM2LABEL_SCAN_SECTORS * 0x200);
 	if (buf == NULL)
@@ -89,7 +95,7 @@
 	for (soff = 0; soff < LVM2LABEL_SCAN_SECTORS * 0x200; soff += 0x200) {
 		lvm = (struct lvm2_super_block *) &buf[soff];
 
-		if (strncmp(lvm->id, LVM2_LABEL_ID, 8) == 0)
+		if (memcmp(lvm->id, LVM2_LABEL_ID, 8) == 0)
 			goto found;
 	}
 

Index: mac.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/mac.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- mac.c	7 Feb 2005 21:24:16 -0000	1.1
+++ mac.c	16 Feb 2005 22:40:47 -0000	1.2
@@ -39,33 +39,37 @@
 #include "util.h"
 #include "mac.h"
 
-int volume_id_probe_mac_partition_map(struct volume_id *id, __u64 off)
-{
-	struct mac_driver_desc {
-		__u8	signature[2];
-		__u16	block_size;
-		__u32	block_count;
-	} __attribute__((__packed__)) *driver;
+struct mac_driver_desc {
+	__u8	signature[2];
+	__u16	block_size;
+	__u32	block_count;
+} __attribute__((__packed__));
 
-	struct mac_partition {
-		__u8	signature[2];
-		__u16	res1;
-		__u32	map_count;
-		__u32	start_block;
-		__u32	block_count;
-		__u8	name[32];
-		__u8	type[32];
-	} __attribute__((__packed__)) *part;
+struct mac_partition {
+	__u8	signature[2];
+	__u16	res1;
+	__u32	map_count;
+	__u32	start_block;
+	__u32	block_count;
+	__u8	name[32];
+	__u8	type[32];
+} __attribute__((__packed__));
 
+int volume_id_probe_mac_partition_map(struct volume_id *id, __u64 off)
+{
 	const __u8 *buf;
+	struct mac_driver_desc *driver;
+	struct mac_partition *part;
+
+	dbg("probing at offset %llu", off);
 
 	buf = volume_id_get_buffer(id, off, 0x200);
 	if (buf == NULL)
 		return -1;
 
 	part = (struct mac_partition *) buf;
-	if ((strncmp(part->signature, "PM", 2) == 0) &&
-	    (strncmp(part->type, "Apple_partition_map", 19) == 0)) {
+	if ((memcmp(part->signature, "PM", 2) == 0) &&
+	    (memcmp(part->type, "Apple_partition_map", 19) == 0)) {
 		/* linux creates an own subdevice for the map
 		 * just return the type if the drive header is missing */
 		volume_id_set_usage(id, VOLUME_ID_PARTITIONTABLE);
@@ -74,7 +78,7 @@
 	}
 
 	driver = (struct mac_driver_desc *) buf;
-	if (strncmp(driver->signature, "ER", 2) == 0) {
+	if (memcmp(driver->signature, "ER", 2) == 0) {
 		/* we are on a main device, like a CD
 		 * just try to probe the first partition from the map */
 		unsigned int bsize = be16_to_cpu(driver->block_size);
@@ -87,7 +91,7 @@
 			return -1;
 
 		part = (struct mac_partition *) buf;
-		if (strncmp(part->signature, "PM", 2) != 0)
+		if (memcmp(part->signature, "PM", 2) != 0)
 			return -1;
 
 		part_count = be32_to_cpu(part->map_count);
@@ -112,7 +116,7 @@
 				return -1;
 
 			part = (struct mac_partition *) buf;
-			if (strncmp(part->signature, "PM", 2) != 0)
+			if (memcmp(part->signature, "PM", 2) != 0)
 				return -1;
 
 			poff = be32_to_cpu(part->start_block) * bsize;
@@ -123,9 +127,9 @@
 			id->partitions[i].off = poff;
 			id->partitions[i].len = plen;
 
-			if (strncmp(part->type, "Apple_Free", 10) == 0) {
+			if (memcmp(part->type, "Apple_Free", 10) == 0) {
 				volume_id_set_usage_part(&id->partitions[i], VOLUME_ID_UNUSED);
-			} else if (strncmp(part->type, "Apple_partition_map", 19) == 0) {
+			} else if (memcmp(part->type, "Apple_partition_map", 19) == 0) {
 				volume_id_set_usage_part(&id->partitions[i], VOLUME_ID_PARTITIONTABLE);
 			} else {
 				volume_id_set_usage_part(&id->partitions[i], VOLUME_ID_UNPROBED);

Index: msdos.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/msdos.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- msdos.c	7 Feb 2005 21:24:16 -0000	1.1
+++ msdos.c	16 Feb 2005 22:40:47 -0000	1.2
@@ -39,6 +39,19 @@
 #include "util.h"
 #include "msdos.h"
 
+struct msdos_partition_entry {
+	__u8	boot_ind;
+	__u8	head;
+	__u8	sector;
+	__u8	cyl;
+	__u8	sys_ind;
+	__u8	end_head;
+	__u8	end_sector;
+	__u8	end_cyl;
+	__u32	start_sect;
+	__u32	nr_sects;
+} __attribute__((packed));
+
 #define MSDOS_MAGIC			"\x55\xaa"
 #define MSDOS_PARTTABLE_OFFSET		0x1be
 #define MSDOS_SIG_OFF			0x1fe
@@ -56,19 +69,6 @@
 
 int volume_id_probe_msdos_part_table(struct volume_id *id, __u64 off)
 {
-	struct msdos_partition_entry {
-		__u8	boot_ind;
-		__u8	head;
-		__u8	sector;
-		__u8	cyl;
-		__u8	sys_ind;
-		__u8	end_head;
-		__u8	end_sector;
-		__u8	end_cyl;
-		__u32	start_sect;
-		__u32	nr_sects;
-	} __attribute__((packed)) *part;
-
 	const __u8 *buf;
 	int i;
 	__u64 poff;
@@ -78,13 +78,16 @@
 	__u64 next;
 	int limit;
 	int empty = 1;
+	struct msdos_partition_entry *part;
 	struct volume_id_partition *p;
 
+	dbg("probing at offset %llu", off);
+
 	buf = volume_id_get_buffer(id, off, 0x200);
 	if (buf == NULL)
 		return -1;
 
-	if (strncmp(&buf[MSDOS_SIG_OFF], MSDOS_MAGIC, 2) != 0)
+	if (memcmp(&buf[MSDOS_SIG_OFF], MSDOS_MAGIC, 2) != 0)
 		return -1;
 
 	/* check flags on all entries for a valid partition table */
@@ -158,7 +161,7 @@
 
 		part = (struct msdos_partition_entry*) &buf[MSDOS_PARTTABLE_OFFSET];
 
-		if (strncmp(&buf[MSDOS_SIG_OFF], MSDOS_MAGIC, 2) != 0)
+		if (memcmp(&buf[MSDOS_SIG_OFF], MSDOS_MAGIC, 2) != 0)
 			break;
 
 		next = 0;

Index: ntfs.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/ntfs.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ntfs.c	7 Feb 2005 21:24:16 -0000	1.1
+++ ntfs.c	16 Feb 2005 22:40:47 -0000	1.2
@@ -39,6 +39,64 @@
 #include "util.h"
 #include "ntfs.h"
 
+struct ntfs_super_block {
+	__u8	jump[3];
+	__u8	oem_id[8];
+	__u16	bytes_per_sector;
+	__u8	sectors_per_cluster;
+	__u16	reserved_sectors;
+	__u8	fats;
+	__u16	root_entries;
+	__u16	sectors;
+	__u8	media_type;
+	__u16	sectors_per_fat;
+	__u16	sectors_per_track;
+	__u16	heads;
+	__u32	hidden_sectors;
+	__u32	large_sectors;
+	__u16	unused[2];
+	__u64	number_of_sectors;
+	__u64	mft_cluster_location;
+	__u64	mft_mirror_cluster_location;
+	__s8	cluster_per_mft_record;
+	__u8	reserved1[3];
+	__s8	cluster_per_index_record;
+	__u8	reserved2[3];
+	__u8	volume_serial[8];
+	__u16	checksum;
+} __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;
+
+struct volume_info {
+	__u64 reserved;
+	__u8 major_ver;
+	__u8 minor_ver;
+} __attribute__((__packed__)) *info;
+
 #define MFT_RECORD_VOLUME			3
 #define MFT_RECORD_ATTR_VOLUME_NAME		0x60
 #define MFT_RECORD_ATTR_VOLUME_INFO		0x70
@@ -47,64 +105,6 @@
 
 int volume_id_probe_ntfs(struct volume_id *id, __u64 off)
 {
-	struct ntfs_super_block {
-		__u8	jump[3];
-		__u8	oem_id[8];
-		__u16	bytes_per_sector;
-		__u8	sectors_per_cluster;
-		__u16	reserved_sectors;
-		__u8	fats;
-		__u16	root_entries;
-		__u16	sectors;
-		__u8	media_type;
-		__u16	sectors_per_fat;
-		__u16	sectors_per_track;
-		__u16	heads;
-		__u32	hidden_sectors;
-		__u32	large_sectors;
-		__u16	unused[2];
-		__u64	number_of_sectors;
-		__u64	mft_cluster_location;
-		__u64	mft_mirror_cluster_location;
-		__s8	cluster_per_mft_record;
-		__u8	reserved1[3];
-		__s8	cluster_per_index_record;
-		__u8	reserved2[3];
-		__u8	volume_serial[8];
-		__u16	checksum;
-	} __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;
-
-	struct volume_info {
-		__u64 reserved;
-		__u8 major_ver;
-		__u8 minor_ver;
-	} __attribute__((__packed__)) *info;
-
 	unsigned int sector_size;
 	unsigned int cluster_size;
 	__u64 mft_cluster;
@@ -118,11 +118,13 @@
 	const __u8 *buf;
 	const __u8 *val;
 
+	dbg("probing at offset %llu", off);
+
 	ns = (struct ntfs_super_block *) volume_id_get_buffer(id, off, 0x200);
 	if (ns == NULL)
 		return -1;
 
-	if (strncmp(ns->oem_id, "NTFS", 4) != 0)
+	if (memcmp(ns->oem_id, "NTFS", 4) != 0)
 		return -1;
 
 	volume_id_set_uuid(id, ns->volume_serial, UUID_NTFS);
@@ -153,7 +155,7 @@
 	mftr = (struct master_file_table_record*) buf;
 
 	dbg("mftr->magic '%c%c%c%c'", mftr->magic[0], mftr->magic[1], mftr->magic[2], mftr->magic[3]);
-	if (strncmp(mftr->magic, "FILE", 4) != 0)
+	if (memcmp(mftr->magic, "FILE", 4) != 0)
 		goto found;
 
 	attr_off = le16_to_cpu(mftr->attrs_offset);

Index: reiserfs.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/reiserfs.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- reiserfs.c	7 Feb 2005 21:24:16 -0000	1.1
+++ reiserfs.c	16 Feb 2005 22:40:47 -0000	1.2
@@ -39,37 +39,41 @@
 #include "util.h"
 #include "reiserfs.h"
 
+struct reiserfs_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];
+	__u8	magic[12];
+	__u32	dummy4[5];
+	__u8	uuid[16];
+	__u8	label[16];
+} __attribute__((__packed__));
+
 #define REISERFS1_SUPERBLOCK_OFFSET		0x2000
 #define REISERFS_SUPERBLOCK_OFFSET		0x10000
 
 int volume_id_probe_reiserfs(struct volume_id *id, __u64 off)
 {
-	struct reiserfs_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];
-		__u8	magic[12];
-		__u32	dummy4[5];
-		__u8	uuid[16];
-		__u8	label[16];
-	} __attribute__((__packed__)) *rs;
+	struct reiserfs_super_block *rs;
+
+	dbg("probing at offset %llu", off);
 
 	rs = (struct reiserfs_super_block *) volume_id_get_buffer(id, off + REISERFS_SUPERBLOCK_OFFSET, 0x200);
 	if (rs == NULL)
 		return -1;
 
-	if (strncmp(rs->magic, "ReIsEr2Fs", 9) == 0) {
+	if (memcmp(rs->magic, "ReIsEr2Fs", 9) == 0) {
 		strcpy(id->type_version, "3.6");
 		goto found;
 	}
 
-	if (strncmp(rs->magic, "ReIsEr3Fs", 9) == 0) {
+	if (memcmp(rs->magic, "ReIsEr3Fs", 9) == 0) {
 		strcpy(id->type_version, "JR");
 		goto found;
 	}
@@ -78,7 +82,7 @@
 	if (rs == NULL)
 		return -1;
 
-	if (strncmp(rs->magic, "ReIsErFs", 8) == 0) {
+	if (memcmp(rs->magic, "ReIsErFs", 8) == 0) {
 		strcpy(id->type_version, "3.5");
 		goto found;
 	}

--- NEW FILE: romfs.c ---
/*
 * volume_id - reads filesystem label and uuid
 *
 * Copyright (C) 2004 Kay Sievers <kay.sievers at vrfy.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
 */

#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <asm/types.h>

#include "volume_id.h"
#include "logging.h"
#include "util.h"
#include "romfs.h"

struct romfs_super {
	__u8 magic[8];
	__u32 size;
	__u32 checksum;
	__u8 name[0];
} __attribute__((__packed__));

int volume_id_probe_romfs(struct volume_id *id, __u64 off)
{
	struct romfs_super *rfs;

	dbg("probing at offset %llu", off);

	rfs = (struct romfs_super *) volume_id_get_buffer(id, off, 0x200);
	if (rfs == NULL)
		return -1;

	if (memcmp(rfs->magic, "-rom1fs-", 4) == 0) {
		size_t len = strlen(rfs->name);

		if (len) {
			volume_id_set_label_raw(id, rfs->name, len);
			volume_id_set_label_string(id, rfs->name, len);
		}

		volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
		id->type = "romfs";
		return 0;
	}

	return -1;
}

--- NEW FILE: romfs.h ---
/*
 * volume_id - reads filesystem label and uuid
 *
 * Copyright (C) 2004 Kay Sievers <kay.sievers at vrfy.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
 */

#ifndef _VOLUME_ID_ROMFS_
#define _VOLUME_ID_ROMFS_

extern int volume_id_probe_romfs(struct volume_id *id, __u64 off);

#endif

--- NEW FILE: sysv.c ---
/*
 * volume_id - reads filesystem label and uuid
 *
 * Copyright (C) 2005 Kay Sievers <kay.sievers at vrfy.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
 */

#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <asm/types.h>

#include "volume_id.h"
#include "logging.h"
#include "util.h"
#include "sysv.h"

#define SYSV_NICINOD			100
#define SYSV_NICFREE			50

struct sysv_super
{
	__u16	s_isize;
	__u16	s_pad0;
	__u32	s_fsize;
	__u16	s_nfree;
	__u16	s_pad1;
	__u32	s_free[SYSV_NICFREE];
	__u16	s_ninode;
	__u16	s_pad2;
	__u16	s_inode[SYSV_NICINOD];
	__u8	s_flock;
	__u8	s_ilock;
	__u8	s_fmod;
	__u8	s_ronly;
	__u32	s_time;
	__u16	s_dinfo[4];
	__u32	s_tfree;
	__u16	s_tinode;
	__u16	s_pad3;
	__u8	s_fname[6];
	__u8	s_fpack[6];
	__u32	s_fill[12];
	__u32	s_state;
	__u32	s_magic;
	__u32	s_type;
} __attribute__((__packed__));

#define XENIX_NICINOD				100
#define XENIX_NICFREE				100

struct xenix_super {
	__u16	s_isize;
	__u32	s_fsize;
	__u16	s_nfree;
	__u32	s_free[XENIX_NICFREE];
	__u16	s_ninode;
	__u16	s_inode[XENIX_NICINOD];
	__u8	s_flock;
	__u8	s_ilock;
	__u8	s_fmod;
	__u8	s_ronly;
	__u32	s_time;
	__u32	s_tfree;
	__u16	s_tinode;
	__u16	s_dinfo[4];
	__u8	s_fname[6];
	__u8	s_fpack[6];
	__u8	s_clean;
	__u8	s_fill[371];
	__u32	s_magic;
	__u32	s_type;
} __attribute__((__packed__));

#define SYSV_SUPERBLOCK_BLOCK			0x01
#define SYSV_MAGIC				0xfd187e20
#define XENIX_SUPERBLOCK_BLOCK			0x18
#define XENIX_MAGIC				0x2b5544
#define SYSV_MAX_BLOCKSIZE			0x800

int volume_id_probe_sysv(struct volume_id *id, __u64 off)
{
	struct sysv_super *vs;
	struct xenix_super *xs;
	unsigned int boff;

	dbg("probing at offset %llu", off);

	for (boff = 0x200; boff <= SYSV_MAX_BLOCKSIZE; boff <<= 1) {
		vs = (struct sysv_super *)
			volume_id_get_buffer(id, off + (boff * SYSV_SUPERBLOCK_BLOCK), 0x200);
		if (vs == NULL)
			return -1;

		if (vs->s_magic == cpu_to_le32(SYSV_MAGIC) || vs->s_magic == cpu_to_be32(SYSV_MAGIC)) {
			volume_id_set_label_raw(id, vs->s_fname, 6);
			volume_id_set_label_string(id, vs->s_fname, 6);
			id->type = "sysv";
			goto found;
		}
	}

	for (boff = 0x200; boff <= SYSV_MAX_BLOCKSIZE; boff <<= 1) {
		xs = (struct xenix_super *)
			volume_id_get_buffer(id, off + (boff + XENIX_SUPERBLOCK_BLOCK), 0x200);
		if (xs == NULL)
			return -1;

		if (xs->s_magic == cpu_to_le32(XENIX_MAGIC) || xs->s_magic == cpu_to_be32(XENIX_MAGIC)) {
			volume_id_set_label_raw(id, xs->s_fname, 6);
			volume_id_set_label_string(id, xs->s_fname, 6);
			id->type = "xenix";
			goto found;
		}
	}

	return -1;

found:
	volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
	return 0;
}

--- NEW FILE: sysv.h ---
/*
 * volume_id - reads filesystem label and uuid
 *
 * Copyright (C) 2005 Kay Sievers <kay.sievers at vrfy.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
 */

#ifndef _VOLUME_ID_SYSV_
#define _VOLUME_ID_SYSV_

extern int volume_id_probe_sysv(struct volume_id *id, __u64 off);

#endif

Index: udf.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/udf.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- udf.c	7 Feb 2005 21:24:16 -0000	1.1
+++ udf.c	16 Feb 2005 22:40:47 -0000	1.2
@@ -39,43 +39,45 @@
 #include "util.h"
 #include "udf.h"
 
+struct volume_descriptor {
+	struct descriptor_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;
+		} __attribute__((__packed__)) anchor;
+		struct primary_descriptor {
+			__u32	seq_num;
+			__u32	desc_num;
+			struct dstring {
+				__u8	clen;
+				__u8	c[31];
+			} __attribute__((__packed__)) ident;
+		} __attribute__((__packed__)) primary;
+	} __attribute__((__packed__)) type;
+} __attribute__((__packed__));
+
+struct volume_structure_descriptor {
+	__u8	type;
+	__u8	id[5];
+	__u8	version;
+} __attribute__((__packed__));
+
 #define UDF_VSD_OFFSET			0x8000
 
 int volume_id_probe_udf(struct volume_id *id, __u64 off)
 {
-	struct volume_descriptor {
-		struct descriptor_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;
-			} __attribute__((__packed__)) anchor;
-			struct primary_descriptor {
-				__u32	seq_num;
-				__u32	desc_num;
-				struct dstring {
-					__u8	clen;
-					__u8	c[31];
-				} __attribute__((__packed__)) ident;
-			} __attribute__((__packed__)) primary;
-		} __attribute__((__packed__)) type;
-	} __attribute__((__packed__)) *vd;
-
-	struct volume_structure_descriptor {
-		__u8	type;
-		__u8	id[5];
-		__u8	version;
-	} *vsd;
-
+	struct volume_descriptor *vd;
+	struct volume_structure_descriptor *vsd;
 	unsigned int bs;
 	unsigned int b;
 	unsigned int type;
@@ -83,23 +85,25 @@
 	unsigned int loc;
 	unsigned int clen;
 
+	dbg("probing at offset %llu", off);
+
 	vsd = (struct volume_structure_descriptor *) volume_id_get_buffer(id, off + UDF_VSD_OFFSET, 0x200);
 	if (vsd == NULL)
 		return -1;
 
-	if (strncmp(vsd->id, "NSR02", 5) == 0)
+	if (memcmp(vsd->id, "NSR02", 5) == 0)
 		goto blocksize;
-	if (strncmp(vsd->id, "NSR03", 5) == 0)
+	if (memcmp(vsd->id, "NSR03", 5) == 0)
 		goto blocksize;
-	if (strncmp(vsd->id, "BEA01", 5) == 0)
+	if (memcmp(vsd->id, "BEA01", 5) == 0)
 		goto blocksize;
-	if (strncmp(vsd->id, "BOOT2", 5) == 0)
+	if (memcmp(vsd->id, "BOOT2", 5) == 0)
 		goto blocksize;
-	if (strncmp(vsd->id, "CD001", 5) == 0)
+	if (memcmp(vsd->id, "CD001", 5) == 0)
 		goto blocksize;
-	if (strncmp(vsd->id, "CDW02", 5) == 0)
+	if (memcmp(vsd->id, "CDW02", 5) == 0)
 		goto blocksize;
-	if (strncmp(vsd->id, "TEA03", 5) == 0)
+	if (memcmp(vsd->id, "TEA03", 5) == 0)
 		goto blocksize;
 	return -1;
 
@@ -127,9 +131,9 @@
 
 		if (vsd->id[0] == '\0')
 			return -1;
-		if (strncmp(vsd->id, "NSR02", 5) == 0)
+		if (memcmp(vsd->id, "NSR02", 5) == 0)
 			goto anchor;
-		if (strncmp(vsd->id, "NSR03", 5) == 0)
+		if (memcmp(vsd->id, "NSR03", 5) == 0)
 			goto anchor;
 	}
 	return -1;

Index: ufs.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/ufs.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- ufs.c	7 Feb 2005 21:24:16 -0000	1.1
+++ ufs.c	16 Feb 2005 22:40:47 -0000	1.2
@@ -39,6 +39,143 @@
 #include "util.h"
 #include "ufs.h"
 
+struct ufs_super_block {
+	__u32	fs_link;
+	__u32	fs_rlink;
+	__u32	fs_sblkno;
+	__u32	fs_cblkno;
+	__u32	fs_iblkno;
+	__u32	fs_dblkno;
+	__u32	fs_cgoffset;
+	__u32	fs_cgmask;
+	__u32	fs_time;
+	__u32	fs_size;
+	__u32	fs_dsize;
+	__u32	fs_ncg;	
+	__u32	fs_bsize;
+	__u32	fs_fsize;
+	__u32	fs_frag;
+	__u32	fs_minfree;
+	__u32	fs_rotdelay;
+	__u32	fs_rps;	
+	__u32	fs_bmask;
+	__u32	fs_fmask;
+	__u32	fs_bshift;
+	__u32	fs_fshift;
+	__u32	fs_maxcontig;
+	__u32	fs_maxbpg;
+	__u32	fs_fragshift;
+	__u32	fs_fsbtodb;
+	__u32	fs_sbsize;
+	__u32	fs_csmask;
+	__u32	fs_csshift;
+	__u32	fs_nindir;
+	__u32	fs_inopb;
+	__u32	fs_nspf;
+	__u32	fs_optim;
+	__u32	fs_npsect_state;
+	__u32	fs_interleave;
+	__u32	fs_trackskew;
+	__u32	fs_id[2];
+	__u32	fs_csaddr;
+	__u32	fs_cssize;
+	__u32	fs_cgsize;
+	__u32	fs_ntrak;
+	__u32	fs_nsect;
+	__u32	fs_spc;	
+	__u32	fs_ncyl;
+	__u32	fs_cpg;
+	__u32	fs_ipg;
+	__u32	fs_fpg;
+	struct ufs_csum {
+		__u32	cs_ndir;
+		__u32	cs_nbfree;
+		__u32	cs_nifree;
+		__u32	cs_nffree;
+	} __attribute__((__packed__)) fs_cstotal;
+	__s8	fs_fmod;
+	__s8	fs_clean;
+	__s8	fs_ronly;
+	__s8	fs_flags;
+	union {
+		struct {
+			__s8	fs_fsmnt[512];
+			__u32	fs_cgrotor;
+			__u32	fs_csp[31];
+			__u32	fs_maxcluster;
+			__u32	fs_cpc;
+			__u16	fs_opostbl[16][8];
+		} __attribute__((__packed__)) fs_u1;
+		struct {
+			__s8	fs_fsmnt[468];
+			__u8	fs_volname[32];
+			__u64	fs_swuid;
+			__s32	fs_pad;
+			__u32	fs_cgrotor;
+			__u32	fs_ocsp[28];
+			__u32	fs_contigdirs;
+			__u32	fs_csp;	
+			__u32	fs_maxcluster;
+			__u32	fs_active;
+			__s32	fs_old_cpc;
+			__s32	fs_maxbsize;
+			__s64	fs_sparecon64[17];
+			__s64	fs_sblockloc;
+			struct ufs2_csum_total {
+				__u64	cs_ndir;
+				__u64	cs_nbfree;
+				__u64	cs_nifree;
+				__u64	cs_nffree;
+				__u64	cs_numclusters;
+				__u64	cs_spare[3];
+			} __attribute__((__packed__)) fs_cstotal;
+			struct ufs_timeval {
+				__s32	tv_sec;
+				__s32	tv_usec;
+			} __attribute__((__packed__)) fs_time;
+			__s64	fs_size;
+			__s64	fs_dsize;
+			__u64	fs_csaddr;
+			__s64	fs_pendingblocks;
+			__s32	fs_pendinginodes;
+		} __attribute__((__packed__)) fs_u2;
+	}  fs_u11;
+	union {
+		struct {
+			__s32	fs_sparecon[53];
+			__s32	fs_reclaim;
+			__s32	fs_sparecon2[1];
+			__s32	fs_state;
+			__u32	fs_qbmask[2];
+			__u32	fs_qfmask[2];
+		} __attribute__((__packed__)) fs_sun;
+		struct {
+			__s32	fs_sparecon[53];
+			__s32	fs_reclaim;
+			__s32	fs_sparecon2[1];
+			__u32	fs_npsect;
+			__u32	fs_qbmask[2];
+			__u32	fs_qfmask[2];
+		} __attribute__((__packed__)) fs_sunx86;
+		struct {
+			__s32	fs_sparecon[50];
+			__s32	fs_contigsumsize;
+			__s32	fs_maxsymlinklen;
+			__s32	fs_inodefmt;
+			__u32	fs_maxfilesize[2];
+			__u32	fs_qbmask[2];
+			__u32	fs_qfmask[2];
+			__s32	fs_state;
+		} __attribute__((__packed__)) fs_44;
+	} fs_u2;
+	__s32	fs_postblformat;
+	__s32	fs_nrpos;
+	__s32	fs_postbloff;
+	__s32	fs_rotbloff;
+	__u32	fs_magic;
+	__u8	fs_space[1];
+} __attribute__((__packed__));
+
 #define UFS_MAGIC			0x00011954
 #define UFS2_MAGIC			0x19540119
 #define UFS_MAGIC_FEA			0x00195612
@@ -46,147 +183,13 @@
 
 int volume_id_probe_ufs(struct volume_id *id, __u64 off)
 {
-	struct ufs_super_block {
-		__u32	fs_link;
-		__u32	fs_rlink;
-		__u32	fs_sblkno;
-		__u32	fs_cblkno;
-		__u32	fs_iblkno;
-		__u32	fs_dblkno;
-		__u32	fs_cgoffset;
-		__u32	fs_cgmask;
-		__u32	fs_time;
-		__u32	fs_size;
-		__u32	fs_dsize;
-		__u32	fs_ncg;	
-		__u32	fs_bsize;
-		__u32	fs_fsize;
-		__u32	fs_frag;
-		__u32	fs_minfree;
-		__u32	fs_rotdelay;
-		__u32	fs_rps;	
-		__u32	fs_bmask;
-		__u32	fs_fmask;
-		__u32	fs_bshift;
-		__u32	fs_fshift;
-		__u32	fs_maxcontig;
-		__u32	fs_maxbpg;
-		__u32	fs_fragshift;
-		__u32	fs_fsbtodb;
-		__u32	fs_sbsize;
-		__u32	fs_csmask;
-		__u32	fs_csshift;
-		__u32	fs_nindir;
-		__u32	fs_inopb;
-		__u32	fs_nspf;
-		__u32	fs_optim;
-		__u32	fs_npsect_state;
-		__u32	fs_interleave;
-		__u32	fs_trackskew;
-		__u32	fs_id[2];
-		__u32	fs_csaddr;
-		__u32	fs_cssize;
-		__u32	fs_cgsize;
-		__u32	fs_ntrak;
-		__u32	fs_nsect;
-		__u32	fs_spc;	
-		__u32	fs_ncyl;
-		__u32	fs_cpg;
-		__u32	fs_ipg;
-		__u32	fs_fpg;
-		struct ufs_csum {
-			__u32	cs_ndir;
-			__u32	cs_nbfree;
-			__u32	cs_nifree;
-			__u32	cs_nffree;
-		} __attribute__((__packed__)) fs_cstotal;
-		__s8	fs_fmod;
-		__s8	fs_clean;
-		__s8	fs_ronly;
-		__s8	fs_flags;
-		union {
-			struct {
-				__s8	fs_fsmnt[512];
-				__u32	fs_cgrotor;
-				__u32	fs_csp[31];
-				__u32	fs_maxcluster;
-				__u32	fs_cpc;
-				__u16	fs_opostbl[16][8];
-			} __attribute__((__packed__)) fs_u1;
-			struct {
-				__s8  fs_fsmnt[468];
-				__u8   fs_volname[32];
-				__u64  fs_swuid;
-				__s32  fs_pad;
-				__u32   fs_cgrotor;
-				__u32   fs_ocsp[28];
-				__u32   fs_contigdirs;
-				__u32   fs_csp;	
-				__u32   fs_maxcluster;
-				__u32   fs_active;
-				__s32   fs_old_cpc;
-				__s32   fs_maxbsize;
-				__s64   fs_sparecon64[17];
-				__s64   fs_sblockloc;
-				struct  ufs2_csum_total {
-					__u64	cs_ndir;
-					__u64	cs_nbfree;
-					__u64	cs_nifree;
-					__u64	cs_nffree;
-					__u64	cs_numclusters;
-					__u64	cs_spare[3];
-				} __attribute__((__packed__)) fs_cstotal;
-				struct  ufs_timeval {
-					__s32	tv_sec;
-					__s32	tv_usec;
-				} __attribute__((__packed__)) fs_time;
-				__s64    fs_size;
-				__s64    fs_dsize;
-				__u64    fs_csaddr;
-				__s64    fs_pendingblocks;
-				__s32    fs_pendinginodes;
-			} __attribute__((__packed__)) fs_u2;
-		}  fs_u11;
-		union {
-			struct {
-				__s32	fs_sparecon[53];
-				__s32	fs_reclaim;
-				__s32	fs_sparecon2[1];
-				__s32	fs_state;
-				__u32	fs_qbmask[2];
-				__u32	fs_qfmask[2];
-			} __attribute__((__packed__)) fs_sun;
-			struct {
-				__s32	fs_sparecon[53];
-				__s32	fs_reclaim;
-				__s32	fs_sparecon2[1];
-				__u32	fs_npsect;
-				__u32	fs_qbmask[2];
-				__u32	fs_qfmask[2];
-			} __attribute__((__packed__)) fs_sunx86;
-			struct {
-				__s32	fs_sparecon[50];
-				__s32	fs_contigsumsize;
-				__s32	fs_maxsymlinklen;
-				__s32	fs_inodefmt;
-				__u32	fs_maxfilesize[2];
-				__u32	fs_qbmask[2];
-				__u32	fs_qfmask[2];
-				__s32	fs_state;
-			} __attribute__((__packed__)) fs_44;
-		} fs_u2;
-		__s32	fs_postblformat;
-		__s32	fs_nrpos;
-		__s32	fs_postbloff;
-		__s32	fs_rotbloff;
-		__u32	fs_magic;
-		__u8	fs_space[1];
-	} __attribute__((__packed__)) *ufs;
-
 	__u32	magic;
 	int 	i;
+	struct ufs_super_block *ufs;
 	int	offsets[] = {0, 8, 64, 256, -1};
 
+	dbg("probing at offset %llu", off);
+
 	for (i = 0; offsets[i] >= 0; i++) {	
 		ufs = (struct ufs_super_block *) volume_id_get_buffer(id, off + (offsets[i] * 0x400), 0x800);
 		if (ufs == NULL)

Index: util.h
===================================================================
RCS file: /cvs/hal/hal/volume_id/util.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- util.h	7 Feb 2005 21:24:16 -0000	1.1
+++ util.h	16 Feb 2005 22:40:47 -0000	1.2
@@ -58,12 +58,16 @@
 #define le64_to_cpu(x) (x)
 #define be16_to_cpu(x) bswap16(x)
 #define be32_to_cpu(x) bswap32(x)
+#define cpu_to_le32(x) (x)
+#define cpu_to_be32(x) bswap32(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)
 #define be16_to_cpu(x) (x)
 #define be32_to_cpu(x) (x)
+#define cpu_to_le32(x) bswap32(x)
+#define cpu_to_be32(x) (x)
 #endif
 
 enum uuid_format {

Index: volume_id.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/volume_id.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- volume_id.c	16 Feb 2005 20:16:55 -0000	1.2
+++ volume_id.c	16 Feb 2005 22:40:47 -0000	1.3
@@ -51,10 +51,15 @@
 #include "ntfs.h"
 #include "iso9660.h"
 #include "udf.h"
+#include "luks.h"
 #include "highpoint.h"
 #include "linux_swap.h"
 #include "linux_raid.h"
 #include "lvm.h"
+#include "cramfs.h"
+#include "hpfs.h"
+#include "romfs.h"
+#include "sysv.h"
 #include "mac.h"
 #include "msdos.h"
 
@@ -76,7 +81,6 @@
 	if (volume_id_probe_highpoint_ataraid(id, off) == 0)
 		goto exit;
 
-	/* LUKS encrypted volume */
 	if (volume_id_probe_luks(id, off) == 0)
 		goto exit;
 
@@ -120,6 +124,18 @@
 	if (volume_id_probe_ntfs(id, off)  == 0)
 		goto exit;
 
+	if (volume_id_probe_cramfs(id, off) == 0)
+		goto exit;
+
+	if (volume_id_probe_romfs(id, off) == 0)
+		goto exit;
+
+	if (volume_id_probe_hpfs(id, off) == 0)
+		goto exit;
+
+	if (volume_id_probe_sysv(id, off) == 0)
+		goto exit;
+
 	return -1;
 
 exit:

Index: volume_id.h
===================================================================
RCS file: /cvs/hal/hal/volume_id/volume_id.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- volume_id.h	16 Feb 2005 22:25:20 -0000	1.3
+++ volume_id.h	16 Feb 2005 22:40:47 -0000	1.4
@@ -21,7 +21,7 @@
 #ifndef _VOLUME_ID_H_
 #define _VOLUME_ID_H_
 
-#define VOLUME_ID_VERSION		31
+#define VOLUME_ID_VERSION		34
 
 #define VOLUME_ID_LABEL_SIZE		64
 #define VOLUME_ID_UUID_SIZE		16

Index: xfs.c
===================================================================
RCS file: /cvs/hal/hal/volume_id/xfs.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- xfs.c	7 Feb 2005 21:24:16 -0000	1.1
+++ xfs.c	16 Feb 2005 22:40:47 -0000	1.2
@@ -39,28 +39,32 @@
 #include "util.h"
 #include "xfs.h"
 
+struct xfs_super_block {
+	__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__));
+
 int volume_id_probe_xfs(struct volume_id *id, __u64 off)
 {
-	struct xfs_super_block {
-		__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;
+	struct xfs_super_block *xs;
+
+	dbg("probing at offset %llu", off);
 
 	xs = (struct xfs_super_block *) volume_id_get_buffer(id, off, 0x200);
 	if (xs == NULL)
 		return -1;
 
-	if (strncmp(xs->magic, "XFSB", 4) != 0)
+	if (memcmp(xs->magic, "XFSB", 4) != 0)
 		return -1;
 
 	volume_id_set_label_raw(id, xs->fname, 12);




More information about the hal-commit mailing list