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/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
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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
/* 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;
/*
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);
}
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);
}
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);
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;
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;
}
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;
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);
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;
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);
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;
}
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);
}
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);
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);
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;
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);
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 */
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;
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);
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);
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;
}
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;
}
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;
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;
#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"
if (volume_id_probe_ntfs(id, off) == 0)
goto exit;
+ if (volume_id_probe_cramfs(id, off) == 0)
+ goto exit;
+
return -1;
exit:
#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
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);