]> git.wh0rd.org - dump.git/blobdiff - compat/lib/bylabel.c
Andreas Dilger fixes (CPP, ext2 features, const char etc).
[dump.git] / compat / lib / bylabel.c
index 31bdd0d601746b66a31b477ff73461a040b18ed6..065d52985c5629ec810e53f2ae46953bf045b4c1 100644 (file)
 #define PROC_PARTITIONS "/proc/partitions"
 #define DEVLABELDIR    "/dev"
 
-#define EXT2_SUPER_MAGIC 0xEF53
+#define EXT2_SUPER_OFFSET      1024
+#define EXT2_SUPER_SIZE                sizeof(struct ext2_super_block)
+#define EXT2_SUPER_MAGIC       0xEF53
+
 struct ext2_super_block {
        unsigned char   s_dummy1[56];
        unsigned char   s_magic[2];
@@ -56,9 +59,9 @@ get_label_uuid(const char *device, char **label, char *uuid) {
        if (fd < 0)
                return 1;
 
-       if (lseek(fd, 1024, SEEK_SET) != 1024
-           || read(fd, (char *) &e2sb, sizeof(e2sb)) != sizeof(e2sb)
-           || (ext2magic(e2sb) != EXT2_SUPER_MAGIC)) {
+       if (lseek(fd, EXT2_SUPER_OFFSET, SEEK_SET) != EXT2_SUPER_OFFSET ||
+           read(fd, (char *) &e2sb, EXT2_SUPER_SIZE) != EXT2_SUPER_SIZE ||
+           ext2magic(e2sb) != EXT2_SUPER_MAGIC) {
                close(fd);
                return 1;
        }