OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
3.7 KiB

  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 ---
  16. add -f --foreground option which prevents automount from daemonizing
  17. adapted from: http://lkml.org/lkml/2004/10/7/217 by Denis Vlasenko
  18. diff -urpN autofs-4.1.4/daemon/automount.c autofs-4.1.4-fg/daemon/automount.c
  19. --- autofs-4.1.4/daemon/automount.c 2005-03-06 06:43:55.000000000 -0300
  20. +++ autofs-4.1.4-fg/daemon/automount.c 2006-02-12 10:21:38.000000000 -0300
  21. @@ -60,6 +60,7 @@ static int submount = 0;
  22. int do_verbose = 0; /* Verbose feedback option */
  23. int do_debug = 0; /* Enable full debug output */
  24. +int daemonize = 1; /* Shall we daemonize? */
  25. sigset_t ready_sigs; /* signals only accepted in ST_READY */
  26. sigset_t lock_sigs; /* signals blocked for locking */
  27. @@ -1282,7 +1283,7 @@ static void become_daemon(void)
  28. chdir("/");
  29. /* Detach from foreground process */
  30. - if (!submount) {
  31. + if (!submount && daemonize) {
  32. pid = fork();
  33. if (pid > 0)
  34. exit(0);
  35. @@ -1311,9 +1311,15 @@
  36. * ouselves from the controling tty. This ensures we don't get unexpected
  37. * signals. This call also sets us as the process group leader.
  38. */
  39. - if (!submount && (setsid() == -1)) {
  40. - crit("setsid: %m");
  41. - exit(1);
  42. + if (!submount) {
  43. + if (daemonize && (setsid() == -1)) {
  44. + crit("setsid: %m");
  45. + exit(1);
  46. + }
  47. + if (!daemonize && (setpgrp() == -1)) {
  48. + crit("setpgrp: %m");
  49. + exit(1);
  50. + }
  51. }
  52. my_pgrp = getpgrp();
  53. @@ -1327,7 +1328,7 @@ static void become_daemon(void)
  54. crit("redirecting file descriptors failed: %m");
  55. exit(1);
  56. }
  57. - close(nullfd);
  58. + if (nullfd > 2) close(nullfd);
  59. /* Write pid file if requested */
  60. if (pid_file) {
  61. @@ -1379,7 +1380,19 @@ static unsigned long getnumopt(char *str
  62. static void usage(void)
  63. {
  64. - fprintf(stderr, "Usage: %s [options] path map_type [args...]\n", program);
  65. + fprintf(stderr,
  66. + "Usage: %s [options] path map_type [args...]\n"
  67. + " -h --help this text\n"
  68. + " -p --pid-file f write process id to file f\n"
  69. + " -t --timeout n auto-unmount in n seconds (0-disable)\n"
  70. + " -f --foreground do not daemonize\n"
  71. + " -v --verbose be verbose\n"
  72. + " -d --debug be even more verbose\n"
  73. + " -V --version print version and exit\n"
  74. + /* " -g --ghost \n" */
  75. + /* " --submount \n" */
  76. + , program
  77. + );
  78. }
  79. static void setup_signals(__sighandler_t event_handler, __sighandler_t cld_handler)
  80. @@ -1666,6 +1679,7 @@ int main(int argc, char *argv[])
  81. {"help", 0, 0, 'h'},
  82. {"pid-file", 1, 0, 'p'},
  83. {"timeout", 1, 0, 't'},
  84. + {"foreground", 0, 0, 'f'},
  85. {"verbose", 0, 0, 'v'},
  86. {"debug", 0, 0, 'd'},
  87. {"version", 0, 0, 'V'},
  88. @@ -1683,7 +1697,7 @@ int main(int argc, char *argv[])
  89. ap.dir_created = 0; /* We haven't created the main directory yet */
  90. opterr = 0;
  91. - while ((opt = getopt_long(argc, argv, "+hp:t:vdVg", long_options, NULL)) != EOF) {
  92. + while ((opt = getopt_long(argc, argv, "+hp:t:fvdVg", long_options, NULL)) != EOF) {
  93. switch (opt) {
  94. case 'h':
  95. usage();
  96. @@ -1697,6 +1711,10 @@ int main(int argc, char *argv[])
  97. ap.exp_timeout = getnumopt(optarg, opt);
  98. break;
  99. + case 'f':
  100. + daemonize = 0;
  101. + break;
  102. +
  103. case 'v':
  104. do_verbose = 1;
  105. break;