chiark / gitweb /
[PATCH] udev_volume_id: version 39
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>
Sun, 6 Mar 2005 11:16:32 +0000 (12:16 +0100)
committerGreg KH <gregkh@suse.de>
Wed, 27 Apr 2005 06:51:00 +0000 (23:51 -0700)
extras/volume_id/volume_id/Makefile.inc
extras/volume_id/volume_id/hpfs.c
extras/volume_id/volume_id/minix.c [new file with mode: 0644]
extras/volume_id/volume_id/minix.h [new file with mode: 0644]
extras/volume_id/volume_id/volume_id.c
extras/volume_id/volume_id/volume_id.h
udev_db.c

index 9cadec20cc291d1a0ef343527369df0293d62cf2..68d80d689c58acc34fb78a292567d5532dc26dc3 100644 (file)
@@ -19,6 +19,7 @@ VOLUME_ID_OBJS=                                       \
        $(VOLUME_ID_BASE)/hpfs.o                \
        $(VOLUME_ID_BASE)/romfs.o               \
        $(VOLUME_ID_BASE)/sysv.o                \
        $(VOLUME_ID_BASE)/hpfs.o                \
        $(VOLUME_ID_BASE)/romfs.o               \
        $(VOLUME_ID_BASE)/sysv.o                \
+       $(VOLUME_ID_BASE)/minix.o               \
        $(VOLUME_ID_BASE)/dasd.o                \
        $(VOLUME_ID_BASE)/luks.o                \
        $(VOLUME_ID_BASE)/volume_id.o           \
        $(VOLUME_ID_BASE)/dasd.o                \
        $(VOLUME_ID_BASE)/luks.o                \
        $(VOLUME_ID_BASE)/volume_id.o           \
@@ -42,8 +43,9 @@ VOLUME_ID_HEADERS=                            \
        $(VOLUME_ID_BASE)/ufs.h                 \
        $(VOLUME_ID_BASE)/xfs.h                 \
        $(VOLUME_ID_BASE)/cramfs.h              \
        $(VOLUME_ID_BASE)/ufs.h                 \
        $(VOLUME_ID_BASE)/xfs.h                 \
        $(VOLUME_ID_BASE)/cramfs.h              \
-       $(VOLUME_ID_BASE)/sysv.h                \
        $(VOLUME_ID_BASE)/romfs.h               \
        $(VOLUME_ID_BASE)/romfs.h               \
+       $(VOLUME_ID_BASE)/sysv.h                \
+       $(VOLUME_ID_BASE)/minix.h               \
        $(VOLUME_ID_BASE)/dasd.h                \
        $(VOLUME_ID_BASE)/luks.h                \
        $(VOLUME_ID_BASE)/volume_id.h           \
        $(VOLUME_ID_BASE)/dasd.h                \
        $(VOLUME_ID_BASE)/luks.h                \
        $(VOLUME_ID_BASE)/volume_id.h           \
index a8daea7892568a5501b22d8d0cc9cb78c81da98e..3aa95fa8397da25a32fd4739a6611e879973d4d7 100644 (file)
@@ -58,7 +58,7 @@ int volume_id_probe_hpfs(struct volume_id *id, __u64 off)
                return -1;
 
        if (memcmp(hs->magic, "\x49\xe8\x95\xf9", 4) == 0) {
                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";
 
                volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
                id->type = "hpfs";
diff --git a/extras/volume_id/volume_id/minix.c b/extras/volume_id/volume_id/minix.c
new file mode 100644 (file)
index 0000000..d9c9ea8
--- /dev/null
@@ -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 %llu", 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/extras/volume_id/volume_id/minix.h b/extras/volume_id/volume_id/minix.h
new file mode 100644 (file)
index 0000000..7a9d97a
--- /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_MINIX_
+#define _VOLUME_ID_MINIX_
+
+extern int volume_id_probe_minix(struct volume_id *id, __u64 off);
+
+#endif
index 7a08be89d9e2e4cc2b6af9d28051e2187413ecab..22d30ee7413061251d10883c1d6e7e62b312001b 100644 (file)
@@ -60,6 +60,7 @@
 #include "hpfs.h"
 #include "romfs.h"
 #include "sysv.h"
 #include "hpfs.h"
 #include "romfs.h"
 #include "sysv.h"
+#include "minix.h"
 #include "mac.h"
 #include "msdos.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_sysv(id, off) == 0)
                goto exit;
 
+       if (volume_id_probe_minix(id, off) == 0)
+               goto exit;
+
        return -1;
 
 exit:
        return -1;
 
 exit:
index 22bb3ea4872131267ec262d81bbd428a4a006c48..6719c1aa311f8c14e2480d6a2526ea3d47dc6320 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef _VOLUME_ID_H_
 #define _VOLUME_ID_H_
 
 #ifndef _VOLUME_ID_H_
 #define _VOLUME_ID_H_
 
-#define VOLUME_ID_VERSION              38
+#define VOLUME_ID_VERSION              39
 
 #define VOLUME_ID_LABEL_SIZE           64
 #define VOLUME_ID_UUID_SIZE            36
 
 #define VOLUME_ID_LABEL_SIZE           64
 #define VOLUME_ID_UUID_SIZE            36
index c12e88c3c413f39bda9016004c77fe14be62791d..653d7d0855a1766340f3fda2e41517d1ba0959de 100644 (file)
--- a/udev_db.c
+++ b/udev_db.c
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stddef.h>
 #include <stdio.h>
 #include <string.h>
 #include <stddef.h>
+#include <unistd.h>
 #include <fcntl.h>
 #include <string.h>
 #include <errno.h>
 #include <fcntl.h>
 #include <string.h>
 #include <errno.h>