X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=compat%2Flib%2Fbylabel.c;h=07f0dd92320ccb112b773a9eb54e44b1a826256c;hb=989f348a5757083e00a3bc75a6ce8fdbf834913b;hp=978a39d1d6ff358dc4c47151410a83c4943ca6b0;hpb=a23c5022421f8f7e2182300beb938167a3975286;p=dump.git diff --git a/compat/lib/bylabel.c b/compat/lib/bylabel.c index 978a39d..07f0dd9 100644 --- a/compat/lib/bylabel.c +++ b/compat/lib/bylabel.c @@ -11,6 +11,8 @@ * - Ported to dump/restore */ +#include +#include #include #include #include @@ -23,7 +25,10 @@ #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]; @@ -51,13 +56,13 @@ get_label_uuid(const char *device, char **label, char *uuid) { int fd; struct ext2_super_block e2sb; - fd = open(device, O_RDONLY); + fd = OPEN(device, O_RDONLY); 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; }