1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-10-30 23:21:08 +03:00

[PATCH] udev_volume_id: volume_id version 032

This commit is contained in:
kay.sievers@vrfy.org 2005-02-05 04:10:48 +01:00 committed by Greg KH
parent 51df9ee496
commit 7979e3d4b7
17 changed files with 154 additions and 47 deletions

View File

@ -47,6 +47,7 @@ VOLUME_ID_OBJS= \
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
@ -68,6 +69,7 @@ VOLUME_ID_HEADERS= \
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

View File

@ -0,0 +1,75 @@
/*
* 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 "cramfs.h"
struct cramfs_super {
__u8 magic[4];
__u32 size;
__u32 flags;
__u32 future;
__u8 signature[16];
struct cramfs_info {
__u32 crc;
__u32 edition;
__u32 blocks;
__u32 files;
} __attribute__((__packed__)) info;
__u8 name[16];
} __attribute__((__packed__));
int volume_id_probe_cramfs(struct volume_id *id, __u64 off)
{
struct cramfs_super *cs;
cs = (struct cramfs_super *) volume_id_get_buffer(id, off, 0x200);
if (cs == NULL)
return -1;
if (memcmp(cs->magic, "\x45\x3d\xcd\x28", 4) == 0) {
volume_id_set_label_raw(id, cs->name, 16);
volume_id_set_label_string(id, cs->name, 16);
volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
id->type = "cramfs";
return 0;
}
return -1;
}

View File

@ -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_CRAMFS_
#define _VOLUME_ID_CRAMFS_
extern int volume_id_probe_cramfs(struct volume_id *id, __u64 off);
#endif

View File

@ -166,22 +166,22 @@ int volume_id_probe_vfat(struct volume_id *id, __u64 off)
/* believe only that's fat, don't trust the version
* the cluster_count will tell us
*/
if (strncmp(vs->sysid, "NTFS", 4) == 0)
if (memcmp(vs->sysid, "NTFS", 4) == 0)
return -1;
if (strncmp(vs->type.fat32.magic, "MSWIN", 5) == 0)
if (memcmp(vs->type.fat32.magic, "MSWIN", 5) == 0)
goto valid;
if (strncmp(vs->type.fat32.magic, "FAT32 ", 8) == 0)
if (memcmp(vs->type.fat32.magic, "FAT32 ", 8) == 0)
goto valid;
if (strncmp(vs->type.fat.magic, "FAT16 ", 8) == 0)
if (memcmp(vs->type.fat.magic, "FAT16 ", 8) == 0)
goto valid;
if (strncmp(vs->type.fat.magic, "MSDOS", 5) == 0)
if (memcmp(vs->type.fat.magic, "MSDOS", 5) == 0)
goto valid;
if (strncmp(vs->type.fat.magic, "FAT12 ", 8) == 0)
if (memcmp(vs->type.fat.magic, "FAT12 ", 8) == 0)
goto valid;
/*
@ -272,10 +272,10 @@ valid:
if (vs == NULL)
return -1;
if (label != NULL && strncmp(label, "NO NAME ", 11) != 0) {
if (label != NULL && memcmp(label, "NO NAME ", 11) != 0) {
volume_id_set_label_raw(id, label, 11);
volume_id_set_label_string(id, label, 11);
} else if (strncmp(vs->type.fat.label, "NO NAME ", 11) != 0) {
} else if (memcmp(vs->type.fat.label, "NO NAME ", 11) != 0) {
volume_id_set_label_raw(id, vs->type.fat.label, 11);
volume_id_set_label_string(id, vs->type.fat.label, 11);
}
@ -333,10 +333,10 @@ fat32:
if (vs == NULL)
return -1;
if (label != NULL && strncmp(label, "NO NAME ", 11) != 0) {
if (label != NULL && memcmp(label, "NO NAME ", 11) != 0) {
volume_id_set_label_raw(id, label, 11);
volume_id_set_label_string(id, label, 11);
} else if (strncmp(vs->type.fat32.label, "NO NAME ", 11) != 0) {
} else if (memcmp(vs->type.fat32.label, "NO NAME ", 11) != 0) {
volume_id_set_label_raw(id, vs->type.fat32.label, 11);
volume_id_set_label_string(id, vs->type.fat32.label, 11);
}

View File

@ -178,11 +178,11 @@ int volume_id_probe_hfs_hfsplus(struct volume_id *id, __u64 off)
return -1;
hfs = (struct hfs_mdb *) buf;
if (strncmp(hfs->signature, "BD", 2) != 0)
if (memcmp(hfs->signature, "BD", 2) != 0)
goto checkplus;
/* it may be just a hfs wrapper for hfs+ */
if (strncmp(hfs->embed_sig, "H+", 2) == 0) {
if (memcmp(hfs->embed_sig, "H+", 2) == 0) {
alloc_block_size = be32_to_cpu(hfs->al_blk_size);
dbg("alloc_block_size 0x%x", alloc_block_size);
@ -216,9 +216,9 @@ int volume_id_probe_hfs_hfsplus(struct volume_id *id, __u64 off)
checkplus:
hfsplus = (struct hfsplus_vol_header *) buf;
if (strncmp(hfsplus->signature, "H+", 2) == 0)
if (memcmp(hfsplus->signature, "H+", 2) == 0)
goto hfsplus;
if (strncmp(hfsplus->signature, "HX", 2) == 0)
if (memcmp(hfsplus->signature, "HX", 2) == 0)
goto hfsplus;
return -1;

View File

@ -70,7 +70,7 @@ int volume_id_probe_iso9660(struct volume_id *id, __u64 off)
if (is == NULL)
return -1;
if (strncmp(is->iso.id, "CD001", 5) == 0) {
if (memcmp(is->iso.id, "CD001", 5) == 0) {
char root_label[VOLUME_ID_LABEL_SIZE+1];
int vd_offset;
int i;
@ -96,14 +96,14 @@ int volume_id_probe_iso9660(struct volume_id *id, __u64 off)
}
if (!found_svd ||
(found_svd && !strncmp(root_label, id->label, 16)))
(found_svd && !memcmp(root_label, id->label, 16)))
{
volume_id_set_label_raw(id, root_label, 32);
volume_id_set_label_string(id, root_label, 32);
}
goto found;
}
if (strncmp(is->hs.id, "CDROM", 5) == 0)
if (memcmp(is->hs.id, "CDROM", 5) == 0)
goto found;
return -1;

View File

@ -60,7 +60,7 @@ int volume_id_probe_jfs(struct volume_id *id, __u64 off)
if (js == NULL)
return -1;
if (strncmp(js->magic, "JFS1", 4) != 0)
if (memcmp(js->magic, "JFS1", 4) != 0)
return -1;
volume_id_set_label_raw(id, js->label, 16);

View File

@ -61,12 +61,12 @@ int volume_id_probe_linux_swap(struct volume_id *id, __u64 off)
if (buf == NULL)
return -1;
if (strncmp(buf, "SWAP-SPACE", 10) == 0) {
if (memcmp(buf, "SWAP-SPACE", 10) == 0) {
strcpy(id->type_version, "1");
goto found;
}
if (strncmp(buf, "SWAPSPACE2", 10) == 0) {
if (memcmp(buf, "SWAPSPACE2", 10) == 0) {
sw = (struct swap_header_v1_2 *) volume_id_get_buffer(id, off, sizeof(struct swap_header_v1_2));
if (sw == NULL)
return -1;

View File

@ -56,7 +56,7 @@ int volume_id_probe_lvm1(struct volume_id *id, __u64 off)
lvm = (struct lvm2_super_block *) buf;
if (strncmp(lvm->id, LVM1_MAGIC, 2) != 0)
if (memcmp(lvm->id, LVM1_MAGIC, 2) != 0)
return -1;
volume_id_set_usage(id, VOLUME_ID_RAID);
@ -89,7 +89,7 @@ int volume_id_probe_lvm2(struct volume_id *id, __u64 off)
for (soff = 0; soff < LVM2LABEL_SCAN_SECTORS * 0x200; soff += 0x200) {
lvm = (struct lvm2_super_block *) &buf[soff];
if (strncmp(lvm->id, LVM2_LABEL_ID, 8) == 0)
if (memcmp(lvm->id, LVM2_LABEL_ID, 8) == 0)
goto found;
}

View File

@ -64,8 +64,8 @@ int volume_id_probe_mac_partition_map(struct volume_id *id, __u64 off)
return -1;
part = (struct mac_partition *) buf;
if ((strncmp(part->signature, "PM", 2) == 0) &&
(strncmp(part->type, "Apple_partition_map", 19) == 0)) {
if ((memcmp(part->signature, "PM", 2) == 0) &&
(memcmp(part->type, "Apple_partition_map", 19) == 0)) {
/* linux creates an own subdevice for the map
* just return the type if the drive header is missing */
volume_id_set_usage(id, VOLUME_ID_PARTITIONTABLE);
@ -74,7 +74,7 @@ int volume_id_probe_mac_partition_map(struct volume_id *id, __u64 off)
}
driver = (struct mac_driver_desc *) buf;
if (strncmp(driver->signature, "ER", 2) == 0) {
if (memcmp(driver->signature, "ER", 2) == 0) {
/* we are on a main device, like a CD
* just try to probe the first partition from the map */
unsigned int bsize = be16_to_cpu(driver->block_size);
@ -87,7 +87,7 @@ int volume_id_probe_mac_partition_map(struct volume_id *id, __u64 off)
return -1;
part = (struct mac_partition *) buf;
if (strncmp(part->signature, "PM", 2) != 0)
if (memcmp(part->signature, "PM", 2) != 0)
return -1;
part_count = be32_to_cpu(part->map_count);
@ -112,7 +112,7 @@ int volume_id_probe_mac_partition_map(struct volume_id *id, __u64 off)
return -1;
part = (struct mac_partition *) buf;
if (strncmp(part->signature, "PM", 2) != 0)
if (memcmp(part->signature, "PM", 2) != 0)
return -1;
poff = be32_to_cpu(part->start_block) * bsize;
@ -123,9 +123,9 @@ int volume_id_probe_mac_partition_map(struct volume_id *id, __u64 off)
id->partitions[i].off = poff;
id->partitions[i].len = plen;
if (strncmp(part->type, "Apple_Free", 10) == 0) {
if (memcmp(part->type, "Apple_Free", 10) == 0) {
volume_id_set_usage_part(&id->partitions[i], VOLUME_ID_UNUSED);
} else if (strncmp(part->type, "Apple_partition_map", 19) == 0) {
} else if (memcmp(part->type, "Apple_partition_map", 19) == 0) {
volume_id_set_usage_part(&id->partitions[i], VOLUME_ID_PARTITIONTABLE);
} else {
volume_id_set_usage_part(&id->partitions[i], VOLUME_ID_UNPROBED);

View File

@ -84,7 +84,7 @@ int volume_id_probe_msdos_part_table(struct volume_id *id, __u64 off)
if (buf == NULL)
return -1;
if (strncmp(&buf[MSDOS_SIG_OFF], MSDOS_MAGIC, 2) != 0)
if (memcmp(&buf[MSDOS_SIG_OFF], MSDOS_MAGIC, 2) != 0)
return -1;
/* check flags on all entries for a valid partition table */
@ -158,7 +158,7 @@ int volume_id_probe_msdos_part_table(struct volume_id *id, __u64 off)
part = (struct msdos_partition_entry*) &buf[MSDOS_PARTTABLE_OFFSET];
if (strncmp(&buf[MSDOS_SIG_OFF], MSDOS_MAGIC, 2) != 0)
if (memcmp(&buf[MSDOS_SIG_OFF], MSDOS_MAGIC, 2) != 0)
break;
next = 0;

View File

@ -122,7 +122,7 @@ int volume_id_probe_ntfs(struct volume_id *id, __u64 off)
if (ns == NULL)
return -1;
if (strncmp(ns->oem_id, "NTFS", 4) != 0)
if (memcmp(ns->oem_id, "NTFS", 4) != 0)
return -1;
volume_id_set_uuid(id, ns->volume_serial, UUID_NTFS);
@ -153,7 +153,7 @@ int volume_id_probe_ntfs(struct volume_id *id, __u64 off)
mftr = (struct master_file_table_record*) buf;
dbg("mftr->magic '%c%c%c%c'", mftr->magic[0], mftr->magic[1], mftr->magic[2], mftr->magic[3]);
if (strncmp(mftr->magic, "FILE", 4) != 0)
if (memcmp(mftr->magic, "FILE", 4) != 0)
goto found;
attr_off = le16_to_cpu(mftr->attrs_offset);

View File

@ -64,12 +64,12 @@ int volume_id_probe_reiserfs(struct volume_id *id, __u64 off)
if (rs == NULL)
return -1;
if (strncmp(rs->magic, "ReIsEr2Fs", 9) == 0) {
if (memcmp(rs->magic, "ReIsEr2Fs", 9) == 0) {
strcpy(id->type_version, "3.6");
goto found;
}
if (strncmp(rs->magic, "ReIsEr3Fs", 9) == 0) {
if (memcmp(rs->magic, "ReIsEr3Fs", 9) == 0) {
strcpy(id->type_version, "JR");
goto found;
}
@ -78,7 +78,7 @@ int volume_id_probe_reiserfs(struct volume_id *id, __u64 off)
if (rs == NULL)
return -1;
if (strncmp(rs->magic, "ReIsErFs", 8) == 0) {
if (memcmp(rs->magic, "ReIsErFs", 8) == 0) {
strcpy(id->type_version, "3.5");
goto found;
}

View File

@ -87,19 +87,19 @@ int volume_id_probe_udf(struct volume_id *id, __u64 off)
if (vsd == NULL)
return -1;
if (strncmp(vsd->id, "NSR02", 5) == 0)
if (memcmp(vsd->id, "NSR02", 5) == 0)
goto blocksize;
if (strncmp(vsd->id, "NSR03", 5) == 0)
if (memcmp(vsd->id, "NSR03", 5) == 0)
goto blocksize;
if (strncmp(vsd->id, "BEA01", 5) == 0)
if (memcmp(vsd->id, "BEA01", 5) == 0)
goto blocksize;
if (strncmp(vsd->id, "BOOT2", 5) == 0)
if (memcmp(vsd->id, "BOOT2", 5) == 0)
goto blocksize;
if (strncmp(vsd->id, "CD001", 5) == 0)
if (memcmp(vsd->id, "CD001", 5) == 0)
goto blocksize;
if (strncmp(vsd->id, "CDW02", 5) == 0)
if (memcmp(vsd->id, "CDW02", 5) == 0)
goto blocksize;
if (strncmp(vsd->id, "TEA03", 5) == 0)
if (memcmp(vsd->id, "TEA03", 5) == 0)
goto blocksize;
return -1;
@ -127,9 +127,9 @@ nsr:
if (vsd->id[0] == '\0')
return -1;
if (strncmp(vsd->id, "NSR02", 5) == 0)
if (memcmp(vsd->id, "NSR02", 5) == 0)
goto anchor;
if (strncmp(vsd->id, "NSR03", 5) == 0)
if (memcmp(vsd->id, "NSR03", 5) == 0)
goto anchor;
}
return -1;

View File

@ -55,6 +55,7 @@
#include "linux_swap/linux_swap.h"
#include "linux_raid/linux_raid.h"
#include "lvm/lvm.h"
#include "cramfs/cramfs.h"
#include "mac/mac.h"
#include "msdos/msdos.h"
@ -116,6 +117,9 @@ int volume_id_probe_all(struct volume_id *id, unsigned long long off, unsigned l
if (volume_id_probe_ntfs(id, off) == 0)
goto exit;
if (volume_id_probe_cramfs(id, off) == 0)
goto exit;
return -1;
exit:

View File

@ -21,7 +21,7 @@
#ifndef _VOLUME_ID_H_
#define _VOLUME_ID_H_
#define VOLUME_ID_VERSION 31
#define VOLUME_ID_VERSION 32
#define VOLUME_ID_LABEL_SIZE 64
#define VOLUME_ID_UUID_SIZE 16

View File

@ -60,7 +60,7 @@ int volume_id_probe_xfs(struct volume_id *id, __u64 off)
if (xs == NULL)
return -1;
if (strncmp(xs->magic, "XFSB", 4) != 0)
if (memcmp(xs->magic, "XFSB", 4) != 0)
return -1;
volume_id_set_label_raw(id, xs->fname, 12);