summaryrefslogtreecommitdiff
path: root/volume_id
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@vrfy.org>2005-02-25 17:21:48 +0000
committerKay Sievers <kay.sievers@vrfy.org>2005-02-25 17:21:48 +0000
commit05131cd539e2835d2b8ec930f953cd11d770e46f (patch)
tree47105afe9ffbd65cc29405cc8ed5c9cbbd766627 /volume_id
parentf7b467fff7aa641deb04ac0a93874e7190911165 (diff)
downloadhal-05131cd539e2835d2b8ec930f953cd11d770e46f.tar.gz
Move HAL specific logging to this file.
Remove unused stuff. Fix typo and copyright. Support reiser4. Include luks.h. Version 36. Remove HAL specific logging.
Diffstat (limited to 'volume_id')
-rw-r--r--volume_id/logging.h5
-rw-r--r--volume_id/luks.c7
-rw-r--r--volume_id/luks.h6
-rw-r--r--volume_id/reiserfs.c33
-rw-r--r--volume_id/volume_id.c1
-rw-r--r--volume_id/volume_id.h7
6 files changed, 37 insertions, 22 deletions
diff --git a/volume_id/logging.h b/volume_id/logging.h
index d74d61f0..e56d2c55 100644
--- a/volume_id/logging.h
+++ b/volume_id/logging.h
@@ -15,6 +15,11 @@
#include <config.h>
#endif
+/* User of this library is supposed to export the volume_id_log symbol
+ * if sources are built with -DDEBUG
+ */
+extern void volume_id_log (const char *format, ...);
+
#ifdef DEBUG
#define dbg(format, arg...) \
do { \
diff --git a/volume_id/luks.c b/volume_id/luks.c
index 11df5f88..20016927 100644
--- a/volume_id/luks.c
+++ b/volume_id/luks.c
@@ -40,10 +40,6 @@
#include "logging.h"
#include "luks.h"
-/* FIXME: this contains a lot of copy and pasted code. One alternative
- * would be to fork/exec cryptsetup isLuks and cryptsetup luksUUID. Another
- * would be to write a LUKS library */
-
/* from cryptsetup-luks internal.h */
#define SECTOR_SHIFT 9
#define SECTOR_SIZE (1 << SECTOR_SHIFT)
@@ -68,8 +64,6 @@ const unsigned char LUKS_MAGIC[] = {'L','U','K','S', 0xba, 0xbe};
int volume_id_probe_luks(struct volume_id *id, __u64 off)
{
- int i;
-
/* from cryptsetup-luks luks.h */
struct luks_phdr {
char magic[LUKS_MAGIC_L];
@@ -83,7 +77,6 @@ int volume_id_probe_luks(struct volume_id *id, __u64 off)
char mkDigestSalt[LUKS_SALTSIZE];
uint32_t mkDigestIterations;
char uuid[UUID_STRING_L];
-
struct {
uint32_t active;
diff --git a/volume_id/luks.h b/volume_id/luks.h
index 5d94bb70..180336f5 100644
--- a/volume_id/luks.h
+++ b/volume_id/luks.h
@@ -1,7 +1,7 @@
/*
* volume_id - reads filesystem label and uuid
*
- * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
+ * Copyright (C) 2005 W. Michael Petullo <mike@flyn.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -18,8 +18,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef _VOLUME_ID_EXT_
-#define _VOLUME_ID_EXT_
+#ifndef _VOLUME_ID_LUKS_
+#define _VOLUME_ID_LUKS_
extern int volume_id_probe_luks(struct volume_id *id, __u64 off);
diff --git a/volume_id/reiserfs.c b/volume_id/reiserfs.c
index b74b8ae5..094062db 100644
--- a/volume_id/reiserfs.c
+++ b/volume_id/reiserfs.c
@@ -2,6 +2,7 @@
* volume_id - reads filesystem label and uuid
*
* Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
+ * Copyright (C) 2005 Tobias Klauser <tklauser@access.unizh.ch>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -55,26 +56,45 @@ struct reiserfs_super_block {
__u8 label[16];
} __attribute__((__packed__));
+struct reiser4_super_block {
+ __u8 magic[16];
+ __u16 dummy[2];
+ __u8 uuid[16];
+ __u8 label[16];
+ __u64 dummy2;
+} __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 *rs;
+ struct reiser4_super_block *rs4;
+ __u8 *buf;
dbg("probing at offset %llu", off);
- rs = (struct reiserfs_super_block *) volume_id_get_buffer(id, off + REISERFS_SUPERBLOCK_OFFSET, 0x200);
- if (rs == NULL)
+ buf = volume_id_get_buffer(id, off + REISERFS_SUPERBLOCK_OFFSET, 0x200);
+ if (buf == NULL)
return -1;
+ rs = (struct reiserfs_super_block *) buf;;
if (memcmp(rs->magic, "ReIsEr2Fs", 9) == 0) {
strcpy(id->type_version, "3.6");
- goto found;
+ goto found_v3;
}
-
if (memcmp(rs->magic, "ReIsEr3Fs", 9) == 0) {
strcpy(id->type_version, "JR");
+ goto found_v3;
+ }
+
+ rs4 = (struct reiser4_super_block *) buf;
+ if (memcmp(rs4->magic, "ReIsEr4", 7) == 0) {
+ strcpy(id->type_version, "4");
+ volume_id_set_label_raw(id, rs4->label, 16);
+ volume_id_set_label_string(id, rs4->label, 16);
+ volume_id_set_uuid(id, rs4->uuid, UUID_DCE);
goto found;
}
@@ -84,16 +104,17 @@ int volume_id_probe_reiserfs(struct volume_id *id, __u64 off)
if (memcmp(rs->magic, "ReIsErFs", 8) == 0) {
strcpy(id->type_version, "3.5");
- goto found;
+ goto found_v3;
}
return -1;
-found:
+found_v3:
volume_id_set_label_raw(id, rs->label, 16);
volume_id_set_label_string(id, rs->label, 16);
volume_id_set_uuid(id, rs->uuid, UUID_DCE);
+found:
volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
id->type = "reiserfs";
diff --git a/volume_id/volume_id.c b/volume_id/volume_id.c
index af1cd762..f93cc911 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 "luks.h"
#include "mac.h"
#include "msdos.h"
diff --git a/volume_id/volume_id.h b/volume_id/volume_id.h
index d3e36077..8fe4c3a5 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 34
+#define VOLUME_ID_VERSION 36
#define VOLUME_ID_LABEL_SIZE 64
#define VOLUME_ID_UUID_SIZE 16
@@ -79,9 +79,4 @@ extern struct volume_id *volume_id_open_dev_t(dev_t devt);
extern int volume_id_probe_all(struct volume_id *id, unsigned long long off, unsigned long long size);
extern void volume_id_close(struct volume_id *id);
-/* User of this library is supposed to export the volume_id_log symbol
- * if sources are built with -DDEBUG
- */
-extern void volume_id_log (const char *format, ...);
-
#endif