* updated wlroots (0.17.3 -> 0.18.1)
[t2sde.git] / package / filesystem / autofs / 2-fg.patch
blob0403bb5026b0a157160dc21ce6f391f05ca49413
1 # --- T2-COPYRIGHT-NOTE-BEGIN ---
2 # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
3 #
4 # T2 SDE: package/.../autofs/2-fg.patch
5 # Copyright (C) 2006 The T2 SDE Project
6 #
7 # More information can be found in the files COPYING and README.
8 #
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
14 # version.
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)
32 chdir("/");
34 /* Detach from foreground process */
35 - if (!submount) {
36 + if (!submount && daemonize) {
37 pid = fork();
38 if (pid > 0)
39 exit(0);
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)) {
45 - crit("setsid: %m");
46 - exit(1);
47 + if (!submount) {
48 + if (daemonize && (setsid() == -1)) {
49 + crit("setsid: %m");
50 + exit(1);
51 + }
52 + if (!daemonize && (setpgrp() == -1)) {
53 + crit("setpgrp: %m");
54 + exit(1);
55 + }
57 my_pgrp = getpgrp();
59 @@ -1327,7 +1328,7 @@ static void become_daemon(void)
60 crit("redirecting file descriptors failed: %m");
61 exit(1);
63 - close(nullfd);
64 + if (nullfd > 2) close(nullfd);
66 /* Write pid file if requested */
67 if (pid_file) {
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);
73 + fprintf(stderr,
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" */
84 + , program
85 + );
88 static void setup_signals(__sighandler_t event_handler, __sighandler_t cld_handler)
89 @@ -1666,6 +1679,7 @@ int main(int argc, char *argv[])
90 {"help", 0, 0, 'h'},
91 {"pid-file", 1, 0, 'p'},
92 {"timeout", 1, 0, 't'},
93 + {"foreground", 0, 0, 'f'},
94 {"verbose", 0, 0, 'v'},
95 {"debug", 0, 0, 'd'},
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 */
100 opterr = 0;
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) {
103 switch (opt) {
104 case 'h':
105 usage();
106 @@ -1697,6 +1711,10 @@ int main(int argc, char *argv[])
107 ap.exp_timeout = getnumopt(optarg, opt);
108 break;
110 + case 'f':
111 + daemonize = 0;
112 + break;
114 case 'v':
115 do_verbose = 1;
116 break;