]> git.pld-linux.org Git - packages/autofs.git/blob - autofs-5.0.4-force-unlink-umount.patch
- updated to 5.0.5, nfy.
[packages/autofs.git] / autofs-5.0.4-force-unlink-umount.patch
1 autofs-5.0.4 - force unlink umount at startup
2
3 From: Ian Kent <raven@themaw.net>
4
5 Version 5.0.3 autofs would unlink existing mounts at startup. This
6 functioned OK most of the time but caused processes whose working
7 directory was within unlinked automounted directories to not get a
8 correct pwd reported by the system.
9
10 There can be situations where the unlink umounting is desirable, such
11 as when the daemon is forceably killed and we want to get rid of any
12 existing mounts at startup. This change provides a way to force this
13 old behavior by passing the "--force" option to the daemon. This can
14 also be done by using the "forcestart" and "forcerestart" actions to
15 the init script.
16
17 Note that the old behavior will always be used if the kernel does not
18 include the iotcl re-implementation which provides the ability to
19 re-connect to existing mounts.
20 ---
21
22  CHANGELOG             |    2 ++
23  daemon/automount.c    |   14 +++++++++++++-
24  daemon/direct.c       |    2 +-
25  daemon/indirect.c     |    2 +-
26  include/automount.h   |    3 +++
27  man/automount.8       |   13 +++++++++++++
28  redhat/autofs.init.in |   10 +++++++++-
29  samples/rc.autofs.in  |   10 +++++++++-
30  8 files changed, 51 insertions(+), 5 deletions(-)
31
32
33 diff --git a/CHANGELOG b/CHANGELOG
34 index 7dee674..d4dd70b 100644
35 --- a/CHANGELOG
36 +++ b/CHANGELOG
37 @@ -12,6 +12,8 @@
38  - fix hosts map use after free.
39  - fix uri list locking (again).
40  - check for stale SASL credentials upon connect fail.
41 +- add "forcestart" and "forcerestart" init script options to allow
42 +  use of 5.0.3 strartup behavior if required.
43  
44  4/11/2008 autofs-5.0.4
45  -----------------------
46 diff --git a/daemon/automount.c b/daemon/automount.c
47 index f04273f..e20e7c9 100644
48 --- a/daemon/automount.c
49 +++ b/daemon/automount.c
50 @@ -57,6 +57,7 @@ static char *pid_file = NULL;         /* File in which to keep pid */
51  unsigned int global_random_selection;  /* use random policy when selecting
52                                          * which multi-mount host to mount */
53  long global_negative_timeout = -1;
54 +int do_force_unlink = 0;               /* Forceably unlink mount tree at startup */
55  
56  static int start_pipefd[2];
57  static int st_stat = 0;
58 @@ -1798,6 +1799,7 @@ int main(int argc, char *argv[])
59                 {"version", 0, 0, 'V'},
60                 {"set-log-priority", 1, 0, 'l'},
61                 {"dont-check-daemon", 0, 0, 'C'},
62 +               {"force", 0, 0, 'F'},
63                 {0, 0, 0, 0}
64         };
65  
66 @@ -1819,7 +1821,7 @@ int main(int argc, char *argv[])
67         daemon_check = 1;
68  
69         opterr = 0;
70 -       while ((opt = getopt_long(argc, argv, "+hp:t:vdD:fVrO:l:n:C", long_options, NULL)) != EOF) {
71 +       while ((opt = getopt_long(argc, argv, "+hp:t:vdD:fVrO:l:n:CF", long_options, NULL)) != EOF) {
72                 switch (opt) {
73                 case 'h':
74                         usage();
75 @@ -1892,6 +1894,10 @@ int main(int argc, char *argv[])
76                         daemon_check = 0;
77                         break;
78  
79 +               case 'F':
80 +                       do_force_unlink = 1;
81 +                       break;
82 +
83                 case '?':
84                 case ':':
85                         printf("%s: Ambiguous or unknown options\n", program);
86 @@ -2066,6 +2072,12 @@ int main(int argc, char *argv[])
87                 exit(3);
88         }
89  
90 +       /*
91 +        * Mmm ... reset force unlink umount so we don't also do this
92 +        * in future when we receive a HUP signal.
93 +        */
94 +       do_force_unlink = 0;
95 +
96         res = write(start_pipefd[1], pst_stat, sizeof(*pst_stat));
97         close(start_pipefd[1]);
98  
99 diff --git a/daemon/direct.c b/daemon/direct.c
100 index d9dda3d..2d979f1 100644
101 --- a/daemon/direct.c
102 +++ b/daemon/direct.c
103 @@ -335,7 +335,7 @@ int do_mount_autofs_direct(struct autofs_point *ap, struct mnt_list *mnts, struc
104         /* Calculate the timeouts */
105         ap->exp_runfreq = (timeout + CHECK_RATIO - 1) / CHECK_RATIO;
106  
107 -       if (ops->version) {
108 +       if (ops->version && !do_force_unlink) {
109                 ap->flags |= MOUNT_FLAG_REMOUNT;
110                 ret = try_remount(ap, me, t_direct);
111                 ap->flags &= ~MOUNT_FLAG_REMOUNT;
112 diff --git a/daemon/indirect.c b/daemon/indirect.c
113 index 0721707..2ccbc53 100644
114 --- a/daemon/indirect.c
115 +++ b/daemon/indirect.c
116 @@ -97,7 +97,7 @@ static int do_mount_autofs_indirect(struct autofs_point *ap, const char *root)
117  
118         ap->exp_runfreq = (timeout + CHECK_RATIO - 1) / CHECK_RATIO;
119  
120 -       if (ops->version) {
121 +       if (ops->version && !do_force_unlink) {
122                 ap->flags |= MOUNT_FLAG_REMOUNT;
123                 ret = try_remount(ap, NULL, t_indirect);
124                 ap->flags &= ~MOUNT_FLAG_REMOUNT;
125 diff --git a/include/automount.h b/include/automount.h
126 index 46cb6c6..1f14d5b 100644
127 --- a/include/automount.h
128 +++ b/include/automount.h
129 @@ -428,6 +428,9 @@ struct autofs_point {
130         struct list_head submounts;     /* List of child submounts */
131  };
132  
133 +/* Foreably unlink existing mounts at startup. */
134 +extern int do_force_unlink;
135 +
136  /* Standard functions used by daemon or modules */
137  
138  #define        MOUNT_OFFSET_OK         0
139 diff --git a/man/automount.8 b/man/automount.8
140 index d9285bf..9fcaaf4 100644
141 --- a/man/automount.8
142 +++ b/man/automount.8
143 @@ -84,6 +84,11 @@ path name as specified in the master map.
144  .TP
145  .I "\-C, \-\-dont-check-daemon"
146  Don't check if the daemon is currently running (see NOTES).
147 +.TP
148 +.I "\-F, \-\-force"
149 +Force an unlink umount of existing mounts under autofs managed mount points
150 +during startup. This can cause problems for processes with working directories
151 +within these mounts (see NOTES).
152  .SH ARGUMENTS
153  \fBautomount\fP takes one optional argument, the name of the master map to
154  use.
155 @@ -132,6 +137,14 @@ for certain types of automount maps. The mounts of the seperate daemons
156  might interfere with one another. The implications of running multiple
157  daemon instances needs to be checked and tested before we can say this
158  is supported.
159 +.P
160 +If the option to force an unlink of mounts at startup is used then processes
161 +whose working directory is within unlinked automounted directories will not
162 +get the correct pwd from the system. This is because, after the mount is
163 +unlinked from the mount tree, anything that needs to walk back up the mount
164 +tree to construct a path, such as getcwd(2) and the proc filesystem
165 +/proc/<pid>/cwd, cannot work because the point from which the path is
166 +constructed has been detached from the mount tree.
167  .SH "SEE ALSO"
168  .BR autofs (5),
169  .BR autofs (8),
170 diff --git a/redhat/autofs.init.in b/redhat/autofs.init.in
171 index 65c786e..471667e 100644
172 --- a/redhat/autofs.init.in
173 +++ b/redhat/autofs.init.in
174 @@ -137,6 +137,10 @@ case "$1" in
175         start)
176                 start
177                 ;;
178 +       forcestart)
179 +               OPTIONS="$OPTIONS --force"
180 +               start
181 +               ;;
182         stop)
183                 stop
184                 ;;
185 @@ -146,6 +150,10 @@ case "$1" in
186         restart)
187                 restart
188                 ;;
189 +       forcerestart)
190 +               OPTIONS="$OPTIONS --force"
191 +               restart
192 +               ;;
193         reload)
194                 reload
195                 ;;
196 @@ -155,7 +163,7 @@ case "$1" in
197                 fi
198                 ;;
199         *)
200 -               echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
201 +               echo $"Usage: $0 {start|forcestart|stop|status|restart|orcerestart|reload|condrestart}"
202                 exit 1;
203                 ;;
204  esac
205 diff --git a/samples/rc.autofs.in b/samples/rc.autofs.in
206 index 51f5b02..2877fe2 100644
207 --- a/samples/rc.autofs.in
208 +++ b/samples/rc.autofs.in
209 @@ -117,17 +117,25 @@ case "$1" in
210         start)
211                 start
212                 ;;
213 +       forcestart)
214 +               OPTIONS="$OPTIONS --force"
215 +               start
216 +               ;;
217         stop)
218                 stop
219                 ;;
220         restart)
221                 restart
222                 ;;
223 +       forcerestart)
224 +               OPTIONS="$OPTIONS --force"
225 +               restart
226 +               ;;
227         reload)
228                 reload
229                 ;;
230         *)
231 -               echo $"Usage: $0 {start|stop|restart|reload}"
232 +               echo $"Usage: $0 {start|forcestart|stop|restart|forcerestart|reload}"
233                 exit 1;
234                 ;;
235  esac
This page took 0.039947 seconds and 3 git commands to generate.