1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
4 # T2 SDE: package/.../autofs/2-fg.patch
5 # Copyright (C) 2006 The T2 SDE Project
7 # More information can be found in the files COPYING and README.
9 # This patch file is dual-licensed. It is available under the license the
10 # patched project is licensed under, as long as it is an OpenSource license
11 # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
12 # of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
15 # --- T2-COPYRIGHT-NOTE-END ---
17 add -f --foreground option which prevents automount from daemonizing
18 adapted from: http://lkml.org/lkml/2004/10/7/217 by Denis Vlasenko
20 diff -urpN autofs-4.1.4/daemon/automount.c autofs-4.1.4-fg/daemon/automount.c
21 --- autofs-4.1.4/daemon/automount.c 2005-03-06 06:43:55.000000000 -0300
22 +++ autofs-4.1.4-fg/daemon/automount.c 2006-02-12 10:21:38.000000000 -0300
23 @@ -60,6 +60,7 @@ static int submount = 0;
25 int do_verbose = 0; /* Verbose feedback option */
26 int do_debug = 0; /* Enable full debug output */
27 +int daemonize = 1; /* Shall we daemonize? */
29 sigset_t ready_sigs; /* signals only accepted in ST_READY */
30 sigset_t lock_sigs; /* signals blocked for locking */
31 @@ -1282,7 +1283,7 @@ static void become_daemon(void)
34 /* Detach from foreground process */
36 + if (!submount && daemonize) {
40 @@ -1311,9 +1311,15 @@
41 * ouselves from the controling tty. This ensures we don't get unexpected
42 * signals. This call also sets us as the process group leader.
44 - if (!submount && (setsid() == -1)) {
48 + if (daemonize && (setsid() == -1)) {
52 + if (!daemonize && (setpgrp() == -1)) {
53 + crit("setpgrp: %m");
59 @@ -1327,7 +1328,7 @@ static void become_daemon(void)
60 crit("redirecting file descriptors failed: %m");
64 + if (nullfd > 2) close(nullfd);
66 /* Write pid file if requested */
68 @@ -1379,7 +1380,19 @@ static unsigned long getnumopt(char *str
70 static void usage(void)
72 - fprintf(stderr, "Usage: %s [options] path map_type [args...]\n", program);
74 + "Usage: %s [options] path map_type [args...]\n"
75 + " -h --help this text\n"
76 + " -p --pid-file f write process id to file f\n"
77 + " -t --timeout n auto-unmount in n seconds (0-disable)\n"
78 + " -f --foreground do not daemonize\n"
79 + " -v --verbose be verbose\n"
80 + " -d --debug be even more verbose\n"
81 + " -V --version print version and exit\n"
82 + /* " -g --ghost \n" */
83 + /* " --submount \n" */
88 static void setup_signals(__sighandler_t event_handler, __sighandler_t cld_handler)
89 @@ -1666,6 +1679,7 @@ int main(int argc, char *argv[])
91 {"pid-file", 1, 0, 'p'},
92 {"timeout", 1, 0, 't'},
93 + {"foreground", 0, 0, 'f'},
94 {"verbose", 0, 0, 'v'},
96 {"version", 0, 0, 'V'},
97 @@ -1683,7 +1697,7 @@ int main(int argc, char *argv[])
98 ap.dir_created = 0; /* We haven't created the main directory yet */
101 - while ((opt = getopt_long(argc, argv, "+hp:t:vdVg", long_options, NULL)) != EOF) {
102 + while ((opt = getopt_long(argc, argv, "+hp:t:fvdVg", long_options, NULL)) != EOF) {
106 @@ -1697,6 +1711,10 @@ int main(int argc, char *argv[])
107 ap.exp_timeout = getnumopt(optarg, opt);