]>
Commit | Line | Data |
---|---|---|
3d551623 PG |
1 | diff --git a/daemon/spawn.c b/daemon/spawn.c |
2 | index 0ed873e..78d69c6 100644 | |
3 | --- a/daemon/spawn.c | |
4 | +++ b/daemon/spawn.c | |
5 | @@ -25,6 +25,7 @@ | |
6 | #include <time.h> | |
7 | #include <sys/wait.h> | |
8 | #include <sys/stat.h> | |
9 | +#include <sys/mount.h> | |
10 | ||
11 | #include "automount.h" | |
12 | ||
13 | @@ -308,6 +309,8 @@ int spawn_mount(unsigned logopt, ...) | |
14 | while (retries--) { | |
15 | ret = do_spawn(logopt, options, prog, (const char **) argv); | |
16 | if (ret & MTAB_NOTUPDATED) { | |
17 | + struct timespec tm = {3, 0}; | |
18 | + | |
19 | /* | |
20 | * If the mount succeeded but the mtab was not | |
21 | * updated, then retry the mount with the -f (fake) | |
22 | @@ -329,6 +332,9 @@ int spawn_mount(unsigned logopt, ...) | |
23 | argv[argc - 1] = argv[argc - 2]; | |
24 | argv[argc - 2] = arg_fake; | |
25 | } | |
26 | + | |
27 | + nanosleep(&tm, NULL); | |
28 | + | |
29 | continue; | |
30 | } | |
31 | break; | |
32 | @@ -336,9 +342,16 @@ int spawn_mount(unsigned logopt, ...) | |
33 | ||
34 | /* This is not a fatal error */ | |
35 | if (ret == MTAB_NOTUPDATED) { | |
36 | - warn(logopt, "Unable to update the mtab file, /proc/mounts " | |
37 | - "and /etc/mtab will differ"); | |
38 | - ret = 0; | |
39 | + /* | |
40 | + * Version 5 requires that /etc/mtab be in sync with | |
41 | + * /proc/mounts. If we're unable to update matb after | |
42 | + * retrying then we have no choice but umount the mount | |
43 | + * and return a fail. | |
44 | + */ | |
45 | + warn(logopt, | |
46 | + "Unable to update the mtab file, forcing mount fail!"); | |
47 | + umount(argv[argc]); | |
48 | + ret = MNT_FORCE_FAIL; | |
49 | } | |
50 | ||
51 | return ret; | |
52 | @@ -395,6 +408,8 @@ int spawn_bind_mount(unsigned logopt, ...) | |
53 | while (retries--) { | |
54 | ret = do_spawn(logopt, options, prog, (const char **) argv); | |
55 | if (ret & MTAB_NOTUPDATED) { | |
56 | + struct timespec tm = {3, 0}; | |
57 | + | |
58 | /* | |
59 | * If the mount succeeded but the mtab was not | |
60 | * updated, then retry the mount with the -f (fake) | |
61 | @@ -416,6 +431,9 @@ int spawn_bind_mount(unsigned logopt, ...) | |
62 | argv[argc - 1] = argv[argc - 2]; | |
63 | argv[argc - 2] = arg_fake; | |
64 | } | |
65 | + | |
66 | + nanosleep(&tm, NULL); | |
67 | + | |
68 | continue; | |
69 | } | |
70 | break; | |
71 | @@ -423,9 +441,16 @@ int spawn_bind_mount(unsigned logopt, ...) | |
72 | ||
73 | /* This is not a fatal error */ | |
74 | if (ret == MTAB_NOTUPDATED) { | |
75 | - warn(logopt, "Unable to update the mtab file, /proc/mounts " | |
76 | - "and /etc/mtab will differ"); | |
77 | - ret = 0; | |
78 | + /* | |
79 | + * Version 5 requires that /etc/mtab be in sync with | |
80 | + * /proc/mounts. If we're unable to update matb after | |
81 | + * retrying then we have no choice but umount the mount | |
82 | + * and return a fail. | |
83 | + */ | |
84 | + warn(logopt, | |
85 | + "Unable to update the mtab file, forcing mount fail!"); | |
86 | + umount(argv[argc]); | |
87 | + ret = MNT_FORCE_FAIL; | |
88 | } | |
89 | ||
90 | return ret; | |
91 | diff --git a/include/automount.h b/include/automount.h | |
92 | index 4887da6..fa5cd97 100644 | |
93 | --- a/include/automount.h | |
94 | +++ b/include/automount.h | |
95 | @@ -78,6 +78,7 @@ int load_autofs4_module(void); | |
96 | #define MOUNTED_LOCK _PATH_MOUNTED "~" /* mounts' lock file */ | |
97 | #define MTAB_NOTUPDATED 0x1000 /* mtab succeded but not updated */ | |
98 | #define NOT_MOUNTED 0x0100 /* path notmounted */ | |
99 | +#define MNT_FORCE_FAIL -1 | |
100 | #define _PROC_MOUNTS "/proc/mounts" | |
101 | ||
102 | /* Constants for lookup modules */ | |
103 | diff --git a/modules/mount_bind.c b/modules/mount_bind.c | |
104 | index 04284f5..ef973e1 100644 | |
105 | --- a/modules/mount_bind.c | |
106 | +++ b/modules/mount_bind.c | |
107 | @@ -147,7 +147,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int | |
108 | if ((!ap->ghost && name_len) || !existed) | |
109 | rmdir_path(ap, fullpath, ap->dev); | |
110 | ||
111 | - return 1; | |
112 | + return err; | |
113 | } else { | |
114 | debug(ap->logopt, | |
115 | MODPREFIX "mounted %s type %s on %s", | |
116 | diff --git a/modules/mount_nfs.c b/modules/mount_nfs.c | |
117 | index bad21fc..0e7aebe 100644 | |
118 | --- a/modules/mount_nfs.c | |
119 | +++ b/modules/mount_nfs.c | |
120 | @@ -233,6 +233,10 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int | |
121 | return 0; | |
122 | } | |
123 | ||
124 | + /* Failed to update mtab, don't try any more */ | |
125 | + if (err == MNT_FORCE_FAIL) | |
126 | + goto forced_fail; | |
127 | + | |
128 | /* No hostname, can't be NFS */ | |
129 | if (!this->name) { | |
130 | this = this->next; | |
131 | @@ -275,6 +279,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int | |
132 | this = this->next; | |
133 | } | |
134 | ||
135 | +forced_fail: | |
136 | free_host_list(&hosts); | |
137 | ap->ghost = save_ghost; | |
138 |