1 - mount allows loopback devices to be mounted
2 more than once to the same mount point
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
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);
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
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) {
23 unsigned long long offset;
27 int loopro = (*flags & MS_RDONLY);
29 + if (is_mounted_same_loopfile(*loopfile, dir)) {
30 + error(_("mount: %s already mounted on %s"), *loopfile, dir);
34 if (!*loopdev || !**loopdev)
35 *loopdev = find_unused_loop_device();
38 * stale assignments of files to loop devices. Nasty when used for
41 - res = loop_check(&spec, &types, &flags, &loop, &loopdev, &loopfile);
42 + res = loop_check(&spec, &types, &flags, &loop, &loopdev, &loopfile, node);
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
53 + * Given the loop file LOOPFILE, and the mount point DIR, check that
54 + * same file is already mounted on same directory
56 + * Don't forget there's
57 + * /path/loopfile /path/dir loop=/dev/loop0
58 + * in mtab for loop devices.
61 +is_mounted_same_loopfile(const char *loopfile, const char *dir) {
62 + struct mntentchn *mc, *mc0;
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))
73 /* Given the name FILE, try to find the option "loop=FILE" in mtab. */
75 getmntoptfile (const char *file) {