]> err.no Git - systemd/commitdiff
[PATCH] udev_volume_id: volume_id version 034
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>
Wed, 9 Feb 2005 00:02:18 +0000 (01:02 +0100)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 06:26:14 +0000 (23:26 -0700)
29 files changed:
extras/volume_id/Makefile
extras/volume_id/volume_id/Makefile.inc [new file with mode: 0644]
extras/volume_id/volume_id/cramfs/cramfs.c
extras/volume_id/volume_id/dasd/dasd.c
extras/volume_id/volume_id/ext/ext.c
extras/volume_id/volume_id/fat/fat.c
extras/volume_id/volume_id/hfs/hfs.c
extras/volume_id/volume_id/highpoint/highpoint.c
extras/volume_id/volume_id/hpfs/hpfs.c [new file with mode: 0644]
extras/volume_id/volume_id/hpfs/hpfs.h [new file with mode: 0644]
extras/volume_id/volume_id/iso9660/iso9660.c
extras/volume_id/volume_id/jfs/jfs.c
extras/volume_id/volume_id/linux_raid/linux_raid.c
extras/volume_id/volume_id/linux_swap/linux_swap.c
extras/volume_id/volume_id/lvm/lvm.c
extras/volume_id/volume_id/mac/mac.c
extras/volume_id/volume_id/msdos/msdos.c
extras/volume_id/volume_id/ntfs/ntfs.c
extras/volume_id/volume_id/reiserfs/reiserfs.c
extras/volume_id/volume_id/romfs/romfs.c [new file with mode: 0644]
extras/volume_id/volume_id/romfs/romfs.h [new file with mode: 0644]
extras/volume_id/volume_id/sysv/sysv.c [new file with mode: 0644]
extras/volume_id/volume_id/sysv/sysv.h [new file with mode: 0644]
extras/volume_id/volume_id/udf/udf.c
extras/volume_id/volume_id/ufs/ufs.c
extras/volume_id/volume_id/util.h
extras/volume_id/volume_id/volume_id.c
extras/volume_id/volume_id/volume_id.h
extras/volume_id/volume_id/xfs/xfs.c

index bfe4cf74af52f47da5027ef4eead30da331f44cc..9c274212a653a4d757a8071fbc54881114097595 100644 (file)
@@ -30,49 +30,8 @@ INSTALL_SCRIPT = ${INSTALL_PROGRAM}
 
 override CFLAGS+=-D_FILE_OFFSET_BITS=64
 
-VOLUME_ID_OBJS=                                        \
-       volume_id/ext/ext.o                     \
-       volume_id/fat/fat.o                     \
-       volume_id/hfs/hfs.o                     \
-       volume_id/highpoint/highpoint.o         \
-       volume_id/iso9660/iso9660.o             \
-       volume_id/jfs/jfs.o                     \
-       volume_id/linux_raid/linux_raid.o       \
-       volume_id/linux_swap/linux_swap.o       \
-       volume_id/lvm/lvm.o                     \
-       volume_id/mac/mac.o                     \
-       volume_id/msdos/msdos.o                 \
-       volume_id/ntfs/ntfs.o                   \
-       volume_id/reiserfs/reiserfs.o           \
-       volume_id/udf/udf.o                     \
-       volume_id/ufs/ufs.o                     \
-       volume_id/xfs/xfs.o                     \
-       volume_id/cramfs/cramfs.o               \
-       volume_id/dasd/dasd.o                   \
-       volume_id/volume_id.o                   \
-       volume_id/util.o
-
-VOLUME_ID_HEADERS=                             \
-       volume_id/ext/ext.h                     \
-       volume_id/fat/fat.h                     \
-       volume_id/hfs/hfs.h                     \
-       volume_id/highpoint/highpoint.h         \
-       volume_id/iso9660/iso9660.h             \
-       volume_id/jfs/jfs.h                     \
-       volume_id/linux_raid/linux_raid.h       \
-       volume_id/linux_swap/linux_swap.h       \
-       volume_id/lvm/lvm.h                     \
-       volume_id/mac/mac.h                     \
-       volume_id/msdos/msdos.h                 \
-       volume_id/ntfs/ntfs.h                   \
-       volume_id/reiserfs/reiserfs.h           \
-       volume_id/udf/udf.h                     \
-       volume_id/ufs/ufs.h                     \
-       volume_id/xfs/xfs.h                     \
-       volume_id/cramfs/cramfs.h               \
-       volume_id/dasd/dasd.h                   \
-       volume_id/volume_id.h                   \
-       volume_id/util.h
+VOLUME_ID_BASE=volume_id
+include $(VOLUME_ID_BASE)/Makefile.inc
 
 OBJS = udev_volume_id.o $(VOLUME_ID_OBJS) $(SYSFS)
 HEADERS = $(VOLUME_ID_HEADERS)
diff --git a/extras/volume_id/volume_id/Makefile.inc b/extras/volume_id/volume_id/Makefile.inc
new file mode 100644 (file)
index 0000000..d010f77
--- /dev/null
@@ -0,0 +1,48 @@
+VOLUME_ID_OBJS=                                                \
+       $(VOLUME_ID_BASE)/ext/ext.o                     \
+       $(VOLUME_ID_BASE)/fat/fat.o                     \
+       $(VOLUME_ID_BASE)/hfs/hfs.o                     \
+       $(VOLUME_ID_BASE)/highpoint/highpoint.o         \
+       $(VOLUME_ID_BASE)/iso9660/iso9660.o             \
+       $(VOLUME_ID_BASE)/jfs/jfs.o                     \
+       $(VOLUME_ID_BASE)/linux_raid/linux_raid.o       \
+       $(VOLUME_ID_BASE)/linux_swap/linux_swap.o       \
+       $(VOLUME_ID_BASE)/lvm/lvm.o                     \
+       $(VOLUME_ID_BASE)/mac/mac.o                     \
+       $(VOLUME_ID_BASE)/msdos/msdos.o                 \
+       $(VOLUME_ID_BASE)/ntfs/ntfs.o                   \
+       $(VOLUME_ID_BASE)/reiserfs/reiserfs.o           \
+       $(VOLUME_ID_BASE)/udf/udf.o                     \
+       $(VOLUME_ID_BASE)/ufs/ufs.o                     \
+       $(VOLUME_ID_BASE)/xfs/xfs.o                     \
+       $(VOLUME_ID_BASE)/cramfs/cramfs.o               \
+       $(VOLUME_ID_BASE)/hpfs/hpfs.o                   \
+       $(VOLUME_ID_BASE)/romfs/romfs.o                 \
+       $(VOLUME_ID_BASE)/sysv/sysv.o                   \
+       $(VOLUME_ID_BASE)/dasd/dasd.o                   \
+       $(VOLUME_ID_BASE)/volume_id.o                   \
+       $(VOLUME_ID_BASE)/util.o
+
+VOLUME_ID_HEADERS=                                     \
+       $(VOLUME_ID_BASE)/ext/ext.h                     \
+       $(VOLUME_ID_BASE)/fat/fat.h                     \
+       $(VOLUME_ID_BASE)/hfs/hfs.h                     \
+       $(VOLUME_ID_BASE)/highpoint/highpoint.h         \
+       $(VOLUME_ID_BASE)/iso9660/iso9660.h             \
+       $(VOLUME_ID_BASE)/jfs/jfs.h                     \
+       $(VOLUME_ID_BASE)/linux_raid/linux_raid.h       \
+       $(VOLUME_ID_BASE)/linux_swap/linux_swap.h       \
+       $(VOLUME_ID_BASE)/lvm/lvm.h                     \
+       $(VOLUME_ID_BASE)/mac/mac.h                     \
+       $(VOLUME_ID_BASE)/msdos/msdos.h                 \
+       $(VOLUME_ID_BASE)/ntfs/ntfs.h                   \
+       $(VOLUME_ID_BASE)/reiserfs/reiserfs.h           \
+       $(VOLUME_ID_BASE)/udf/udf.h                     \
+       $(VOLUME_ID_BASE)/ufs/ufs.h                     \
+       $(VOLUME_ID_BASE)/xfs/xfs.h                     \
+       $(VOLUME_ID_BASE)/cramfs/cramfs.h               \
+       $(VOLUME_ID_BASE)/sysv/sysv.h                   \
+       $(VOLUME_ID_BASE)/romfs/romfs.h                 \
+       $(VOLUME_ID_BASE)/dasd/dasd.h                   \
+       $(VOLUME_ID_BASE)/volume_id.h                   \
+       $(VOLUME_ID_BASE)/util.h
index 69ab2c7a444003e0be1876b2003d5694260350f3..a1d51f107d2bea7b6e6715e2dc45b06980f078c3 100644 (file)
@@ -58,6 +58,8 @@ 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;
index 5623f69d365cd2d1853a67c56f7640466840bdf9..4548190ce2eb5141f3e1b6c3df2d38a060d69872 100644 (file)
@@ -35,6 +35,7 @@
 #include <asm/types.h>
 
 #include "../volume_id.h"
+#include "../logging.h"
 #include "../util.h"
 #include "dasd.h"
 
@@ -141,7 +142,7 @@ typedef struct dasd_information_t {
        unsigned int confdata_size;
        char characteristics[64];       /* from read_device_characteristics */
        char configuration_data[256];   /* from read_configuration_data */
-} dasd_information_t;
+} __attribute__((__packed__)) dasd_information_t;
 
 #define _IOC_NRBITS            8
 #define _IOC_TYPEBITS          8
@@ -168,6 +169,8 @@ int volume_id_probe_dasd_partition(struct volume_id *id)
        __u8 *label_raw;
        unsigned char name[7];
 
+       dbg("probing");
+
        if (ioctl(id->fd, BIODASDINFO, &info) != 0)
                return -1;
 
index 50ffa8537288a2020819fbecd02fc488ea0fa5fd..0940e452fc6e656305e1fc98a9d6c058a34cf773 100644 (file)
 #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 219207e81dc491a0a3cbc636405e124d76cb134f..c6bb491f70c8d45327f5776200c68a68b3940f8d 100644 (file)
@@ -159,6 +159,8 @@ int volume_id_probe_vfat(struct volume_id *id, __u64 off)
        __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;
index a4ae86b56a0c1b66d27731bd8d4f857b2ba5ba64..905471cb357a2afae80bfdc1975121337e19a1e2 100644 (file)
 #include "../util.h"
 #include "hfs.h"
 
+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 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_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__));
+
+#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_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
-#define HFSPLUS_EXTENT_COUNT           8
 
 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 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_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_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;
-
        unsigned int blocksize;
        unsigned int cat_block;
        unsigned int ext_block_start;
@@ -173,6 +173,8 @@ int volume_id_probe_hfs_hfsplus(struct volume_id *id, __u64 off)
        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;
index 3236d6b2fd9b4be6fb9d6c924282f5002754cb93..b3014500869b5f496f731db32692ccbdcfec9899 100644 (file)
 #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;
diff --git a/extras/volume_id/volume_id/hpfs/hpfs.c b/extras/volume_id/volume_id/hpfs/hpfs.c
new file mode 100644 (file)
index 0000000..212e74e
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * volume_id - reads filesystem label and uuid
+ *
+ * Copyright (C) 2005 Kay Sievers <kay.sievers@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;
+}
diff --git a/extras/volume_id/volume_id/hpfs/hpfs.h b/extras/volume_id/volume_id/hpfs/hpfs.h
new file mode 100644 (file)
index 0000000..bd8d4c9
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * volume_id - reads filesystem label and uuid
+ *
+ * Copyright (C) 2005 Kay Sievers <kay.sievers@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 fa769d3ca385c5f5355c4db769d53bf9adf19c52..1d7cfd50371d3ed0714af8232cd6d5087f230f81 100644 (file)
 #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)
index c9dce84ecb80c6ab19c48889dc721261783316c9..ab0b83081c4259f8b8169dc352e1460c82b432b8 100644 (file)
 #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)
index b55c6ca6e84fc1e408c816f31e23155a1569fe99..ca03030ee4803c253d1bfc77f9c3c9d98856d1cc 100644 (file)
 #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 d34b22c590c993813d2d24d0cf1df8b75a7ecd4b..2fb16377a82f886216959781c8688ef25084b955 100644 (file)
 #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);
index e736f4ed4a2b75519efd522a2191e74748c2752b..ed1a83aeb4c9b517244006ba1898d872e4b3765a 100644 (file)
 #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 (memcmp(lvm->id, LVM1_MAGIC, 2) != 0)
                return -1;
@@ -70,16 +81,11 @@ int volume_id_probe_lvm1(struct volume_id *id, __u64 off)
 
 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)
index 5872b722b45d7e127a1858d52a5250caf0e36370..895316d26c64408e24494c615651785084775783 100644 (file)
 #include "../util.h"
 #include "mac.h"
 
+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__));
+
 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_partition {
-               __u8    signature[2];
-               __u16   res1;
-               __u32   map_count;
-               __u32   start_block;
-               __u32   block_count;
-               __u8    name[32];
-               __u8    type[32];
-       } __attribute__((__packed__)) *part;
-
        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)
index 08124fad2da5b91125c2e4b403e0fc96bef70b73..a90b9efc333010a79a371d77eb726cf8ab9b366f 100644 (file)
 #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
 
 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,8 +78,11 @@ int volume_id_probe_msdos_part_table(struct volume_id *id, __u64 off)
        __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;
index bf87f9d8d003b64c379e6e899118bab25e690100..e46bc64bb267fe553f5f767dfde23b84db771c71 100644 (file)
 #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
 
 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,6 +118,8 @@ int volume_id_probe_ntfs(struct volume_id *id, __u64 off)
        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;
index 5653214e9d6fa3cbab5134f103cc3894dd2c59ca..d54013e4c556d54c875efd32dbb1c2a9f2401d60 100644 (file)
 #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)
diff --git a/extras/volume_id/volume_id/romfs/romfs.c b/extras/volume_id/volume_id/romfs/romfs.c
new file mode 100644 (file)
index 0000000..c04dc98
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * volume_id - reads filesystem label and uuid
+ *
+ * Copyright (C) 2004 Kay Sievers <kay.sievers@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;
+}
diff --git a/extras/volume_id/volume_id/romfs/romfs.h b/extras/volume_id/volume_id/romfs/romfs.h
new file mode 100644 (file)
index 0000000..b0108f3
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * volume_id - reads filesystem label and uuid
+ *
+ * Copyright (C) 2004 Kay Sievers <kay.sievers@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
diff --git a/extras/volume_id/volume_id/sysv/sysv.c b/extras/volume_id/volume_id/sysv/sysv.c
new file mode 100644 (file)
index 0000000..313ac17
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ * volume_id - reads filesystem label and uuid
+ *
+ * Copyright (C) 2005 Kay Sievers <kay.sievers@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;
+}
diff --git a/extras/volume_id/volume_id/sysv/sysv.h b/extras/volume_id/volume_id/sysv/sysv.h
new file mode 100644 (file)
index 0000000..bd5a350
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * volume_id - reads filesystem label and uuid
+ *
+ * Copyright (C) 2005 Kay Sievers <kay.sievers@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 ff23b310399b2a6cc010dc1d9b5ad9b8595dd4b1..79d25ad89027a5efe32103dfbc3f00de2399e2dd 100644 (file)
 #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,6 +85,8 @@ int volume_id_probe_udf(struct volume_id *id, __u64 off)
        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;
index bab1d4cfadc1e25710824696d7b64c6416a3248e..12672ffe01589d320a7dab344c265c4891570987 100644 (file)
 #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
 
 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 e5cd63e1aa5649ebfe3576306ee184ea60ef3e5e..22fd1b94e240e6e017915334fd1dda83d9476808 100644 (file)
 #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 78aae37ba0c39e084f7a01e17bb7b252e81414b4..95f7f5b12712f9753040ea6abcb139bf828c30ab 100644 (file)
@@ -56,6 +56,8 @@
 #include "linux_raid/linux_raid.h"
 #include "lvm/lvm.h"
 #include "cramfs/cramfs.h"
+#include "hpfs/hpfs.h"
+#include "romfs/romfs.h"
 #include "mac/mac.h"
 #include "msdos/msdos.h"
 
@@ -120,6 +122,12 @@ int volume_id_probe_all(struct volume_id *id, unsigned long long off, unsigned l
        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;
+
        return -1;
 
 exit:
index 5a4b136c32dae5355ee1d3a07798ea406777bf7b..5b845602c6f49b352fa08f98817d83c169beaf45 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef _VOLUME_ID_H_
 #define _VOLUME_ID_H_
 
-#define VOLUME_ID_VERSION              33
+#define VOLUME_ID_VERSION              34
 
 #define VOLUME_ID_LABEL_SIZE           64
 #define VOLUME_ID_UUID_SIZE            16
index 67ae2f07d5cedac87a7a585eb9cf58b7eec7f95a..efbe06ec58f8814fe7468cd201b69e0f9f16a464 100644 (file)
 #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)