2009-02-06 16:34:27 +01:00
|
|
|
Index: e2fsprogs-1.41.4/misc/Makefile.in
|
|
|
|
===================================================================
|
|
|
|
--- e2fsprogs-1.41.4.orig/misc/Makefile.in 2008-11-15 18:33:33.000000000 +0100
|
|
|
|
+++ e2fsprogs-1.41.4/misc/Makefile.in 2009-02-03 12:45:22.000000000 +0100
|
2008-09-05 20:13:55 +02:00
|
|
|
@@ -40,7 +40,7 @@ UUIDD_OBJS= uuidd.o
|
2006-12-19 00:15:45 +01:00
|
|
|
DUMPE2FS_OBJS= dumpe2fs.o
|
|
|
|
BADBLOCKS_OBJS= badblocks.o
|
|
|
|
E2IMAGE_OBJS= e2image.o
|
2008-03-07 20:27:55 +01:00
|
|
|
-FSCK_OBJS= fsck.o base_device.o ismounted.o
|
2008-09-05 20:13:55 +02:00
|
|
|
+FSCK_OBJS= fsck.o base_device.o ismounted.o fsck_volume_id.o
|
2006-12-19 00:15:45 +01:00
|
|
|
BLKID_OBJS= blkid.o
|
|
|
|
FILEFRAG_OBJS= filefrag.o
|
2009-02-06 16:34:27 +01:00
|
|
|
E2UNDO_OBJS= e2undo.o
|
|
|
|
@@ -81,6 +81,9 @@ PROFILED_DEPLIBS= $(PROFILED_LIBEXT2FS)
|
|
|
|
STATIC_LIBS= $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR)
|
|
|
|
STATIC_DEPLIBS= $(STATIC_LIBEXT2FS) $(STATIC_LIBCOM_ERR)
|
2008-09-05 20:13:55 +02:00
|
|
|
|
2009-02-06 16:34:27 +01:00
|
|
|
+LIBVOLID= -lvolume_id
|
|
|
|
+DEPLIBVOLID=
|
2006-12-19 00:15:45 +01:00
|
|
|
+
|
|
|
|
LIBS_E2P= $(LIBE2P) $(LIBCOM_ERR)
|
|
|
|
DEPLIBS_E2P= $(LIBE2P) $(LIBCOM_ERR)
|
|
|
|
|
2009-02-06 16:34:27 +01:00
|
|
|
@@ -184,10 +187,6 @@ base_device: base_device.c
|
2006-12-19 00:15:45 +01:00
|
|
|
@$(CC) $(ALL_CFLAGS) $(ALL_LDFLAGS) $(srcdir)/base_device.c \
|
|
|
|
-DDEBUG -o base_device
|
|
|
|
|
|
|
|
-check:: base_device
|
|
|
|
- ./base_device < $(srcdir)/base_device.tst > base_device.out
|
|
|
|
- cmp $(srcdir)/base_device.tst base_device.out
|
|
|
|
-
|
|
|
|
mklost+found: $(MKLPF_OBJS)
|
|
|
|
@echo " LD $@"
|
|
|
|
@$(CC) $(ALL_LDFLAGS) -o mklost+found $(MKLPF_OBJS) $(LIBINTL)
|
2009-02-06 16:34:27 +01:00
|
|
|
@@ -250,14 +249,14 @@ dumpe2fs.profiled: $(PROFILED_DUMPE2FS_O
|
|
|
|
$(PROFILED_DUMPE2FS_OBJS) $(PROFILED_LIBS) \
|
|
|
|
$(PROFILED_LIBE2P) $(PROFILED_LIBUUID) $(LIBINTL)
|
|
|
|
|
|
|
|
-fsck: $(FSCK_OBJS) $(DEPLIBBLKID)
|
|
|
|
+fsck: $(FSCK_OBJS) $(DEPLIBVOLID)
|
|
|
|
@echo " LD $@"
|
|
|
|
- @$(CC) $(ALL_LDFLAGS) -o fsck $(FSCK_OBJS) $(LIBBLKID) $(LIBINTL)
|
|
|
|
+ @$(CC) $(ALL_LDFLAGS) -o fsck $(FSCK_OBJS) $(LIBVOLID) $(LIBINTL)
|
2006-12-19 00:15:45 +01:00
|
|
|
|
2009-02-06 16:34:27 +01:00
|
|
|
-fsck.profiled: $(PROFILED_FSCK_OBJS) $(PROFILED_DEPLIBBLKID)
|
|
|
|
+fsck.profiled: $(PROFILED_FSCK_OBJS) $(DEPLIBVOLID)
|
2006-12-19 00:15:45 +01:00
|
|
|
@echo " LD $@"
|
2009-02-06 16:34:27 +01:00
|
|
|
@$(CC) $(ALL_LDFLAGS) -g -pg -o fsck.profiled $(PROFILED_FSCK_OBJS) \
|
|
|
|
- $(PROFILED_LIBBLKID) $(LIBINTL)
|
|
|
|
+ $(LIBVOLID) $(LIBINTL)
|
2006-12-19 00:15:45 +01:00
|
|
|
|
|
|
|
badblocks: $(BADBLOCKS_OBJS) $(DEPLIBS)
|
|
|
|
@echo " LD $@"
|
2009-02-06 16:34:27 +01:00
|
|
|
Index: e2fsprogs-1.41.4/misc/base_device.c
|
|
|
|
===================================================================
|
|
|
|
--- e2fsprogs-1.41.4.orig/misc/base_device.c 2009-02-03 12:24:08.000000000 +0100
|
|
|
|
+++ e2fsprogs-1.41.4/misc/base_device.c 2009-02-03 12:24:48.000000000 +0100
|
2006-12-19 00:15:45 +01:00
|
|
|
@@ -27,6 +27,8 @@
|
|
|
|
#endif
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <string.h>
|
|
|
|
+#include <sys/stat.h>
|
|
|
|
+#include <errno.h>
|
|
|
|
|
|
|
|
#include "fsck.h"
|
|
|
|
|
2009-02-06 16:34:27 +01:00
|
|
|
Index: e2fsprogs-1.41.4/misc/fsck.c
|
|
|
|
===================================================================
|
|
|
|
--- e2fsprogs-1.41.4.orig/misc/fsck.c 2009-02-03 12:24:08.000000000 +0100
|
|
|
|
+++ e2fsprogs-1.41.4/misc/fsck.c 2009-02-03 12:24:48.000000000 +0100
|
|
|
|
@@ -61,7 +61,6 @@
|
2006-12-19 00:15:45 +01:00
|
|
|
#include "../version.h"
|
|
|
|
#include "nls-enable.h"
|
|
|
|
#include "fsck.h"
|
|
|
|
-#include "blkid/blkid.h"
|
|
|
|
|
|
|
|
#ifndef _PATH_MNTTAB
|
|
|
|
#define _PATH_MNTTAB "/etc/fstab"
|
2009-02-06 16:34:27 +01:00
|
|
|
@@ -122,7 +121,6 @@ struct fs_info *filesys_info = NULL, *fi
|
2006-12-19 00:15:45 +01:00
|
|
|
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)
|
|
|
|
{
|
2009-02-06 16:34:27 +01:00
|
|
|
@@ -298,7 +296,7 @@ static int parse_fstab_line(char *line,
|
2006-12-19 00:15:45 +01:00
|
|
|
parse_escape(freq);
|
|
|
|
parse_escape(passno);
|
|
|
|
|
|
|
|
- dev = blkid_get_devname(cache, device, NULL);
|
|
|
|
+ dev = fsck_get_devname(device);
|
|
|
|
if (dev)
|
|
|
|
device = dev;
|
|
|
|
|
2009-02-06 16:34:27 +01:00
|
|
|
@@ -323,7 +321,7 @@ static void interpret_type(struct fs_inf
|
|
|
|
|
2006-12-19 00:15:45 +01:00
|
|
|
if (strcmp(fs->type, "auto") != 0)
|
|
|
|
return;
|
|
|
|
- t = blkid_get_tag_value(cache, "TYPE", fs->device);
|
|
|
|
+ t = fsck_get_fstype(fs->device);
|
|
|
|
if (t) {
|
|
|
|
free(fs->type);
|
|
|
|
fs->type = t;
|
2009-02-06 16:34:27 +01:00
|
|
|
@@ -1120,7 +1118,7 @@ static void PRS(int argc, char *argv[])
|
2006-12-19 00:15:45 +01:00
|
|
|
progname);
|
|
|
|
exit(EXIT_ERROR);
|
|
|
|
}
|
|
|
|
- dev = blkid_get_devname(cache, arg, NULL);
|
|
|
|
+ dev = fsck_get_devname(arg);
|
|
|
|
if (!dev && strchr(arg, '=')) {
|
|
|
|
/*
|
|
|
|
* Check to see if we failed because
|
2009-02-06 16:34:27 +01:00
|
|
|
@@ -1266,7 +1264,7 @@ int main(int argc, char *argv[])
|
2006-12-19 00:15:45 +01:00
|
|
|
bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
|
|
|
|
textdomain(NLS_CAT_NAME);
|
|
|
|
#endif
|
2008-02-01 21:29:19 +01:00
|
|
|
- blkid_get_cache(&cache, NULL);
|
|
|
|
+ fsck_get_cache(NULL);
|
2006-12-19 00:15:45 +01:00
|
|
|
PRS(argc, argv);
|
|
|
|
|
|
|
|
if (!notitle)
|
2009-02-06 16:34:27 +01:00
|
|
|
@@ -1337,6 +1335,6 @@ int main(int argc, char *argv[])
|
2006-12-19 00:15:45 +01:00
|
|
|
}
|
|
|
|
status |= wait_many(FLAG_WAIT_ALL);
|
|
|
|
free(fsck_path);
|
|
|
|
- blkid_put_cache(cache);
|
|
|
|
+ fsck_put_cache();
|
|
|
|
return status;
|
|
|
|
}
|
2009-02-06 16:34:27 +01:00
|
|
|
Index: e2fsprogs-1.41.4/misc/fsck.h
|
|
|
|
===================================================================
|
|
|
|
--- e2fsprogs-1.41.4.orig/misc/fsck.h 2009-02-03 12:24:08.000000000 +0100
|
|
|
|
+++ e2fsprogs-1.41.4/misc/fsck.h 2009-02-03 12:24:48.000000000 +0100
|
|
|
|
@@ -66,6 +66,11 @@ struct fsck_instance {
|
2008-09-05 20:13:55 +02:00
|
|
|
struct fsck_instance *next;
|
|
|
|
};
|
2008-08-21 22:53:58 +02:00
|
|
|
|
2006-12-19 00:15:45 +01:00
|
|
|
+extern int fsck_get_cache(const char *filename);
|
|
|
|
+extern void fsck_put_cache(void);
|
|
|
|
+extern char *fsck_get_devname(const char *device);
|
|
|
|
+extern char *fsck_get_fstype(const char *device);
|
|
|
|
+
|
2009-02-06 16:34:27 +01:00
|
|
|
extern dev_t base_devt(const char *device);
|
|
|
|
extern int match_device(const char *dev1, const char *dev2);
|
|
|
|
|
|
|
|
Index: e2fsprogs-1.41.4/misc/fsck_volume_id.c
|
|
|
|
===================================================================
|
|
|
|
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
|
|
|
|
+++ e2fsprogs-1.41.4/misc/fsck_volume_id.c 2009-02-03 12:24:48.000000000 +0100
|
2008-09-05 20:13:55 +02:00
|
|
|
@@ -0,0 +1,132 @@
|
2006-12-19 00:15:45 +01:00
|
|
|
+/*
|
|
|
|
+ * Wrapper for libvolume_id
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+#include <stdio.h>
|
|
|
|
+#include <stdlib.h>
|
|
|
|
+#include <unistd.h>
|
|
|
|
+#include <string.h>
|
2008-09-05 20:13:55 +02:00
|
|
|
+#include <fcntl.h>
|
2006-12-19 00:15:45 +01:00
|
|
|
+#include <sys/mount.h>
|
|
|
|
+#include <sys/ioctl.h>
|
|
|
|
+#include <stddef.h>
|
|
|
|
+#include <libvolume_id.h>
|
|
|
|
+
|
|
|
|
+#include "fsck.h"
|
|
|
|
+
|
|
|
|
+int fsck_get_cache(const char *filename)
|
|
|
|
+{
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void fsck_put_cache(void)
|
|
|
|
+{
|
|
|
|
+}
|
|
|
|
+
|
2008-09-05 20:13:55 +02:00
|
|
|
+static char *fsck_get_devname_by_uuid(const char *uuid)
|
2006-12-19 00:15:45 +01:00
|
|
|
+{
|
|
|
|
+ char *dev = NULL;
|
|
|
|
+
|
|
|
|
+ if (!uuid)
|
|
|
|
+ return NULL;
|
|
|
|
+
|
|
|
|
+ dev = malloc(19 + strlen(uuid));
|
|
|
|
+ if (dev) {
|
|
|
|
+ strcpy(dev,"/dev/disk/by-uuid/");
|
|
|
|
+ strcat(dev,uuid);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return dev;
|
|
|
|
+}
|
|
|
|
+
|
2008-09-05 20:13:55 +02:00
|
|
|
+static char *fsck_get_devname_by_label(const char *label)
|
2006-12-19 00:15:45 +01:00
|
|
|
+{
|
|
|
|
+ char *dev = NULL;
|
|
|
|
+
|
|
|
|
+ if (!label)
|
|
|
|
+ return NULL;
|
|
|
|
+
|
|
|
|
+ dev = malloc(20 + strlen(label));
|
|
|
|
+ if (dev) {
|
|
|
|
+ strcpy(dev,"/dev/disk/by-label/");
|
|
|
|
+ strcat(dev,label);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return dev;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+char *fsck_get_devname(const char *spec)
|
|
|
|
+{
|
|
|
|
+ char *token, *cp, *value;
|
|
|
|
+ char *nspec = NULL;
|
|
|
|
+
|
|
|
|
+ if (!spec)
|
|
|
|
+ return NULL;
|
|
|
|
+
|
|
|
|
+ token = strdup(spec);
|
|
|
|
+ if (!token)
|
|
|
|
+ return NULL;
|
|
|
|
+
|
|
|
|
+ /* We have to return an allocated string */
|
|
|
|
+ if (!(cp = strchr(token, '=')))
|
|
|
|
+ return token;
|
|
|
|
+
|
|
|
|
+ value = token + (cp - token);
|
|
|
|
+ *value++ = '\0';
|
|
|
|
+
|
|
|
|
+ if (*value == '"' || *value == '\'') {
|
|
|
|
+ char c = *value++;
|
|
|
|
+ if (!(cp = strrchr(value, c)))
|
|
|
|
+ goto errout; /* missing closing quote */
|
|
|
|
+ *cp = '\0';
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!strcmp(token,"LABEL")) {
|
|
|
|
+ nspec = fsck_get_devname_by_label(value);
|
|
|
|
+ } else if (!strcmp(token,"UUID")) {
|
|
|
|
+ nspec = fsck_get_devname_by_uuid(value);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ free(token);
|
|
|
|
+
|
|
|
|
+ errout:
|
|
|
|
+ return nspec;
|
|
|
|
+}
|
|
|
|
+
|
2008-09-05 20:13:55 +02:00
|
|
|
+char *fsck_get_fstype(const char *device)
|
2006-12-19 00:15:45 +01:00
|
|
|
+{
|
2008-09-05 20:13:55 +02:00
|
|
|
+ int fd = -1;
|
|
|
|
+ struct volume_id *vid = NULL;
|
2006-12-19 00:15:45 +01:00
|
|
|
+ uint64_t size;
|
2008-09-05 20:13:55 +02:00
|
|
|
+ const char *s;
|
|
|
|
+ char *value = NULL;
|
2006-12-19 00:15:45 +01:00
|
|
|
+
|
2008-09-05 20:13:55 +02:00
|
|
|
+ if (!device)
|
2006-12-19 00:15:45 +01:00
|
|
|
+ return NULL;
|
|
|
|
+
|
2008-09-05 20:13:55 +02:00
|
|
|
+ fd = open(device, O_RDONLY);
|
|
|
|
+ if (fd < 0)
|
2006-12-19 00:15:45 +01:00
|
|
|
+ return NULL;
|
|
|
|
+
|
2008-09-05 20:13:55 +02:00
|
|
|
+ vid = volume_id_open_fd(fd);
|
|
|
|
+ if (!vid)
|
2006-12-19 00:15:45 +01:00
|
|
|
+ goto out;
|
|
|
|
+
|
2008-09-05 20:13:55 +02:00
|
|
|
+ if (ioctl(fd, BLKGETSIZE64, &size) != 0)
|
|
|
|
+ size = 0;
|
2006-12-19 00:15:45 +01:00
|
|
|
+
|
2008-09-05 20:13:55 +02:00
|
|
|
+ if (volume_id_probe_all(vid, 0, size) != 0)
|
2006-12-19 00:15:45 +01:00
|
|
|
+ goto out;
|
|
|
|
+
|
2008-09-05 20:13:55 +02:00
|
|
|
+ if (!volume_id_get_type(vid, &s))
|
|
|
|
+ goto out;
|
2006-12-19 00:15:45 +01:00
|
|
|
+
|
2008-09-05 20:13:55 +02:00
|
|
|
+ value = strdup(s);
|
|
|
|
+out:
|
|
|
|
+ if (vid != NULL)
|
2006-12-19 00:15:45 +01:00
|
|
|
+ volume_id_close(vid);
|
2008-09-05 20:13:55 +02:00
|
|
|
+ if (fd >= 0)
|
|
|
|
+ close(fd);
|
2006-12-19 00:15:45 +01:00
|
|
|
+
|
|
|
|
+ return value;
|
|
|
|
+}
|