Contents of /trunk/util-linux/patches/util-linux-2.18-mount-loopdev.patch
Parent Directory | Revision Log
Revision 1080 -
(show annotations)
(download)
Tue Aug 17 16:12:03 2010 UTC (14 years, 1 month ago) by niro
File size: 2519 byte(s)
Tue Aug 17 16:12:03 2010 UTC (14 years, 1 month ago) by niro
File size: 2519 byte(s)
added fix for iso images
1 | diff -up util-linux-ng-2.17.2/mount/mount.c.kzak util-linux-ng-2.17.2/mount/mount.c |
2 | --- util-linux-ng-2.17.2/mount/mount.c.kzak 2010-03-22 09:10:56.000000000 +0100 |
3 | +++ util-linux-ng-2.17.2/mount/mount.c 2010-07-29 16:15:28.000000000 +0200 |
4 | @@ -1090,7 +1090,8 @@ loop_check(const char **spec, const char |
5 | if (verbose) |
6 | printf(_("mount: skipping the setup of a loop device\n")); |
7 | } else { |
8 | - int loop_opts = SETLOOP_AUTOCLEAR; /* always attempt autoclear */ |
9 | + /* use autoclear loopdev on system without regular mtab only */ |
10 | + int loop_opts = mtab_is_writable() ? 0 : SETLOOP_AUTOCLEAR; |
11 | int res; |
12 | |
13 | if (*flags & MS_RDONLY) |
14 | @@ -1759,6 +1760,50 @@ mounted (const char *spec0, const char * |
15 | return ret; |
16 | } |
17 | |
18 | +/* returns 0 if not mounted, 1 if mounted and -1 in case of error */ |
19 | +static int |
20 | +is_fstab_entry_mounted(struct mntentchn *mc, int verbose) |
21 | +{ |
22 | + struct stat st; |
23 | + |
24 | + if (mounted(mc->m.mnt_fsname, mc->m.mnt_dir)) |
25 | + goto yes; |
26 | + |
27 | + /* extra care for loop devices */ |
28 | + if ((strstr(mc->m.mnt_opts, "loop=") || |
29 | + (stat(mc->m.mnt_fsname, &st) == 0 && S_ISREG(st.st_mode)))) { |
30 | + |
31 | + char *p = strstr(mc->m.mnt_opts, "offset="); |
32 | + uintmax_t offset = 0; |
33 | + |
34 | + if (p && *(p + 7)) { |
35 | + char *end = NULL; |
36 | + |
37 | + p += 7; |
38 | + errno = 0; |
39 | + offset = strtoumax(p, &end, 0); |
40 | + |
41 | + if (end == p || (errno != 0 && |
42 | + (offset == UINTMAX_MAX || offset == 0))) { |
43 | + if (verbose) |
44 | + printf(_("mount: ignore %s " |
45 | + "(unparsable offset= option)\n"), |
46 | + mc->m.mnt_fsname); |
47 | + return -1; |
48 | + } |
49 | + } |
50 | + if (is_mounted_same_loopfile(mc->m.mnt_dir, mc->m.mnt_fsname, offset)) |
51 | + goto yes; |
52 | + } |
53 | + |
54 | + return 0; |
55 | +yes: |
56 | + if (verbose) |
57 | + printf(_("mount: %s already mounted on %s\n"), |
58 | + mc->m.mnt_fsname, mc->m.mnt_dir); |
59 | + return 1; |
60 | +} |
61 | + |
62 | /* avoid using stat() on things we are not going to mount anyway.. */ |
63 | static int |
64 | has_noauto (const char *opts) { |
65 | @@ -1804,16 +1849,8 @@ do_mount_all (char *types, char *options |
66 | if (matching_type (mc->m.mnt_type, types) |
67 | && matching_opts (mc->m.mnt_opts, test_opts) |
68 | && !streq (mc->m.mnt_dir, "/") |
69 | - && !streq (mc->m.mnt_dir, "root")) { |
70 | - |
71 | - if (mounted (mc->m.mnt_fsname, mc->m.mnt_dir)) { |
72 | - if (verbose) |
73 | - printf(_("mount: %s already mounted " |
74 | - "on %s\n"), |
75 | - mc->m.mnt_fsname, |
76 | - mc->m.mnt_dir); |
77 | - continue; |
78 | - } |
79 | + && !streq (mc->m.mnt_dir, "root") |
80 | + && !is_fstab_entry_mounted(mc, verbose)) { |
81 | |
82 | mtmp = (struct mntentchn *) xmalloc(sizeof(*mtmp)); |
83 | *mtmp = *mc; |