]> git.pld-linux.org Git - packages/util-linux.git/blame - util-linux-mount-twiceloop.patch
- uniformized configs to use system-auth where possible
[packages/util-linux.git] / util-linux-mount-twiceloop.patch
CommitLineData
5545a732
JR
1- mount allows loopback devices to be mounted
2 more than once to the same mount point
3
4--- util-linux-2.13-pre6/mount/fstab.h.twiceloop 2006-09-15 08:50:46.000000000 +0200
5+++ util-linux-2.13-pre6/mount/fstab.h 2006-09-15 08:51:10.000000000 +0200
6@@ -2,6 +2,7 @@
7 int mtab_is_writable(void);
8 int mtab_does_not_exist(void);
9 int is_mounted_once(const char *name);
10+int is_mounted_same_loopfile(const char *loopfile, const char *dir);
11
12 struct mntentchn {
13 struct mntentchn *nxt, *prev;
14--- util-linux-2.13-pre6/mount/mount.c.twiceloop 2006-09-15 08:50:23.000000000 +0200
15+++ util-linux-2.13-pre6/mount/mount.c 2006-09-15 08:50:24.000000000 +0200
16@@ -671,7 +671,7 @@
17
18 static int
19 loop_check(const char **spec, const char **type, int *flags,
20- int *loop, const char **loopdev, const char **loopfile) {
21+ int *loop, const char **loopdev, const char **loopfile, const char *dir) {
22 int looptype;
23 unsigned long long offset;
24
25@@ -709,6 +709,11 @@
26 } else {
27 int loopro = (*flags & MS_RDONLY);
28
29+ if (is_mounted_same_loopfile(*loopfile, dir)) {
30+ error(_("mount: %s already mounted on %s"), *loopfile, dir);
31+ return EX_FAIL;
32+ }
33+
34 if (!*loopdev || !**loopdev)
35 *loopdev = find_unused_loop_device();
36 if (!*loopdev)
37@@ -856,7 +861,7 @@
38 * stale assignments of files to loop devices. Nasty when used for
39 * encryption.
40 */
41- res = loop_check(&spec, &types, &flags, &loop, &loopdev, &loopfile);
42+ res = loop_check(&spec, &types, &flags, &loop, &loopdev, &loopfile, node);
43 if (res)
44 goto out;
45 }
46--- util-linux-2.13-pre6/mount/fstab.c.twiceloop 2006-09-15 08:50:23.000000000 +0200
47+++ util-linux-2.13-pre6/mount/fstab.c 2006-09-15 08:50:24.000000000 +0200
48@@ -254,6 +254,27 @@
49 return (ct == 1);
50 }
51
52+/*
53+ * Given the loop file LOOPFILE, and the mount point DIR, check that
54+ * same file is already mounted on same directory
55+ *
56+ * Don't forget there's
57+ * /path/loopfile /path/dir loop=/dev/loop0
58+ * in mtab for loop devices.
59+ */
60+int
61+is_mounted_same_loopfile(const char *loopfile, const char *dir) {
62+ struct mntentchn *mc, *mc0;
63+ int ct = 0;
64+
65+ mc0 = mtab_head();
66+ for (mc = mc0->prev; mc && mc != mc0; mc = mc->prev)
67+ if (streq(mc->m.mnt_fsname, loopfile) &&
68+ streq(mc->m.mnt_dir, dir))
69+ ct++;
70+ return (ct == 1);
71+}
72+
73 /* Given the name FILE, try to find the option "loop=FILE" in mtab. */
74 struct mntentchn *
75 getmntoptfile (const char *file) {
This page took 0.064442 seconds and 4 git commands to generate.