X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=compat%2Flib%2Fbylabel.c;h=c91457d3d232d7b47ff0209dc2a7c0531c79d4c6;hb=1099d48c9c09059aade8605beddfa4ef98f575aa;hp=9cdd0e5da502524644ee1fe4fba7a9bb50a4a364;hpb=0f32247911303db183810b8781e907ed9dfdc652;p=dump.git diff --git a/compat/lib/bylabel.c b/compat/lib/bylabel.c index 9cdd0e5..c91457d 100644 --- a/compat/lib/bylabel.c +++ b/compat/lib/bylabel.c @@ -17,13 +17,22 @@ #include #include #include -#include -#include +#include #include "bylabel.h" #define PROC_PARTITIONS "/proc/partitions" #define DEVLABELDIR "/dev" +#define EXT2_SUPER_MAGIC 0xEF53 +struct ext2_super_block { + unsigned char s_dummy1[56]; + unsigned char s_magic[2]; + unsigned char s_dummy2[46]; + unsigned char s_uuid[16]; + unsigned char s_volume_name[16]; +}; +#define ext2magic(s) ((unsigned int) s.s_magic[0] + (((unsigned int) s.s_magic[1]) << 8)) + void msg __P((const char *fmt, ...)); static struct uuidCache_s { @@ -48,7 +57,7 @@ get_label_uuid(const char *device, char **label, char *uuid) { if (lseek(fd, 1024, SEEK_SET) != 1024 || read(fd, (char *) &e2sb, sizeof(e2sb)) != sizeof(e2sb) - || (e2sb.s_magic != EXT2_SUPER_MAGIC)) { + || (ext2magic(e2sb) != EXT2_SUPER_MAGIC)) { close(fd); return 1; } @@ -67,10 +76,10 @@ uuidcache_addentry(char *device, char *label, char *uuid) { struct uuidCache_s *last; if (!uuidCache) { - last = uuidCache = malloc(sizeof(*uuidCache)); + last = uuidCache = (struct uuidCache_s *)malloc(sizeof(*uuidCache)); } else { for (last = uuidCache; last->next; last = last->next) ; - last->next = malloc(sizeof(*uuidCache)); + last->next = (struct uuidCache_s *)malloc(sizeof(*uuidCache)); last = last->next; } last->next = NULL;