diff options
-rw-r--r-- | Makefile.in | 6 | ||||
-rw-r--r-- | lib/blkid/ChangeLog | 14 | ||||
-rw-r--r-- | lib/blkid/blkid.h | 1 | ||||
-rw-r--r-- | lib/blkid/read.c | 4 | ||||
-rw-r--r-- | lib/blkid/resolve.c | 20 | ||||
-rw-r--r-- | misc/ChangeLog | 10 | ||||
-rw-r--r-- | misc/Makefile.in | 38 | ||||
-rw-r--r-- | misc/base_device.c | 2 | ||||
-rw-r--r-- | misc/blkid.c | 12 | ||||
-rw-r--r-- | misc/fsck.c | 257 | ||||
-rw-r--r-- | misc/fsck.h | 3 | ||||
-rw-r--r-- | misc/fstype.c | 111 | ||||
-rw-r--r-- | misc/get_device_by_label.c | 492 | ||||
-rw-r--r-- | misc/get_device_by_label.h | 15 | ||||
-rw-r--r-- | misc/tune2fs.c | 9 | ||||
-rw-r--r-- | misc/util.c | 4 |
16 files changed, 205 insertions, 793 deletions
diff --git a/Makefile.in b/Makefile.in index 76de6c20..8557b538 100644 --- a/Makefile.in +++ b/Makefile.in @@ -15,7 +15,7 @@ LIB_SUBDIRS=lib/et lib/ss lib/e2p lib/ext2fs lib/uuid lib/blkid PROG_SUBDIRS=e2fsck $(DEBUGFS_DIR) misc $(RESIZE_DIR) tests/progs $(EVMS_DIR) SUBDIRS=util $(LIB_SUBDIRS) $(PROG_SUBDIRS) tests -SUBS= lib/ext2fs/ext2_types.h +SUBS= lib/ext2fs/ext2_types.h lib/blkid/blkid_types.h TAR=tar @@ -95,6 +95,10 @@ lib/ext2fs/ext2_types.h: $(DEP_SUBSTITUTE) $(srcdir)/lib/ext2fs/ext2_types.h.in $(SUBSTITUTE) $(srcdir)/lib/ext2fs/ext2_types.h.in \ > lib/ext2fs/ext2_types.h +lib/blkid/blkid_types.h: $(DEP_SUBSTITUTE) $(srcdir)/lib/blkid/blkid_types.h.in + $(SUBSTITUTE) $(srcdir)/lib/blkid/blkid_types.h.in \ + > lib/blkid/blkid_types.h + mostlyclean-local: $(RM) -f \#* *~ *.orig core MAKELOG diff --git a/lib/blkid/ChangeLog b/lib/blkid/ChangeLog index 9a055ae4..ef6f9681 100644 --- a/lib/blkid/ChangeLog +++ b/lib/blkid/ChangeLog @@ -1,3 +1,17 @@ +2003-03-01 Theodore Ts'o <tytso@mit.edu> + + * resolve.c (blkid_get_tag_value): If the passed-in cache is NULL, + then get and release a temporary cache as a convenience to + the calling application. + (blkid_get_devname): If the passed in token does not + contain an '=', and value is NULL, then return the passed + in token. + + * read.c (blkid_read_cache): Don't return 0 since blkid_read_cache + now returns void. + + * blkid.h: Add include of sys/types.h, since we use dev_t + 2003-02-27 Theodore Ts'o <tytso@mit.edu> * resolve.c (blkid_get_tag_value): Rename function (used to be diff --git a/lib/blkid/blkid.h b/lib/blkid/blkid.h index 48a36020..83e070fa 100644 --- a/lib/blkid/blkid.h +++ b/lib/blkid/blkid.h @@ -13,6 +13,7 @@ #ifndef _BLKID_BLKID_H #define _BLKID_BLKID_H +#include <sys/types.h> #include <blkid/blkid_types.h> #ifdef __cplusplus diff --git a/lib/blkid/read.c b/lib/blkid/read.c index 71618e3d..b07cf795 100644 --- a/lib/blkid/read.c +++ b/lib/blkid/read.c @@ -384,7 +384,7 @@ void blkid_read_cache(blkid_cache cache) * struct so that the cache can be populated. */ if ((fd = open(cache->bic_filename, O_RDONLY)) < 0) - return 0; + return; if (fstat(fd, &st) < 0) goto errout; if ((st.st_mtime == cache->bic_ftime) || @@ -426,7 +426,7 @@ void blkid_read_cache(blkid_cache cache) cache->bic_flags &= ~BLKID_BIC_FL_CHANGED; cache->bic_ftime = st.st_mtime; - return 0; + return; errout: close(fd); return; diff --git a/lib/blkid/resolve.c b/lib/blkid/resolve.c index b31bcd30..9e689c68 100644 --- a/lib/blkid/resolve.c +++ b/lib/blkid/resolve.c @@ -30,6 +30,7 @@ char *blkid_get_tag_value(blkid_cache cache, const char *tagname, { blkid_tag found; blkid_dev dev; + blkid_cache c = cache; char *ret = NULL; DBG(DEBUG_RESOLVE, printf("looking for %s on %s\n", tagname, devname)); @@ -37,12 +38,17 @@ char *blkid_get_tag_value(blkid_cache cache, const char *tagname, if (!devname) return NULL; - if ((dev = blkid_get_dev(cache, devname, BLKID_DEV_NORMAL)) && + if (!cache) { + if (blkid_get_cache(&c, NULL) < 0) + return NULL; + } + + if ((dev = blkid_get_dev(c, devname, BLKID_DEV_NORMAL)) && (found = blkid_find_tag_dev(dev, tagname))) ret = blkid_strdup(found->bit_val); if (!cache) - blkid_free_dev(dev); + blkid_put_cache(c); return ret; } @@ -64,16 +70,18 @@ char *blkid_get_devname(blkid_cache cache, const char *token, if (!token) return NULL; - DBG(DEBUG_RESOLVE, - printf("looking for %s%c%s %s\n", token, value ? '=' : ' ', - value ? value : "", cache ? "in cache" : "from disk")); - if (!cache) { if (blkid_get_cache(&c, NULL) < 0) return NULL; } + DBG(DEBUG_RESOLVE, + printf("looking for %s%s%s %s\n", token, value ? "=" : "", + value ? value : "", cache ? "in cache" : "from disk")); + if (!value) { + if (!strchr(token, '=')) + return blkid_strdup(token); blkid_parse_tag_string(token, &t, &v); if (!t || !v) goto errout; diff --git a/misc/ChangeLog b/misc/ChangeLog index c0bfa12e..d1c5dc5f 100644 --- a/misc/ChangeLog +++ b/misc/ChangeLog @@ -1,3 +1,13 @@ +2003-03-01 Theodore Ts'o <tytso@mit.edu> + + * fsck.c, util.c, tune2fs.c, Makefile.in: Use the blkid library + instead of the specialized functions in + get-device-by-label.c and fstype.c. + + * base_device.c (base_device): Take a const char* as an argument. + + * blkid.c: Remove deprecated -d option, + 2003-02-16 Theodore Ts'o <tytso@mit.edu> * blkid.c: Update to reflect renaming of blkid_get_devname() to diff --git a/misc/Makefile.in b/misc/Makefile.in index 78a8c282..8263a255 100644 --- a/misc/Makefile.in +++ b/misc/Makefile.in @@ -22,22 +22,22 @@ SMANPAGES= tune2fs.8 mklost+found.8 mke2fs.8 dumpe2fs.8 badblocks.8 \ UPROGS= chattr lsattr uuidgen UMANPAGES= chattr.1 lsattr.1 uuidgen.1 -TUNE2FS_OBJS= tune2fs.o util.o get_device_by_label.o +TUNE2FS_OBJS= tune2fs.o util.o MKLPF_OBJS= mklost+found.o -MKE2FS_OBJS= mke2fs.o util.o get_device_by_label.o +MKE2FS_OBJS= mke2fs.o util.o CHATTR_OBJS= chattr.o LSATTR_OBJS= lsattr.o UUIDGEN_OBJS= uuidgen.o DUMPE2FS_OBJS= dumpe2fs.o BADBLOCKS_OBJS= badblocks.o E2IMAGE_OBJS= e2image.o -FSCK_OBJS= fsck.o get_device_by_label.o base_device.o fstype.o +FSCK_OBJS= fsck.o base_device.o BLKID_OBJS= blkid.o SRCS= $(srcdir)/tune2fs.c $(srcdir)/mklost+found.c $(srcdir)/mke2fs.c \ $(srcdir)/chattr.c $(srcdir)/lsattr.c $(srcdir)/dumpe2fs.c \ $(srcdir)/badblocks.c $(srcdir)/fsck.c $(srcdir)/util.c \ - $(srcdir)/uuidgen.c $(srcdir)/fstype.c $(srcdir)/blkid.c + $(srcdir)/uuidgen.c $(srcdir)/blkid.c LIBS= $(LIBEXT2FS) $(LIBCOM_ERR) DEPLIBS= $(LIBEXT2FS) $(LIBCOM_ERR) @@ -59,8 +59,9 @@ all:: $(SPROGS) $(UPROGS) $(USPROGS) $(SMANPAGES) $(UMANPAGES) findsuper: findsuper.o $(CC) $(ALL_LDFLAGS) -o findsuper findsuper.o -tune2fs: $(TUNE2FS_OBJS) $(DEPLIBS_E2P) $(DEPLIBUUID) - $(CC) $(ALL_LDFLAGS) -o tune2fs $(TUNE2FS_OBJS) $(LIBS_E2P) $(LIBUUID) +tune2fs: $(TUNE2FS_OBJS) $(DEPLIBS_E2P) $(DEPLIBUUID) $(DEPLIBS_BLKID) + $(CC) $(ALL_LDFLAGS) -o tune2fs $(TUNE2FS_OBJS) $(LIBS_BLKID) \ + $(LIBS_E2P) $(LIBUUID) blkid: $(BLKID_OBJS) $(DEPLIBS_E2P) $(DEPLIBS_BLKID) $(CC) $(ALL_LDFLAGS) -o blkid $(BLKID_OBJS) $(LIBS_E2P) $(LIBS_BLKID) @@ -72,10 +73,6 @@ base_device: base_device.c $(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(srcdir)/base_device.c \ -DDEBUG -o base_device -fstype: fstype.c - $(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) -DTEST_PROGRAM $(srcdir)/fstype.c \ - get_device_by_label.o $(LIBUUID) $(LIBS) -o fstype - check:: base_device ./base_device < $(srcdir)/base_device.tst > base_device.out cmp $(srcdir)/base_device.tst base_device.out @@ -83,8 +80,9 @@ check:: base_device mklost+found: $(MKLPF_OBJS) $(CC) $(ALL_LDFLAGS) -o mklost+found $(MKLPF_OBJS) -mke2fs: $(MKE2FS_OBJS) $(DEPLIBS) $(LIBE2P) $(DEPLIBUUID) - $(CC) $(ALL_LDFLAGS) -o mke2fs $(MKE2FS_OBJS) $(LIBS) $(LIBE2P) $(LIBUUID) +mke2fs: $(MKE2FS_OBJS) $(DEPLIBS) $(LIBE2P) $(DEPLIBUUID) $(DEPLIBS_BLKID) + $(CC) $(ALL_LDFLAGS) -o mke2fs $(MKE2FS_OBJS) $(LIBS) $(LIBS_BLKID) \ + $(LIBE2P) $(LIBUUID) mke2fs.static: $(MKE2FS_OBJS) $(STATIC_DEPLIBS) $(STATIC_LIBE2P) $(DEPSTATIC_LIBUUID) $(CC) $(ALL_LDFLAGS) -static -o mke2fs.static $(MKE2FS_OBJS) \ @@ -105,8 +103,8 @@ uuidgen: $(UUIDGEN_OBJS) $(DEPLIBUUID) dumpe2fs: $(DUMPE2FS_OBJS) $(DEPLIBS_E2P) $(DEPLIBUUID) $(CC) $(ALL_LDFLAGS) -o dumpe2fs $(DUMPE2FS_OBJS) $(LIBS_E2P) $(LIBUUID) -fsck: $(FSCK_OBJS) - $(CC) $(ALL_LDFLAGS) -o fsck $(FSCK_OBJS) $(LIBS) +fsck: $(FSCK_OBJS) $(DEBLIBS_BLKID) + $(CC) $(ALL_LDFLAGS) -o fsck $(FSCK_OBJS) $(LIBS) $(LIBS_BLKID) badblocks: $(BADBLOCKS_OBJS) $(DEPLIBS) $(CC) $(ALL_LDFLAGS) -o badblocks $(BADBLOCKS_OBJS) $(LIBS) @@ -236,7 +234,8 @@ tune2fs.o: $(srcdir)/tune2fs.c $(top_srcdir)/lib/ext2fs/ext2_fs.h \ $(top_srcdir)/lib/uuid/uuid.h $(top_srcdir)/lib/e2p/e2p.h \ $(srcdir)/jfs_user.h $(top_srcdir)/lib/ext2fs/kernel-jbd.h \ $(top_srcdir)/lib/ext2fs/jfs_compat.h $(top_srcdir)/lib/ext2fs/kernel-list.h \ - $(srcdir)/util.h $(srcdir)/get_device_by_label.h $(top_srcdir)/version.h \ + $(srcdir)/util.h $(top_srcdir)/lib/blkid/blkid.h \ + $(top_builddir)/lib/blkid/blkid_types.h $(top_srcdir)/version.h \ $(srcdir)/nls-enable.h mklost+found.o: $(srcdir)/mklost+found.c $(top_srcdir)/lib/ext2fs/ext2_fs.h \ $(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/version.h \ @@ -267,13 +266,16 @@ badblocks.o: $(srcdir)/badblocks.c $(top_srcdir)/lib/et/com_err.h \ $(top_builddir)/lib/ext2fs/ext2_err.h $(top_srcdir)/lib/ext2fs/bitops.h \ $(srcdir)/nls-enable.h fsck.o: $(srcdir)/fsck.c $(top_srcdir)/version.h $(srcdir)/nls-enable.h \ - $(srcdir)/fsck.h $(srcdir)/get_device_by_label.h + $(srcdir)/fsck.h $(top_srcdir)/lib/blkid/blkid.h \ + $(top_builddir)/lib/blkid/blkid_types.h util.o: $(srcdir)/util.c $(top_srcdir)/lib/et/com_err.h \ $(top_srcdir)/lib/e2p/e2p.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \ $(top_builddir)/lib/ext2fs/ext2_types.h $(top_srcdir)/lib/ext2fs/ext2fs.h \ $(top_srcdir)/lib/ext2fs/ext2_io.h $(top_builddir)/lib/ext2fs/ext2_err.h \ $(top_srcdir)/lib/ext2fs/bitops.h $(srcdir)/nls-enable.h \ - $(srcdir)/get_device_by_label.h $(srcdir)/util.h + $(top_srcdir)/lib/blkid/blkid.h $(top_builddir)/lib/blkid/blkid_types.h \ + $(srcdir)/util.h uuidgen.o: $(srcdir)/uuidgen.c $(top_srcdir)/lib/uuid/uuid.h \ $(srcdir)/nls-enable.h -fstype.o: $(srcdir)/fstype.c $(srcdir)/fsck.h +blkid.o: $(srcdir)/blkid.c $(top_srcdir)/lib/blkid/blkid.h \ + $(top_builddir)/lib/blkid/blkid_types.h diff --git a/misc/base_device.c b/misc/base_device.c index 80cd0fad..6237d0e6 100644 --- a/misc/base_device.c +++ b/misc/base_device.c @@ -38,7 +38,7 @@ static const char *devfs_hier[] = { "host", "bus", "target", "lun", 0 }; -char *base_device(char *device) +char *base_device(const char *device) { char *str, *cp; const char **hier, *disk; diff --git a/misc/blkid.c b/misc/blkid.c index b88a1afa..84ae3dd5 100644 --- a/misc/blkid.c +++ b/misc/blkid.c @@ -50,7 +50,7 @@ static void print_tags(blkid_dev dev, char *show[], int numtag) { blkid_tag_iterate iter; const char *type, *value; - int i, first = 1, printed_type = 0; + int i, first = 1; if (!dev) return; @@ -90,16 +90,8 @@ int main(int argc, char **argv) int i; char c; - while ((c = getopt (argc, argv, "c:d:f:hps:t:w:v")) != EOF) + while ((c = getopt (argc, argv, "c:f:hps:t:w:v")) != EOF) switch (c) { - case 'd': /* deprecated */ - if (numdev >= sizeof(devices) / sizeof(*devices)) { - fprintf(stderr, - "Too many devices specified\n"); - usage(err); - } - devices[numdev++] = optarg; - break; case 'c': if (optarg && !*optarg) read = NULL; diff --git a/misc/fsck.c b/misc/fsck.c index c6df8451..86f2406b 100644 --- a/misc/fsck.c +++ b/misc/fsck.c @@ -55,7 +55,7 @@ #include "../version.h" #include "nls-enable.h" #include "fsck.h" -#include "get_device_by_label.h" +#include "blkid/blkid.h" #ifndef _PATH_MNTTAB #define _PATH_MNTTAB "/etc/fstab" @@ -104,10 +104,24 @@ volatile int cancel_requested = 0; int kill_sent = 0; char *progname; char *fstype = NULL; -struct fs_info *filesys_info; +struct fs_info *filesys_info = NULL, *filesys_last = NULL; struct fsck_instance *instance_list; const char *fsck_prefix_path = "/sbin:/sbin/fs.d:/sbin/fs:/etc/fs:/etc"; char *fsck_path = 0; +blkid_cache cache = NULL; + +static char *string_copy(const char *s) +{ + char *ret; + + if (!s) + return 0; + ret = malloc(strlen(s)+1); + if (ret) + strcpy(ret, s); + return ret; +} + static int ignore(struct fs_info *); static char *skip_over_blank(char *cp) @@ -158,6 +172,9 @@ static void parse_escape(char *word) char *p, *q; int ac, i; + if (!word) + return; + for (p = word, q = word; *p; p++, q++) { *q = *p; if (*p != '\\') @@ -200,9 +217,39 @@ static void free_instance(struct fsck_instance *i) return; } +static struct fs_info *create_fs_device(char *device, char *mntpnt, + char *type, char *opts, int freq, + int passno) +{ + struct fs_info *fs; + + if (!(fs = malloc(sizeof(struct fs_info)))) + return NULL; + + fs->device = string_copy(device); + fs->mountpt = string_copy(mntpnt); + fs->type = string_copy(type); + fs->opts = string_copy(opts ? opts : ""); + fs->freq = freq; + fs->passno = passno; + fs->flags = 0; + fs->next = NULL; + + if (!filesys_info) + filesys_info = fs; + else + filesys_last->next = fs; + filesys_last = fs; + + return fs; +} + + + static int parse_fstab_line(char *line, struct fs_info **ret_fs) { - char *device, *mntpnt, *type, *opts, *freq, *passno, *cp; + char *dev, *device, *mntpnt, *type, *opts, *freq, *passno, *cp; + char *t = NULL; struct fs_info *fs; *ret_fs = 0; @@ -218,6 +265,12 @@ static int parse_fstab_line(char *line, struct fs_info **ret_fs) freq = parse_word(&cp); passno = parse_word(&cp); + if (!device) + return 0; /* Allow blank lines */ + + if (!mntpnt || !type) + return -1; + parse_escape(device); parse_escape(mntpnt); parse_escape(type); @@ -225,86 +278,30 @@ static int parse_fstab_line(char *line, struct fs_info **ret_fs) parse_escape(freq); parse_escape(passno); - if (!device) - return 0; /* Allow blank lines */ - - if (!mntpnt || !type) - return -1; + dev = blkid_get_devname(cache, device, NULL); + if (dev) + device = dev; - if (!(fs = malloc(sizeof(struct fs_info)))) + if (strcmp(type, "auto") == 0 || (strchr(type, ',') != 0)) + t = blkid_get_tag_value(cache, "TYPE", device); + if (t) + type = t; + + fs = create_fs_device(device, mntpnt, type, opts, + freq ? atoi(freq) : -1, + passno ? atoi(passno) : -1); + if (dev) + free(dev); + if (t) + free(t); + + if (!fs) return -1; - - fs->device = string_copy(device); - fs->mountpt = string_copy(mntpnt); - fs->type = string_copy(type); - fs->opts = string_copy(opts ? opts : ""); - fs->freq = freq ? atoi(freq) : -1; - fs->passno = passno ? atoi(passno) : -1; - fs->flags = 0; - fs->next = NULL; - *ret_fs = fs; - return 0; } /* - * Interpret the device name if necessary - */ -static char *interpret_device(char *spec) -{ - char *dev = interpret_spec(spec); - - if (dev) - return dev; - - /* - * Check to see if this was because /proc/partitions isn't - * found. - */ - if (access("/proc/partitions", R_OK) < 0) { - fprintf(stderr, "Couldn't open /proc/partitions: %s\n", - strerror(errno)); - fprintf(stderr, "Is /proc mounted?\n"); - exit(EXIT_ERROR); - } - /* - * Check to see if this is because we're not running as root - */ - if (geteuid()) - fprintf(stderr, - "Must be root to scan for matching filesystems: %s\n", - spec); - else - fprintf(stderr, "Couldn't find matching filesystem: %s\n", - spec); - exit(EXIT_ERROR); -} - -/* - * Interpret filesystem auto type if necessary - */ -static void interpret_type(struct fs_info *fs) -{ - const char *type; - - if (strcmp(fs->type, "auto") == 0 || - (strchr(fs->type, ',') != 0)) { - if (fs && strchr(fs->device, '=')) - fs->device = interpret_device(fs->device); - type = identify_fs(fs->device, fs->type); - if (type) { - free(fs->type); - fs->type = string_copy(type); - } else - fprintf(stderr, _("Could not determine " - "filesystem type for %s\n"), - fs->device); - } -} - - -/* * Load the filesystem database from /etc/fstab */ static void load_fs_info(const char *filename) @@ -313,9 +310,8 @@ static void load_fs_info(const char *filename) char buf[1024]; int lineno = 0; int old_fstab = 1; - struct fs_info *fs, *fs_last = NULL; + struct fs_info *fs; - filesys_info = NULL; if ((f = fopen(filename, "r")) == NULL) { fprintf(stderr, _("WARNING: couldn't open %s: %s\n"), filename, strerror(errno)); @@ -333,11 +329,6 @@ static void load_fs_info(const char *filename) } if (!fs) continue; - if (!filesys_info) - filesys_info = fs; - else - fs_last->next = fs; - fs_last = fs; if (fs->passno < 0) fs->passno = 0; else @@ -369,22 +360,8 @@ static struct fs_info *lookup(char *filesys) return NULL; for (fs = filesys_info; fs; fs = fs->next) { - if (strchr(fs->device, '=')) - try_again++; - if (!strcmp(filesys, fs->device) || - !strcmp(filesys, fs->mountpt)) - break; - } - if (fs && strchr(fs->device, '=')) - fs->device = interpret_device(fs->device); - - if (fs || !try_again) - return fs; - - for (fs = filesys_info; fs; fs = fs->next) { - fs->device = interpret_device(fs->device); if (!strcmp(filesys, fs->device) || - !strcmp(filesys, fs->mountpt)) + (fs->mountpt && !strcmp(filesys, fs->mountpt))) break; } @@ -428,7 +405,7 @@ static int progress_active(NOARGS) * Execute a particular fsck program, and link it into the list of * child processes we are waiting for. */ -static int execute(const char *type, char *device, char *mntpt, +static int execute(const char *type, const char *device, const char *mntpt, int interactive) { char *s, *argv[80], prog[80]; @@ -674,10 +651,9 @@ static int wait_all(int flags) * If the type isn't specified by the user, then use either the type * specified in /etc/fstab, or DEFAULT_FSTYPE. */ -static void fsck_device(char *device, int interactive) +static void fsck_device(struct fs_info *fs, int interactive) { const char *type = 0; - struct fs_info *fsent; int retval; if (fstype && strncmp(fstype, "no", 2) && @@ -685,21 +661,13 @@ static void fsck_device(char *device, int interactive) !strchr(fstype, ',')) type = fstype; - if ((fsent = lookup(device))) { - device = fsent->device; - interpret_type(fsent); - if (!type) - type = fsent->type; - } - if (!type) - type = DEFAULT_FSTYPE; + type = fs->type ? fs->type : DEFAULT_FSTYPE; num_running++; - retval = execute(type, device, fsent ? fsent->mountpt : 0, - interactive); + retval = execute(type, fs->device, fs->mountpt, interactive); if (retval) { fprintf(stderr, _("%s: Error %d while executing fsck.%s " - "for %s\n"), progname, retval, type, device); + "for %s\n"), progname, retval, type, fs->device); num_running--; } } @@ -856,8 +824,6 @@ static int ignore(struct fs_info *fs) if (fs->passno == 0) return 1; - interpret_type(fs); - /* * If a specific fstype is specified, and it doesn't match, * ignore it. @@ -944,8 +910,6 @@ static int check_all(NOARGS) for (fs = filesys_info; fs; fs = fs->next) { if (ignore(fs)) fs->flags |= FLAG_DONE; - else - fs->device = interpret_device(fs->device); } /* @@ -958,7 +922,7 @@ static int check_all(NOARGS) } if (fs) { if (!skip_root && !ignore(fs)) { - fsck_device(fs->device, 1); + fsck_device(fs, 1); status |= wait_all(0); if (status > EXIT_NONDESTRUCT) return status; @@ -1005,7 +969,7 @@ static int check_all(NOARGS) /* * Spawn off the fsck process */ - fsck_device(fs->device, serialize); + fsck_device(fs, serialize); fs->flags |= FLAG_DONE; /* @@ -1056,7 +1020,7 @@ static void signal_cancel(int sig) static void PRS(int argc, char *argv[]) { int i, j; - char *arg, *tmp; + char *arg, *dev, *tmp = 0; char options[128]; int opt = 0; int opts_for_fsck = 0; @@ -1082,16 +1046,37 @@ static void PRS(int argc, char *argv[]) arg = argv[i]; if (!arg) continue; - if ((arg[0] == '/' && !opts_for_fsck) || - (strncmp(arg, "LABEL=", 6) == 0) || - (strncmp(arg, "UUID=", 5) == 0)) { + if ((arg[0] == '/' && !opts_for_fsck) || strchr(arg, '=')) { if (num_devices >= MAX_DEVICES) { fprintf(stderr, _("%s: too many devices\n"), progname); exit(EXIT_ERROR); } - devices[num_devices++] = - interpret_device(string_copy(arg)); + dev = blkid_get_devname(cache, arg, NULL); + if (!dev && strchr(arg, '=')) { + /* + * Check to see if we failed because + * /proc/partitions isn't found. + */ + if (access("/proc/partitions", R_OK) < 0) { + fprintf(stderr, "Couldn't open /proc/partitions: %s\n", + strerror(errno)); + fprintf(stderr, "Is /proc mounted?\n"); + exit(EXIT_ERROR); + } + /* + * Check to see if this is because + * we're not running as root + */ + if (geteuid()) + fprintf(stderr, + "Must be root to scan for matching filesystems: %s\n", arg); + else + fprintf(stderr, + "Couldn't find matching filesystem: %s\n", arg); + exit(EXIT_ERROR); + } + devices[num_devices++] = dev ? dev : string_copy(arg); continue; } if (arg[0] != '-' || opts_for_fsck) { @@ -1181,11 +1166,11 @@ static void PRS(int argc, char *argv[]) int main(int argc, char *argv[]) { - int i; - int status = 0; + int i, status = 0; int interactive = 0; - char *oldpath = getenv("PATH"); + char *type, *oldpath = getenv("PATH"); const char *fstab; + struct fs_info *fs; #ifdef ENABLE_NLS setlocale(LC_MESSAGES, ""); @@ -1193,6 +1178,7 @@ int main(int argc, char *argv[]) bindtextdomain(NLS_CAT_NAME, LOCALEDIR); textdomain(NLS_CAT_NAME); #endif + blkid_get_cache(&cache, NULL); PRS(argc, argv); if (!notitle) @@ -1234,7 +1220,21 @@ int main(int argc, char *argv[]) } break; } - fsck_device(devices[i], interactive); + fs = lookup(devices[i]); + if (!fs) { + type = blkid_get_tag_value(cache, "TYPE", devices[i]); + if (!type) { + fprintf(stderr, _("Could not determine " + "filesystem type for %s\n"), + devices[i]); + continue; + } + fs = create_fs_device(devices[i], 0, type, 0, -1, -1); + free(type); + if (!fs) + continue; + } + fsck_device(fs, interactive); if (serialize || (max_running && (num_running >= max_running))) { struct fsck_instance *inst; @@ -1250,5 +1250,6 @@ int main(int argc, char *argv[]) } status |= wait_all(0); free(fsck_path); + blkid_put_cache(cache); return status; } diff --git a/misc/fsck.h b/misc/fsck.h index a4baaaef..56afcf98 100644 --- a/misc/fsck.h +++ b/misc/fsck.h @@ -59,6 +59,5 @@ struct fsck_instance { struct fsck_instance *next; }; -extern char *base_device(char *device); -extern char *string_copy(const char *s); +extern char *base_device(const char *device); extern const char *identify_fs(const char *fs_name, const char *fs_types); diff --git a/misc/fstype.c b/misc/fstype.c deleted file mode 100644 index 8b5f9aa2..00000000 --- a/misc/fstype.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - * fstype.c - * - * Copyright (C) 2001 Theodore Ts'o. - * - * %Begin-Header% - * This file may be redistributed under the terms of the GNU Public - * License. - * %End-Header% - */ - -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#if HAVE_UNISTD_H -#include <unistd.h> -#endif -#include <fcntl.h> -#include <sys/types.h> - -#include "fsck.h" - -struct fs_magic { - const char *fs_name; - int offset; - int len; - const char *magic; -}; - -#define REISERFS_SUPER_MAGIC_STRING "ReIsErFs" -#define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs" -#define REISERFS_DISK_OFFSET_IN_BYTES ((64 * 1024) + 52) -/* the spot for the super in versions 3.5 - 3.5.10 (inclusive) */ -#define REISERFS_OLD_DISK_OFFSET_IN_BYTES ((8 * 1024) + 52) - -struct fs_magic type_array[] = { - { "ext2", 1024+56, 2, "\123\357" }, - { "ext3", 1024+56, 2, "\123\357" }, - { "reiserfs", REISERFS_DISK_OFFSET_IN_BYTES, 9, - REISER2FS_SUPER_MAGIC_STRING }, - { "reiserfs", REISERFS_DISK_OFFSET_IN_BYTES, 8, - REISERFS_SUPER_MAGIC_STRING }, - { "reiserfs", REISERFS_OLD_DISK_OFFSET_IN_BYTES, 9, - REISER2FS_SUPER_MAGIC_STRING }, - { "reiserfs", REISERFS_OLD_DISK_OFFSET_IN_BYTES, 8, - REISERFS_SUPER_MAGIC_STRING }, - { "minix", 1040, 2, "\177\023" }, - { "minix", 1040, 2, "\217\023" }, - { "minix", 1040, 2, "\150\044" }, - { "minix", 1040, 2, "\170\044" }, - { "xfs", 0, 4, "XFSB" }, - { 0, 0, 0, 0 } -}; - -const char *identify_fs(const char *fs_name, const char *fs_types) -{ - char buf[73728], *s; - const char *t; - struct fs_magic *p; - int fd; - - fd = open(fs_name, O_RDONLY); - if (fd < 0) - return NULL; - if (lseek(fd, 0, SEEK_SET) < 0) - return NULL; - if (read(fd, buf, sizeof(buf)) != sizeof(buf)) - return NULL; - close(fd); - if (!fs_types || !strcmp(fs_types, "auto")) { - for (p = type_array; p->fs_name; p++) { - if (memcmp(p->magic, buf+p->offset, p->len) == 0) - return p->fs_name; - } - } else { - s = string_copy(fs_types); - for (t = strtok(s, ","); t; t = strtok(NULL, ",")) { - for (p = type_array; p->fs_name; p++) { - if (strcmp(p->fs_name, t)) - continue; - if (memcmp(p->magic, buf+p->offset, - p->len) == 0) { - free(s); - return p->fs_name; - } - } - } - free(s); - } - return NULL; -} - -#ifdef TEST_PROGRAM -int main(int argc, char **argv) -{ - const char *type; - - if (argc < 2 || argc > 3) { - fprintf(stderr, "Usage: %s [type list] device\n", argv[0]); - exit(1); - } - if (argc == 2) { - type = identify_fs(argv[1], NULL); - printf("%s is a %s filesystem\n", argv[1], type); - } else { - type = identify_fs(argv[2],argv[1]); - printf("%s is a %s filesystem\n", argv[2], type); - } - return (0); -} -#endif diff --git a/misc/get_device_by_label.c b/misc/get_device_by_label.c deleted file mode 100644 index cde85a76..00000000 --- a/misc/get_device_by_label.c +++ /dev/null @@ -1,492 +0,0 @@ -/* - * get_device_by_label.h - * - * Copyright 1999 by Andries Brouwer - * Copyright 1999, 2000 by Theodore Ts'o - * - * This file may be redistributed under the terms of the GNU Public - * License. - * - * Taken from aeb's mount, 990619 - * Updated from aeb's mount, 20000725 - * Added call to ext2fs_find_block_device, so that we can find devices - * even if devfs (ugh) is compiled in, but not mounted, since - * this messes up /proc/partitions, by TYT. - */ - -#include <stdio.h> -#include <string.h> -#include <stdlib.h> -#include <ctype.h> -#include <fcntl.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/stat.h> -#ifdef HAVE_SYS_MKDEV_H -#include <sys/mkdev.h> -#endif -#ifdef HAVE_SYS_SYSMACROS_H -#include <sys/sysmacros.h> -#endif -#include <dirent.h> -#include "nls-enable.h" -#include "fsck.h" -#include "get_device_by_label.h" - -/* function prototype from libext2 */ -extern char *ext2fs_find_block_device(dev_t device); - -#define PROC_PARTITIONS "/proc/partitions" -#define PROC_EVMS_VOLUMES "/proc/evms/volumes" -#define DEVLABELDIR "/dev" -#define VG_DIR "/proc/lvm/VGs" - -#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)) - -#define XFS_SUPER_MAGIC "XFSB" -struct xfs_super_block { - unsigned char s_magic[4]; - unsigned char s_dummy[28]; - unsigned char s_uuid[16]; - unsigned char s_dummy2[60]; - unsigned char s_fname[12]; -}; - -struct reiserfs_super_block -{ - /* Following entries are based on reiserfsutils 3.6.3 - * (Copyright Hans Reiser) since Linux kernel headers - * (2.4.18) seemed not up-to-date. */ - unsigned char s_dummy1[52]; - unsigned char s_magic[10]; - unsigned char s_dummy2[10]; - unsigned char s_version[2]; - unsigned char s_dummy3[10]; - unsigned char s_uuid[16]; - unsigned char s_label[16]; - unsigned char s_unused[88]; -}; - -#define REISER2FS_SUPER_MAGIC_STRING "ReIsEr2Fs" /* v. 3.6 */ -#define REISER3FS_SUPER_MAGIC_STRING "ReIsEr3Fs" /* Journal Relocation */ -#define REISERFS_DISK_OFFSET_IN_BYTES (64 * 1024) -/* the spot for the super in versions 3.5 - 3.5.10 (inclusive) - - * We'll use it in case volume has been converted. */ -#define REISERFS_OLD_DISK_OFFSET_IN_BYTES (8 * 1024) -#define reiserversion(s) ((unsigned) (s).s_version[0] + (((unsigned) (s).s_version[1]) << 8)) - -/* We're checking for ReiserFS v. 3.6 and RJ 3.6 SB */ -static int -reiser_supports_uuid (struct reiserfs_super_block *sb) -{ - return (strncmp(sb->s_magic, REISER2FS_SUPER_MAGIC_STRING, - strlen (REISER2FS_SUPER_MAGIC_STRING)) == 0) - || (strncmp(sb->s_magic, REISER3FS_SUPER_MAGIC_STRING, - strlen (REISER3FS_SUPER_MAGIC_STRING)) == 0 - && reiserversion(*sb) == 2); -} - -static struct uuidCache_s { - struct uuidCache_s *next; - char uuid[16]; - char *label; - char *device; -} *uuidCache = NULL; - -char *string_copy(const char *s) -{ - char *ret; - - ret = malloc(strlen(s)+1); - if (ret) - strcpy(ret, s); - return ret; -} - -/* for now, only ext2, ext3, xfs and ReiserFS are supported */ -static int -get_label_uuid(const char *device, char **label, char *uuid) { - - /* start with ext2/3, xfs and ReiserFS tests, taken from mount_guess_fstype */ - /* should merge these later */ - int fd; - size_t label_size; - unsigned char *sb_uuid = 0, *sb_label = 0; - struct ext2_super_block e2sb; - struct xfs_super_block xfsb; - struct reiserfs_super_block rfsb; - - 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)) { - sb_uuid = e2sb.s_uuid; - sb_label = e2sb.s_volume_name; - label_size = sizeof(e2sb.s_volume_name); - } else if (lseek(fd, 0, SEEK_SET) == 0 - && read(fd, (char *) &xfsb, sizeof(xfsb)) == sizeof(xfsb) - && strncmp((char *) &xfsb.s_magic, XFS_SUPER_MAGIC, 4) == 0) { - sb_uuid = xfsb.s_uuid; - sb_label = xfsb.s_fname; - label_size = sizeof(xfsb.s_fname); - } else if ((lseek(fd, REISERFS_OLD_DISK_OFFSET_IN_BYTES, SEEK_SET) - == REISERFS_OLD_DISK_OFFSET_IN_BYTES - && read(fd, (char *) &rfsb, sizeof(rfsb)) == sizeof(rfsb) - && (reiser_supports_uuid(&rfsb))) - || (lseek(fd, REISERFS_DISK_OFFSET_IN_BYTES, SEEK_SET) - == REISERFS_DISK_OFFSET_IN_BYTES - && read(fd, (char *) &rfsb, sizeof(rfsb)) == sizeof(rfsb) - && (reiser_supports_uuid(&rfsb)))) { - sb_uuid = rfsb.s_uuid; - sb_label = rfsb.s_label; - label_size = sizeof(rfsb.s_label); - } else { - close(fd); - return 1; - } - - close(fd); - if (sb_uuid) - memcpy(uuid, sb_uuid, sizeof(e2sb.s_uuid)); - if (sb_label) { - if ((*label = calloc(label_size + 1, 1)) != NULL) - memcpy(*label, sb_label, label_size); - } - return 0; -} - -#define CBBUF (16 * 1024) - -static void -uuidcache_addentry(char *device, char *label, char *uuid) { - struct uuidCache_s *last; - - if (!uuidCache) { - last = uuidCache = malloc(sizeof(*uuidCache)); - } else { - for (last = uuidCache; last->next; last = last->next) ; - last->next = malloc(sizeof(*uuidCache)); - last = last->next; - } - last->next = NULL; - last->device = device; - last->label = label; - memcpy(last->uuid, uuid, sizeof(last->uuid)); -} - -/* - * This function initializes the UUID cache with devices from the LVM - * proc hierarchy. We currently depend on the names of the LVM - * hierarchy giving us the device structure in /dev. (XXX is this a - * safe thing to do?) - */ -#ifdef VG_DIR -static void init_lvm(void) -{ - DIR *vg_dir, *lv_list; - char *vdirname, *lvm_device; - char uuid[16], *label, *vname, *lname; - struct dirent *vg_iter, *lv_iter; - - if ((vg_dir = opendir(VG_DIR)) == NULL) - return; - - while ((vg_iter = readdir(vg_dir)) != 0) { - vname = vg_iter->d_name; - if (!strcmp(vname, ".") || !strcmp(vname, "..")) - continue; - vdirname = malloc(strlen(VG_DIR)+strlen(vname)+8); - if (!vdirname) { - closedir(vg_dir); - return; - } - sprintf(vdirname, "%s/%s/LVs", VG_DIR, vname); - - lv_list = opendir(vdirname); - free(vdirname); - if (lv_list == NULL) - return; - - while ((lv_iter = readdir(lv_list)) != 0) { - lname = lv_iter->d_name; - if (!strcmp(lname, ".") || !strcmp(lname, "..")) - continue; - - lvm_device = malloc(strlen(DEVLABELDIR) + - strlen(vname)+ - strlen(lname)+8); - if (!lvm_device) { - closedir(lv_list); - closedir(vg_dir); - return; - } - sprintf(lvm_device, "%s/%s/%s", DEVLABELDIR, - vname, lname); - if (!get_label_uuid(lvm_device, &label, uuid)) { - uuidcache_addentry(string_copy(lvm_device), - label, uuid); - } else - free(lvm_device); - } - closedir(lv_list); - } - closedir( vg_dir ); -} -#endif - -static void -read_partitions(void) -{ - char line[100]; - char *s; - int ma, mi, sz; - static char ptname[100]; - FILE *procpt; - char uuid[16], *label, *devname; - char device[110]; - dev_t dev; - struct stat statbuf; - int firstPass; - int handleOnFirst; - char *iobuf; - - procpt = fopen(PROC_PARTITIONS, "r"); - if (!procpt) - return; - - iobuf = (char *)malloc(CBBUF); - if (iobuf) - setvbuf(procpt, iobuf, _IOFBF, CBBUF); - - for (firstPass = 1; firstPass >= 0; firstPass--) { - fseek(procpt, 0, SEEK_SET); - - while (fgets(line, sizeof(line), procpt)) { - if (sscanf (line, " %d %d %d %[^\n ]", - &ma, &mi, &sz, ptname) != 4) - continue; - - /* skip extended partitions (heuristic: size 1) */ - if (sz == 1) - continue; - - /* look only at md devices on first pass */ - handleOnFirst = !strncmp(ptname, "md", 2); - if (firstPass != handleOnFirst) - continue; - - /* skip entire disk (minor 0, 64, ... on ide; - 0, 16, ... on sd) */ - /* heuristic: partition name ends in a digit */ - /* OR partition name starts with 'lvm' */ - - for(s = ptname; *s; s++); - if (isdigit(s[-1]) || !strncmp(ptname, "lvm", 3)) { - /* - * We first look in /dev for the device, but - * if we don't find it, or if the stat - * information doesn't check out, we use - * ext2fs_find_block_device to find it. - */ - sprintf(device, "%s/%s", DEVLABELDIR, ptname); - dev = makedev(ma, mi); - if ((stat(device, &statbuf) < 0) || - (statbuf.st_rdev != dev)) { - devname = ext2fs_find_block_device(dev); - } else - devname = string_copy(device); - if (!devname) - continue; -#ifdef DEBUG - printf("Checking partition %s (%d, %d)\n", - devname, ma, mi); -#endif - if (!get_label_uuid(devname, &label, uuid)) - uuidcache_addentry(devname, label, uuid); - else - free(devname); - } - } - } - - fclose(procpt); - if (iobuf) - free(iobuf); -} - -static void -read_evms(void) -{ - char line[100]; - int ma, mi, sz; - FILE *procpt; - char uuid[16], *label, *devname; - char device[110]; - dev_t dev; - struct stat statbuf; - - procpt = fopen(PROC_EVMS_VOLUMES, "r"); - if (!procpt) - return; - while (fgets(line, sizeof(line), procpt)) { - if (sscanf (line, " %d %d %d %*s %*s %[^\n ]", - &ma, &mi, &sz, device) != 4) - continue; - - /* - * We first look for the device in the named location, - * but if we don't find it, or if the stat information - * doesn't check out, we use ext2fs_find_block_device - * to find it. - */ - dev = makedev(ma, mi); - if ((stat(device, &statbuf) < 0) || (statbuf.st_rdev != dev)) { - devname = ext2fs_find_block_device(dev); - } else - devname = string_copy(device); - if (!devname) - continue; -#ifdef DEBUG - printf("Checking partition %s (%d, %d)\n", - devname, ma, mi); -#endif - if (!get_label_uuid(devname, &label, uuid)) - uuidcache_addentry(devname, label, uuid); - else - free(devname); - } - fclose(procpt); -} - -static void -uuidcache_init(void) -{ - if (uuidCache) - return; - -#ifdef VG_DIR - init_lvm(); -#endif - read_evms(); - read_partitions(); -} - -#define UUID 1 -#define VOL 2 - -static char * -get_spec_by_x(int n, const char *t) { - struct uuidCache_s *uc; - - uuidcache_init(); - uc = uuidCache; - - if (t == NULL) - return NULL; - - while(uc) { - switch (n) { - case UUID: - if (!memcmp(t, uc->uuid, sizeof(uc->uuid))) - return string_copy(uc->device); - break; - case VOL: - if (!strcmp(t, uc->label)) - return string_copy(uc->device); - break; - } - uc = uc->next; - } - return NULL; -} - -static char fromhex(char c) -{ - if (isdigit(c)) - return (c - '0'); - else if (islower(c)) - return (c - 'a' + 10); - else - return (c - 'A' + 10); -} - -char * -get_spec_by_uuid(const char *s) -{ - char uuid[16]; - int i; - - if (strlen(s) != 36 || - s[8] != '-' || s[13] != '-' || s[18] != '-' || s[23] != '-') - goto bad_uuid; - for (i=0; i<16; i++) { - if (*s == '-') s++; - if (!isxdigit(s[0]) || !isxdigit(s[1])) - goto bad_uuid; - uuid[i] = ((fromhex(s[0])<<4) | fromhex(s[1])); - s += 2; - } - return get_spec_by_x(UUID, uuid); - - bad_uuid: - fprintf(stderr, _("WARNING: %s: bad UUID\n"), s); - return NULL; -} - -char * -get_spec_by_volume_label(const char *s) { - return get_spec_by_x(VOL, s); -} - -const char * -get_volume_label_by_spec(const char *spec) { - struct uuidCache_s *uc; - - uuidcache_init(); - uc = uuidCache; - - while(uc) { - if (!strcmp(spec, uc->device)) - return uc->label; - uc = uc->next; - } - return NULL; -} - -/* - * Interpret the device name if necessary. - * Frees the pointer passed to it if we return a different device string. - */ -char *interpret_spec(char *spec) -{ - char *dev = NULL; - - if (!spec) - return NULL; - - if (!strncmp(spec, "UUID=", 5)) - dev = get_spec_by_uuid(spec+5); - else if (!strncmp(spec, "LABEL=", 6)) - dev = get_spec_by_volume_label(spec+6); - else - dev = string_copy(spec); - return dev; -} - -#ifdef DEBUG -main(int argc, char **argv) -{ - uuidcache_init(); -} -#endif diff --git a/misc/get_device_by_label.h b/misc/get_device_by_label.h deleted file mode 100644 index 516991fe..00000000 --- a/misc/get_device_by_label.h +++ /dev/null @@ -1,15 +0,0 @@ -/* - * get_device_by_label.h - * - * Copyright 1999 by Andries Brouwer - * Copyright 1999, 2000 by Theodore Ts'o - * - * This file may be redistributed under the terms of the GNU Public - * License. - */ - -extern char *string_copy(const char *s); -extern char *get_spec_by_uuid(const char *uuid); -extern char *get_spec_by_volume_label(const char *volumelabel); -extern const char *get_volume_label_by_spec(const char *spec); -extern char *interpret_spec(char *spec); diff --git a/misc/tune2fs.c b/misc/tune2fs.c index dd9f7247..9deba804 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -48,7 +48,7 @@ extern int optind; #include "e2p/e2p.h" #include "jfs_user.h" #include "util.h" -#include "get_device_by_label.h" +#include "blkid/blkid.h" #include "../version.h" #include "nls-enable.h" @@ -114,7 +114,7 @@ static void remove_journal_device(ext2_filsys fs) commit_remove_journal = 1; /* force removal even if error */ uuid_unparse(fs->super->s_journal_uuid, buf); - journal_path = get_spec_by_uuid(buf); + journal_path = blkid_get_devname(NULL, "UUID", buf); if (!journal_path) { journal_path = @@ -184,8 +184,7 @@ no_valid_journal: exit(1); } fs->super->s_journal_dev = 0; - memset(fs->super->s_journal_uuid, 0, - sizeof(fs->super->s_journal_uuid)); + uuid_clear(fs->super->s_journal_uuid); ext2fs_mark_super_dirty(fs); printf(_("Journal removed\n")); free(journal_path); @@ -678,7 +677,7 @@ void do_findfs(int argc, char **argv) fprintf(stderr, "Usage: findfs LABEL=<label>|UUID=<uuid>\n"); exit(2); } - dev = interpret_spec(argv[1]); + dev = blkid_get_devname(NULL, argv[1], NULL); if (!dev) { fprintf(stderr, "Filesystem matching %s not found\n", argv[1]); diff --git a/misc/util.c b/misc/util.c index 42e78b65..6dbeba1d 100644 --- a/misc/util.c +++ b/misc/util.c @@ -29,7 +29,7 @@ #include "ext2fs/ext2_fs.h" #include "ext2fs/ext2fs.h" #include "nls-enable.h" -#include "get_device_by_label.h" +#include "blkid/blkid.h" #include "util.h" #ifndef HAVE_STRCASECMP @@ -178,7 +178,7 @@ void parse_journal_opts(const char *opts) arg ? arg : "NONE"); #endif if (strcmp(token, "device") == 0) { - journal_device = interpret_spec(arg); + journal_device = blkid_get_devname(NULL, arg, NULL); if (!journal_device) { journal_usage++; continue; |