diff options
author | Kay Sievers <kay.sievers@vrfy.org> | 2005-03-10 23:18:33 +0000 |
---|---|---|
committer | Kay Sievers <kay.sievers@vrfy.org> | 2005-03-10 23:18:33 +0000 |
commit | cda91c074085b843416e5edb539fc0fc3bfaf7a1 (patch) | |
tree | 5e2991a34fe01309d8ed26513e0954ba82508435 | |
parent | 10dbabe91eaf75a7f9433581e38674714d69ad17 (diff) | |
download | hal-cda91c074085b843416e5edb539fc0fc3bfaf7a1.tar.gz |
add minix probing code
New file.
New file.
Export unicode converter.
Export unicode converter.
Add minix.
Version 41.
-rw-r--r-- | ChangeLog | 19 | ||||
-rw-r--r-- | volume_id/Makefile.am | 1 | ||||
-rw-r--r-- | volume_id/cramfs.c | 2 | ||||
-rw-r--r-- | volume_id/ext.c | 2 | ||||
-rw-r--r-- | volume_id/fat.c | 6 | ||||
-rw-r--r-- | volume_id/hfs.c | 4 | ||||
-rw-r--r-- | volume_id/highpoint.c | 2 | ||||
-rw-r--r-- | volume_id/hpfs.c | 4 | ||||
-rw-r--r-- | volume_id/iso9660.c | 100 | ||||
-rw-r--r-- | volume_id/jfs.c | 2 | ||||
-rw-r--r-- | volume_id/linux_raid.c | 2 | ||||
-rw-r--r-- | volume_id/linux_swap.c | 2 | ||||
-rw-r--r-- | volume_id/luks.c | 35 | ||||
-rw-r--r-- | volume_id/lvm.c | 4 | ||||
-rw-r--r-- | volume_id/mac.c | 4 | ||||
-rw-r--r-- | volume_id/minix.c | 97 | ||||
-rw-r--r-- | volume_id/minix.h | 26 | ||||
-rw-r--r-- | volume_id/msdos.c | 10 | ||||
-rw-r--r-- | volume_id/ntfs.c | 6 | ||||
-rw-r--r-- | volume_id/reiserfs.c | 2 | ||||
-rw-r--r-- | volume_id/romfs.c | 2 | ||||
-rw-r--r-- | volume_id/sysv.c | 2 | ||||
-rw-r--r-- | volume_id/udf.c | 2 | ||||
-rw-r--r-- | volume_id/ufs.c | 2 | ||||
-rw-r--r-- | volume_id/util.c | 64 | ||||
-rw-r--r-- | volume_id/util.h | 1 | ||||
-rw-r--r-- | volume_id/volume_id.c | 4 | ||||
-rw-r--r-- | volume_id/volume_id.h | 2 | ||||
-rw-r--r-- | volume_id/xfs.c | 2 |
29 files changed, 294 insertions, 117 deletions
@@ -1,3 +1,22 @@ +2005-03-11 Kay Sievers <kay.sievers@vrfy.org> + + * volume_id/Makefile.am: add minix probing code + + * volume_id/luks.c: + + * volume_id/minix.c: New file. + + * volume_id/minix.h: New file. + + * volume_id/util.c: (volume_id_set_unicode16), + (volume_id_set_label_unicode16): Export unicode converter. + + * volume_id/util.h: Export unicode converter. + + * volume_id/volume_id.c: (volume_id_probe_all): Add minix. + + * volume_id/volume_id.h: Version 41. + 2005-03-10 David Zeuthen <davidz@redhat.com> * hald/linux2/acpi.c (battery_refresh_poll): Also set property diff --git a/volume_id/Makefile.am b/volume_id/Makefile.am index 424f9b92..59fb4c98 100644 --- a/volume_id/Makefile.am +++ b/volume_id/Makefile.am @@ -26,6 +26,7 @@ libvolume_id_la_SOURCES = \ romfs.h romfs.c \ sysv.h sysv.c \ cramfs.h cramfs.c \ + minix.h minix.c \ logging.h \ util.h util.c \ volume_id.h volume_id.c diff --git a/volume_id/cramfs.c b/volume_id/cramfs.c index a8058646..0c768600 100644 --- a/volume_id/cramfs.c +++ b/volume_id/cramfs.c @@ -58,7 +58,7 @@ int volume_id_probe_cramfs(struct volume_id *id, __u64 off) { struct cramfs_super *cs; - dbg("probing at offset %llu", off); + dbg("probing at offset 0x%llx", (unsigned long long) off); cs = (struct cramfs_super *) volume_id_get_buffer(id, off, 0x200); if (cs == NULL) diff --git a/volume_id/ext.c b/volume_id/ext.c index b7bdf05d..47836421 100644 --- a/volume_id/ext.c +++ b/volume_id/ext.c @@ -66,7 +66,7 @@ int volume_id_probe_ext(struct volume_id *id, __u64 off) { struct ext2_super_block *es; - dbg("probing at offset %llu", off); + dbg("probing at offset 0x%llx", (unsigned long long) off); es = (struct ext2_super_block *) volume_id_get_buffer(id, off + EXT_SUPERBLOCK_OFFSET, 0x200); if (es == NULL) diff --git a/volume_id/fat.c b/volume_id/fat.c index 58aa2aba..f6d36997 100644 --- a/volume_id/fat.c +++ b/volume_id/fat.c @@ -159,7 +159,7 @@ int volume_id_probe_vfat(struct volume_id *id, __u64 off) __u32 next; int maxloop; - dbg("probing at offset %llu", off); + dbg("probing at offset 0x%llx", (unsigned long long) off); vs = (struct vfat_super_block *) volume_id_get_buffer(id, off, 0x200); if (vs == NULL) @@ -257,7 +257,7 @@ valid: /* the label may be an attribute in the root directory */ root_start = (reserved + fat_size) * sector_size; - dbg("root dir start 0x%llx", root_start); + dbg("root dir start 0x%llx", (unsigned long long) root_start); root_dir_entries = le16_to_cpu(vs->dir_entries); dbg("expected entries 0x%x", root_dir_entries); @@ -302,7 +302,7 @@ fat32: dbg("next cluster %u", next); next_sect_off = (next - 2) * vs->sectors_per_cluster; next_off = (start_data_sect + next_sect_off) * sector_size; - dbg("cluster offset 0x%llx", next_off); + dbg("cluster offset 0x%llx", (unsigned long long) next_off); /* get cluster */ buf = volume_id_get_buffer(id, off + next_off, buf_size); diff --git a/volume_id/hfs.c b/volume_id/hfs.c index 327461c6..8c409750 100644 --- a/volume_id/hfs.c +++ b/volume_id/hfs.c @@ -173,7 +173,7 @@ 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); + dbg("probing at offset 0x%llx", (unsigned long long) off); buf = volume_id_get_buffer(id, off + HFS_SUPERBLOCK_OFFSET, 0x200); if (buf == NULL) @@ -196,7 +196,7 @@ int volume_id_probe_hfs_hfsplus(struct volume_id *id, __u64 off) off += (alloc_first_block * 512) + (embed_first_block * alloc_block_size); - dbg("hfs wrapped hfs+ found at offset 0x%llx", off); + dbg("hfs wrapped hfs+ found at offset 0x%llx", (unsigned long long) off); buf = volume_id_get_buffer(id, off + HFS_SUPERBLOCK_OFFSET, 0x200); if (buf == NULL) diff --git a/volume_id/highpoint.c b/volume_id/highpoint.c index e13fd6de..72f7d284 100644 --- a/volume_id/highpoint.c +++ b/volume_id/highpoint.c @@ -54,7 +54,7 @@ int volume_id_probe_highpoint_ataraid(struct volume_id *id, __u64 off) { const __u8 *buf; - dbg("probing at offset %llu", off); + dbg("probing at offset 0x%llx", (unsigned long long) off); buf = volume_id_get_buffer(id, off + HPT37X_CONFIG_OFF, 0x200); if (buf == NULL) diff --git a/volume_id/hpfs.c b/volume_id/hpfs.c index a8daea78..96c63d5e 100644 --- a/volume_id/hpfs.c +++ b/volume_id/hpfs.c @@ -51,14 +51,14 @@ int volume_id_probe_hpfs(struct volume_id *id, __u64 off) { struct hpfs_super *hs; - dbg("probing at offset %llu", off); + dbg("probing at offset 0x%llx", (unsigned long long) 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); + sprintf(id->type_version, "%u", hs->version); volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); id->type = "hpfs"; diff --git a/volume_id/iso9660.c b/volume_id/iso9660.c index ffccf609..5d4ab92a 100644 --- a/volume_id/iso9660.c +++ b/volume_id/iso9660.c @@ -47,68 +47,86 @@ #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; +struct iso_volume_descriptor { + __u8 vd_type; + __u8 vd_id[5]; + __u8 vd_version; + __u8 flags; + __u8 system_id[32]; + __u8 volume_id[32]; + __u8 unused[8]; + __u8 space_size[8]; + __u8 escape_sequences[8]; +} __attribute__((__packed__)); + +struct high_sierra_volume_descriptor { + __u8 foo[8]; + __u8 type; + __u8 id[4]; + __u8 version; } __attribute__((__packed__)); int volume_id_probe_iso9660(struct volume_id *id, __u64 off) { - union iso_super_block *is; + __u8 *buf; + struct iso_volume_descriptor *is; + struct high_sierra_volume_descriptor *hs; - dbg("probing at offset %llu", off); + dbg("probing at offset 0x%llx", (unsigned long long) off); - is = (union iso_super_block *) volume_id_get_buffer(id, off + ISO_SUPERBLOCK_OFFSET, 0x200); - if (is == NULL) + buf = volume_id_get_buffer(id, off + ISO_SUPERBLOCK_OFFSET, 0x200); + if (buf == NULL) return -1; - if (memcmp(is->iso.id, "CD001", 5) == 0) { - char root_label[VOLUME_ID_LABEL_SIZE+1]; + is = (struct iso_volume_descriptor *) buf; + + if (memcmp(is->vd_id, "CD001", 5) == 0) { int vd_offset; int i; - int found_svd; - memset(root_label, 0, sizeof(root_label)); - strncpy(root_label, is->iso.volume_id, sizeof(root_label)-1); + dbg("read label from PVD"); + volume_id_set_label_raw(id, is->volume_id, 32); + volume_id_set_label_string(id, is->volume_id, 32); - found_svd = 0; + dbg("looking for SVDs"); vd_offset = ISO_VD_OFFSET; for (i = 0; i < ISO_VD_MAX; i++) { - is = (union iso_super_block *) volume_id_get_buffer(id, off + vd_offset, 0x200); - if (is == NULL || is->iso.type == ISO_VD_END) - break; - if (is->iso.type == ISO_VD_SUPPLEMENTARY) { - dbg("found ISO supplementary VD at offset 0x%llx", off + vd_offset); - volume_id_set_label_raw(id, is->iso.volume_id, 32); - volume_id_set_label_unicode16(id, is->iso.volume_id, BE, 32); - found_svd = 1; + char svd_label[64]; + + is = (struct iso_volume_descriptor *) volume_id_get_buffer(id, off + vd_offset, 0x200); + if (is == NULL || is->vd_type == ISO_VD_END) break; + if (is->vd_type != ISO_VD_SUPPLEMENTARY) + continue; + + dbg("found SVD at offset 0x%llx", (unsigned long long) (off + vd_offset)); + if (memcmp(is->escape_sequences, "%/@", 3) == 0|| + memcmp(is->escape_sequences, "%/C", 3) == 0|| + memcmp(is->escape_sequences, "%/E", 3) == 0) { + dbg("Joliet extension found"); + volume_id_set_unicode16(svd_label, sizeof(svd_label), is->volume_id, BE, 32); + if (memcmp(id->label, svd_label, 16) == 0) { + dbg("SVD label is identical, use the possibly longer PVD one"); + break; + } + + volume_id_set_label_raw(id, is->volume_id, 32); + volume_id_set_label_string(id, svd_label, 32); + strcpy(id->type_version, "Joliet Extension"); + goto found; } vd_offset += ISO_SECTOR_SIZE; } - - if (!found_svd || - (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 (memcmp(is->hs.id, "CDROM", 5) == 0) + + hs = (struct high_sierra_volume_descriptor *) buf; + + if (memcmp(hs->id, "CDROM", 5) == 0) { + strcpy(id->type_version, "High Sierra"); goto found; + } + return -1; found: diff --git a/volume_id/jfs.c b/volume_id/jfs.c index ac4eab50..77fa0953 100644 --- a/volume_id/jfs.c +++ b/volume_id/jfs.c @@ -58,7 +58,7 @@ int volume_id_probe_jfs(struct volume_id *id, __u64 off) { struct jfs_super_block *js; - dbg("probing at offset %llu", off); + dbg("probing at offset 0x%llx", (unsigned long long) off); js = (struct jfs_super_block *) volume_id_get_buffer(id, off + JFS_SUPERBLOCK_OFFSET, 0x200); if (js == NULL) diff --git a/volume_id/linux_raid.c b/volume_id/linux_raid.c index 0ea8596a..e7db4031 100644 --- a/volume_id/linux_raid.c +++ b/volume_id/linux_raid.c @@ -67,7 +67,7 @@ int volume_id_probe_linux_raid(struct volume_id *id, __u64 off, __u64 size) __u64 sboff; __u8 uuid[16]; - dbg("probing at offset %llu", off); + dbg("probing at offset 0x%llx", (unsigned long long) off); if (size < 0x10000) return -1; diff --git a/volume_id/linux_swap.c b/volume_id/linux_swap.c index 39a2c4aa..e37a79be 100644 --- a/volume_id/linux_swap.c +++ b/volume_id/linux_swap.c @@ -55,7 +55,7 @@ int volume_id_probe_linux_swap(struct volume_id *id, __u64 off) const __u8 *buf; unsigned int page; - dbg("probing at offset %llu", off); + dbg("probing at offset 0x%llx", (unsigned long long) off); /* the swap signature is at the end of the PAGE_SIZE */ for (page = 0x1000; page <= LARGEST_PAGESIZE; page <<= 1) { diff --git a/volume_id/luks.c b/volume_id/luks.c index dbf7b610..a00bf404 100644 --- a/volume_id/luks.c +++ b/volume_id/luks.c @@ -26,7 +26,6 @@ # include <config.h> #endif -#include <netinet/in.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> @@ -50,29 +49,29 @@ #define LUKS_SALTSIZE 32 #define LUKS_NUMKEYS 8 -const unsigned char LUKS_MAGIC[] = {'L','U','K','S', 0xba, 0xbe}; +const __u8 LUKS_MAGIC[] = {'L','U','K','S', 0xba, 0xbe}; #define LUKS_MAGIC_L 6 #define LUKS_PHDR_SIZE (sizeof(struct luks_phdr)/SECTOR_SIZE+1) #define UUID_STRING_L 40 struct luks_phdr { - char magic[LUKS_MAGIC_L]; - uint16_t version; - char cipherName[LUKS_CIPHERNAME_L]; - char cipherMode[LUKS_CIPHERMODE_L]; - char hashSpec[LUKS_HASHSPEC_L]; - uint32_t payloadOffset; - uint32_t keyBytes; - char mkDigest[LUKS_DIGESTSIZE]; - char mkDigestSalt[LUKS_SALTSIZE]; - uint32_t mkDigestIterations; - char uuid[UUID_STRING_L]; + __u8 magic[LUKS_MAGIC_L]; + __u16 version; + __u8 cipherName[LUKS_CIPHERNAME_L]; + __u8 cipherMode[LUKS_CIPHERMODE_L]; + __u8 hashSpec[LUKS_HASHSPEC_L]; + __u32 payloadOffset; + __u32 keyBytes; + __u8 mkDigest[LUKS_DIGESTSIZE]; + __u8 mkDigestSalt[LUKS_SALTSIZE]; + __u32 mkDigestIterations; + __u8 uuid[UUID_STRING_L]; struct { - uint32_t active; - uint32_t passwordIterations; - char passwordSalt[LUKS_SALTSIZE]; - uint32_t keyMaterialOffset; - uint32_t stripes; + __u32 active; + __u32 passwordIterations; + __u8 passwordSalt[LUKS_SALTSIZE]; + __u32 keyMaterialOffset; + __u32 stripes; } keyblock[LUKS_NUMKEYS]; }; diff --git a/volume_id/lvm.c b/volume_id/lvm.c index bfc2ef23..d1e337dc 100644 --- a/volume_id/lvm.c +++ b/volume_id/lvm.c @@ -59,7 +59,7 @@ int volume_id_probe_lvm1(struct volume_id *id, __u64 off) const __u8 *buf; struct lvm1_super_block *lvm; - dbg("probing at offset %llu", off); + dbg("probing at offset 0x%llx", (unsigned long long) off); buf = volume_id_get_buffer(id, off + LVM1_SB_OFF, 0x800); if (buf == NULL) @@ -85,7 +85,7 @@ int volume_id_probe_lvm2(struct volume_id *id, __u64 off) unsigned int soff; struct lvm2_super_block *lvm; - dbg("probing at offset %llu", off); + dbg("probing at offset 0x%llx", (unsigned long long) off); buf = volume_id_get_buffer(id, off, LVM2LABEL_SCAN_SECTORS * 0x200); if (buf == NULL) diff --git a/volume_id/mac.c b/volume_id/mac.c index 2e2db486..dcfacc2a 100644 --- a/volume_id/mac.c +++ b/volume_id/mac.c @@ -61,7 +61,7 @@ int volume_id_probe_mac_partition_map(struct volume_id *id, __u64 off) struct mac_driver_desc *driver; struct mac_partition *part; - dbg("probing at offset %llu", off); + dbg("probing at offset 0x%llx", (unsigned long long) off); buf = volume_id_get_buffer(id, off, 0x200); if (buf == NULL) @@ -122,7 +122,7 @@ int volume_id_probe_mac_partition_map(struct volume_id *id, __u64 off) poff = be32_to_cpu(part->start_block) * bsize; plen = be32_to_cpu(part->block_count) * bsize; dbg("found '%s' partition entry at 0x%llx, len 0x%llx", - part->type, poff, plen); + part->type, (unsigned long long) poff, (unsigned long long) plen); id->partitions[i].off = poff; id->partitions[i].len = plen; diff --git a/volume_id/minix.c b/volume_id/minix.c new file mode 100644 index 00000000..d2f2a336 --- /dev/null +++ b/volume_id/minix.c @@ -0,0 +1,97 @@ +/* + * 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 "minix.h" + +struct minix_super_block +{ + __u16 s_ninodes; + __u16 s_nzones; + __u16 s_imap_blocks; + __u16 s_zmap_blocks; + __u16 s_firstdatazone; + __u16 s_log_zone_size; + __u32 s_max_size; + __u16 s_magic; + __u16 s_state; + __u32 s_zones; +} __attribute__((__packed__)); + +#define MINIX_SUPERBLOCK_OFFSET 0x400 + +int volume_id_probe_minix(struct volume_id *id, __u64 off) +{ + struct minix_super_block *ms; + + dbg("probing at offset 0x%llx", (unsigned long long) off); + + ms = (struct minix_super_block *) volume_id_get_buffer(id, off + MINIX_SUPERBLOCK_OFFSET, 0x200); + if (ms == NULL) + return -1; + + if (le16_to_cpu(ms->s_magic) == 0x137f) { + strcpy(id->type_version, "1"); + goto found; + } + + if (le16_to_cpu(ms->s_magic) == 0x1387) { + strcpy(id->type_version, "1"); + goto found; + } + + if (le16_to_cpu(ms->s_magic) == 0x2468) { + strcpy(id->type_version, "2"); + goto found; + } + + if (le16_to_cpu(ms->s_magic) == 0x2478) { + strcpy(id->type_version, "2"); + goto found; + } + + goto exit; + +found: + volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); + id->type = "minix"; + return 0; + +exit: + return -1; +} diff --git a/volume_id/minix.h b/volume_id/minix.h new file mode 100644 index 00000000..7a9d97ad --- /dev/null +++ b/volume_id/minix.h @@ -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_MINIX_ +#define _VOLUME_ID_MINIX_ + +extern int volume_id_probe_minix(struct volume_id *id, __u64 off); + +#endif diff --git a/volume_id/msdos.c b/volume_id/msdos.c index fc2f99d4..47c94456 100644 --- a/volume_id/msdos.c +++ b/volume_id/msdos.c @@ -81,7 +81,7 @@ int volume_id_probe_msdos_part_table(struct volume_id *id, __u64 off) struct msdos_partition_entry *part; struct volume_id_partition *p; - dbg("probing at offset %llu", off); + dbg("probing at offset 0x%llx", (unsigned long long) off); buf = volume_id_get_buffer(id, off, 0x200); if (buf == NULL) @@ -124,14 +124,14 @@ int volume_id_probe_msdos_part_table(struct volume_id *id, __u64 off) p->partition_type_raw = part[i].sys_ind; if (is_extended(part[i].sys_ind)) { - dbg("found extended partition at 0x%llx", poff); + dbg("found extended partition at 0x%llx", (unsigned long long) poff); volume_id_set_usage_part(p, VOLUME_ID_PARTITIONTABLE); p->type = "msdos_extended_partition"; if (extended == 0) extended = off + poff; } else { dbg("found 0x%x data partition at 0x%llx, len 0x%llx", - part[i].sys_ind, poff, plen); + part[i].sys_ind, (unsigned long long) poff, (unsigned long long) plen); if (is_raid(part[i].sys_ind)) volume_id_set_usage_part(p, VOLUME_ID_RAID); @@ -174,12 +174,12 @@ int volume_id_probe_msdos_part_table(struct volume_id *id, __u64 off) continue; if (is_extended(part[i].sys_ind)) { - dbg("found extended partition at 0x%llx", poff); + dbg("found extended partition at 0x%llx", (unsigned long long) poff); if (next == 0) next = extended + poff; } else { dbg("found 0x%x data partition at 0x%llx, len 0x%llx", - part[i].sys_ind, poff, plen); + part[i].sys_ind, (unsigned long long) poff, (unsigned long long) plen); /* we always start at the 5th entry */ while (id->partition_count < 4) diff --git a/volume_id/ntfs.c b/volume_id/ntfs.c index 84d6fbb8..8f31735a 100644 --- a/volume_id/ntfs.c +++ b/volume_id/ntfs.c @@ -118,7 +118,7 @@ int volume_id_probe_ntfs(struct volume_id *id, __u64 off) const __u8 *buf; const __u8 *val; - dbg("probing at offset %llu", off); + dbg("probing at offset 0x%llx", (unsigned long long) off); ns = (struct ntfs_super_block *) volume_id_get_buffer(id, off, 0x200); if (ns == NULL) @@ -142,8 +142,8 @@ int volume_id_probe_ntfs(struct volume_id *id, __u64 off) dbg("sectorsize 0x%x", sector_size); dbg("clustersize 0x%x", cluster_size); - dbg("mftcluster %lli", mft_cluster); - dbg("mftoffset 0x%llx", mft_off); + dbg("mftcluster %llu", (unsigned long long) mft_cluster); + dbg("mftoffset 0x%llx", (unsigned long long) mft_off); dbg("cluster per mft_record %i", ns->cluster_per_mft_record); dbg("mft record size %i", mft_record_size); diff --git a/volume_id/reiserfs.c b/volume_id/reiserfs.c index 094062db..34cf167d 100644 --- a/volume_id/reiserfs.c +++ b/volume_id/reiserfs.c @@ -73,7 +73,7 @@ int volume_id_probe_reiserfs(struct volume_id *id, __u64 off) struct reiser4_super_block *rs4; __u8 *buf; - dbg("probing at offset %llu", off); + dbg("probing at offset 0x%llx", (unsigned long long) off); buf = volume_id_get_buffer(id, off + REISERFS_SUPERBLOCK_OFFSET, 0x200); if (buf == NULL) diff --git a/volume_id/romfs.c b/volume_id/romfs.c index fe5e5a48..9c2b41bb 100644 --- a/volume_id/romfs.c +++ b/volume_id/romfs.c @@ -50,7 +50,7 @@ int volume_id_probe_romfs(struct volume_id *id, __u64 off) { struct romfs_super *rfs; - dbg("probing at offset %llu", off); + dbg("probing at offset 0x%llx", (unsigned long long) off); rfs = (struct romfs_super *) volume_id_get_buffer(id, off, 0x200); if (rfs == NULL) diff --git a/volume_id/sysv.c b/volume_id/sysv.c index 6c4408d8..d4745daa 100644 --- a/volume_id/sysv.c +++ b/volume_id/sysv.c @@ -108,7 +108,7 @@ int volume_id_probe_sysv(struct volume_id *id, __u64 off) struct xenix_super *xs; unsigned int boff; - dbg("probing at offset %llu", off); + dbg("probing at offset 0x%llx", (unsigned long long) off); for (boff = 0x200; boff <= SYSV_MAX_BLOCKSIZE; boff <<= 1) { vs = (struct sysv_super *) diff --git a/volume_id/udf.c b/volume_id/udf.c index 06b52154..a378fa9f 100644 --- a/volume_id/udf.c +++ b/volume_id/udf.c @@ -85,7 +85,7 @@ int volume_id_probe_udf(struct volume_id *id, __u64 off) unsigned int loc; unsigned int clen; - dbg("probing at offset %llu", off); + dbg("probing at offset 0x%llx", (unsigned long long) off); vsd = (struct volume_structure_descriptor *) volume_id_get_buffer(id, off + UDF_VSD_OFFSET, 0x200); if (vsd == NULL) diff --git a/volume_id/ufs.c b/volume_id/ufs.c index 37e74aee..d4f4db3d 100644 --- a/volume_id/ufs.c +++ b/volume_id/ufs.c @@ -188,7 +188,7 @@ int volume_id_probe_ufs(struct volume_id *id, __u64 off) struct ufs_super_block *ufs; int offsets[] = {0, 8, 64, 256, -1}; - dbg("probing at offset %llu", off); + dbg("probing at offset 0x%llx", (unsigned long long) off); for (i = 0; offsets[i] >= 0; i++) { ufs = (struct ufs_super_block *) volume_id_get_buffer(id, off + (offsets[i] * 0x400), 0x800); diff --git a/volume_id/util.c b/volume_id/util.c index 6ae4d099..7499fc12 100644 --- a/volume_id/util.c +++ b/volume_id/util.c @@ -40,6 +40,40 @@ #include "logging.h" #include "util.h" +void volume_id_set_unicode16(char *str, unsigned int len, const __u8 *buf, enum endian endianess, unsigned int count) +{ + unsigned int i, j; + __u16 c; + + j = 0; + for (i = 0; i + 2 <= count; i += 2) { + if (endianess == LE) + c = (buf[i+1] << 8) | buf[i]; + else + c = (buf[i] << 8) | buf[i+1]; + if (c == 0) { + str[j] = '\0'; + break; + } else if (c < 0x80) { + if (j+1 >= len) + break; + str[j++] = (__u8) c; + } else if (c < 0x800) { + if (j+2 >= len) + break; + str[j++] = (__u8) (0xc0 | (c >> 6)); + str[j++] = (__u8) (0x80 | (c & 0x3f)); + } else { + if (j+3 >= len) + break; + str[j++] = (__u8) (0xe0 | (c >> 12)); + str[j++] = (__u8) (0x80 | ((c >> 6) & 0x3f)); + str[j++] = (__u8) (0x80 | (c & 0x3f)); + } + } + str[j] = '\0'; +} + static char *usage_to_string(enum volume_id_usage usage_id) { switch (usage_id) { @@ -98,29 +132,7 @@ void volume_id_set_label_string(struct volume_id *id, const __u8 *buf, unsigned void volume_id_set_label_unicode16(struct volume_id *id, const __u8 *buf, enum endian endianess, unsigned int count) { - unsigned int i, j; - __u16 c; - - j = 0; - for (i = 0; i + 2 <= count; i += 2) { - if (endianess == LE) - c = (buf[i+1] << 8) | buf[i]; - else - c = (buf[i] << 8) | buf[i+1]; - if (c == 0) { - id->label[j] = '\0'; - break; - } else if (c < 0x80) { - id->label[j++] = (__u8) c; - } else if (c < 0x800) { - id->label[j++] = (__u8) (0xc0 | (c >> 6)); - id->label[j++] = (__u8) (0x80 | (c & 0x3f)); - } else { - id->label[j++] = (__u8) (0xe0 | (c >> 12)); - id->label[j++] = (__u8) (0x80 | ((c >> 6) & 0x3f)); - id->label[j++] = (__u8) (0x80 | (c & 0x3f)); - } - } + volume_id_set_unicode16(id->label, sizeof(id->label), buf, endianess, count); } void volume_id_set_uuid(struct volume_id *id, const __u8 *buf, enum uuid_format format) @@ -188,7 +200,7 @@ __u8 *volume_id_get_buffer(struct volume_id *id, __u64 off, unsigned int len) { unsigned int buf_len; - dbg("get buffer off 0x%llx(%llu), len 0x%x", off, off, len); + dbg("get buffer off 0x%llx(%llu), len 0x%x", (unsigned long long) off, (unsigned long long) off, len); /* check if requested area fits in superblock buffer */ if (off + len <= SB_BUFFER_SIZE) { if (id->sbbuf == NULL) { @@ -199,7 +211,7 @@ __u8 *volume_id_get_buffer(struct volume_id *id, __u64 off, unsigned int len) /* check if we need to read */ if ((off + len) > id->sbbuf_len) { - dbg("read sbbuf len:0x%llx", off + len); + dbg("read sbbuf len:0x%llx", (unsigned long long) (off + len)); lseek(id->fd, 0, SEEK_SET); buf_len = read(id->fd, id->sbbuf, off + len); dbg("got 0x%x (%i) bytes", buf_len, buf_len); @@ -224,7 +236,7 @@ __u8 *volume_id_get_buffer(struct volume_id *id, __u64 off, unsigned int len) /* check if we need to read */ if ((off < id->seekbuf_off) || ((off + len) > (id->seekbuf_off + id->seekbuf_len))) { - dbg("read seekbuf off:0x%llx len:0x%x", off, len); + dbg("read seekbuf off:0x%llx len:0x%x", (unsigned long long) off, len); if (lseek(id->fd, off, SEEK_SET) == -1) return NULL; buf_len = read(id->fd, id->seekbuf, len); diff --git a/volume_id/util.h b/volume_id/util.h index 0357b420..9cea8fc3 100644 --- a/volume_id/util.h +++ b/volume_id/util.h @@ -83,6 +83,7 @@ enum endian { BE = 1 }; +extern void volume_id_set_unicode16(char *str, unsigned int len, const __u8 *buf, enum endian endianess, unsigned int count); extern void volume_id_set_usage(struct volume_id *id, enum volume_id_usage usage_id); extern void volume_id_set_usage_part(struct volume_id_partition *part, enum volume_id_usage usage_id); extern void volume_id_set_label_raw(struct volume_id *id, const __u8 *buf, unsigned int count); diff --git a/volume_id/volume_id.c b/volume_id/volume_id.c index 7a08be89..22d30ee7 100644 --- a/volume_id/volume_id.c +++ b/volume_id/volume_id.c @@ -60,6 +60,7 @@ #include "hpfs.h" #include "romfs.h" #include "sysv.h" +#include "minix.h" #include "mac.h" #include "msdos.h" @@ -136,6 +137,9 @@ int volume_id_probe_all(struct volume_id *id, unsigned long long off, unsigned l if (volume_id_probe_sysv(id, off) == 0) goto exit; + if (volume_id_probe_minix(id, off) == 0) + goto exit; + return -1; exit: diff --git a/volume_id/volume_id.h b/volume_id/volume_id.h index 2b92bf4f..0a273fba 100644 --- a/volume_id/volume_id.h +++ b/volume_id/volume_id.h @@ -21,7 +21,7 @@ #ifndef _VOLUME_ID_H_ #define _VOLUME_ID_H_ -#define VOLUME_ID_VERSION 37 +#define VOLUME_ID_VERSION 41 #define VOLUME_ID_LABEL_SIZE 64 #define VOLUME_ID_UUID_SIZE 36 diff --git a/volume_id/xfs.c b/volume_id/xfs.c index 12a89aaf..b8702a3f 100644 --- a/volume_id/xfs.c +++ b/volume_id/xfs.c @@ -58,7 +58,7 @@ int volume_id_probe_xfs(struct volume_id *id, __u64 off) { struct xfs_super_block *xs; - dbg("probing at offset %llu", off); + dbg("probing at offset 0x%llx", (unsigned long long) off); xs = (struct xfs_super_block *) volume_id_get_buffer(id, off, 0x200); if (xs == NULL) |