|
|
3e4b94e |
--- util-linux-2.13-pre6/mount/fstab.h.twiceloop 2006-09-15 08:50:46.000000000 +0200
|
|
|
3e4b94e |
+++ util-linux-2.13-pre6/mount/fstab.h 2006-09-15 08:51:10.000000000 +0200
|
|
|
3e4b94e |
@@ -2,6 +2,7 @@
|
|
|
3e4b94e |
int mtab_is_writable(void);
|
|
|
3e4b94e |
int mtab_does_not_exist(void);
|
|
|
3e4b94e |
int is_mounted_once(const char *name);
|
|
|
3e4b94e |
+int is_mounted_same_loopfile(const char *loopfile, const char *dir);
|
|
|
632f494 |
|
|
|
3e4b94e |
struct mntentchn {
|
|
|
3e4b94e |
struct mntentchn *nxt, *prev;
|
|
|
3e4b94e |
--- util-linux-2.13-pre6/mount/mount.c.twiceloop 2006-09-15 08:50:23.000000000 +0200
|
|
|
3e4b94e |
+++ util-linux-2.13-pre6/mount/mount.c 2006-09-15 08:50:24.000000000 +0200
|
|
|
632f494 |
@@ -671,7 +671,7 @@
|
|
|
632f494 |
|
|
|
632f494 |
static int
|
|
|
632f494 |
loop_check(const char **spec, const char **type, int *flags,
|
|
|
632f494 |
- int *loop, const char **loopdev, const char **loopfile) {
|
|
|
632f494 |
+ int *loop, const char **loopdev, const char **loopfile, const char *dir) {
|
|
|
632f494 |
int looptype;
|
|
|
632f494 |
unsigned long long offset;
|
|
|
632f494 |
|
|
|
632f494 |
@@ -709,6 +709,11 @@
|
|
|
632f494 |
} else {
|
|
|
632f494 |
int loopro = (*flags & MS_RDONLY);
|
|
|
632f494 |
|
|
|
632f494 |
+ if (is_mounted_same_loopfile(*loopfile, dir)) {
|
|
|
632f494 |
+ error(_("mount: %s already mounted on %s"), *loopfile, dir);
|
|
|
632f494 |
+ return EX_FAIL;
|
|
|
632f494 |
+ }
|
|
|
632f494 |
+
|
|
|
632f494 |
if (!*loopdev || !**loopdev)
|
|
|
632f494 |
*loopdev = find_unused_loop_device();
|
|
|
632f494 |
if (!*loopdev)
|
|
|
632f494 |
@@ -856,7 +861,7 @@
|
|
|
632f494 |
* stale assignments of files to loop devices. Nasty when used for
|
|
|
632f494 |
* encryption.
|
|
|
632f494 |
*/
|
|
|
632f494 |
- res = loop_check(&spec, &types, &flags, &loop, &loopdev, &loopfile);
|
|
|
632f494 |
+ res = loop_check(&spec, &types, &flags, &loop, &loopdev, &loopfile, node);
|
|
|
632f494 |
if (res)
|
|
|
632f494 |
goto out;
|
|
|
632f494 |
}
|
|
|
3e4b94e |
--- util-linux-2.13-pre6/mount/fstab.c.twiceloop 2006-09-15 08:50:23.000000000 +0200
|
|
|
3e4b94e |
+++ util-linux-2.13-pre6/mount/fstab.c 2006-09-15 08:50:24.000000000 +0200
|
|
|
3e4b94e |
@@ -254,6 +254,27 @@
|
|
|
3e4b94e |
return (ct == 1);
|
|
|
3e4b94e |
}
|
|
|
3e4b94e |
|
|
|
3e4b94e |
+/*
|
|
|
3e4b94e |
+ * Given the loop file LOOPFILE, and the mount point DIR, check that
|
|
|
3e4b94e |
+ * same file is already mounted on same directory
|
|
|
3e4b94e |
+ *
|
|
|
3e4b94e |
+ * Don't forget there's
|
|
|
3e4b94e |
+ * /path/loopfile /path/dir loop=/dev/loop0
|
|
|
3e4b94e |
+ * in mtab for loop devices.
|
|
|
3e4b94e |
+ */
|
|
|
3e4b94e |
+int
|
|
|
3e4b94e |
+is_mounted_same_loopfile(const char *loopfile, const char *dir) {
|
|
|
3e4b94e |
+ struct mntentchn *mc, *mc0;
|
|
|
3e4b94e |
+ int ct = 0;
|
|
|
3e4b94e |
+
|
|
|
3e4b94e |
+ mc0 = mtab_head();
|
|
|
3e4b94e |
+ for (mc = mc0->prev; mc && mc != mc0; mc = mc->prev)
|
|
|
3e4b94e |
+ if (streq(mc->m.mnt_fsname, loopfile) &&
|
|
|
3e4b94e |
+ streq(mc->m.mnt_dir, dir))
|
|
|
3e4b94e |
+ ct++;
|
|
|
3e4b94e |
+ return (ct == 1);
|
|
|
3e4b94e |
+}
|
|
|
3e4b94e |
+
|
|
|
3e4b94e |
/* Given the name FILE, try to find the option "loop=FILE" in mtab. */
|
|
|
3e4b94e |
struct mntentchn *
|
|
|
3e4b94e |
getmntoptfile (const char *file) {
|