* [PATCH 0/5] rediffed patches
@ 2005-02-11 9:55 Denis Vlasenko
2005-02-11 9:58 ` [PATCH 1/5] use PATH Denis Vlasenko
` (3 more replies)
0 siblings, 4 replies; 20+ messages in thread
From: Denis Vlasenko @ 2005-02-11 9:55 UTC (permalink / raw)
To: autofs
Originally done against 4.1.3. Rediffed against 4.1.4_beta1 now
Please comment /apply
--
vda
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 1/5] use PATH
2005-02-11 9:55 [PATCH 0/5] rediffed patches Denis Vlasenko
@ 2005-02-11 9:58 ` Denis Vlasenko
2005-02-11 9:59 ` Denis Vlasenko
` (2 subsequent siblings)
3 siblings, 0 replies; 20+ messages in thread
From: Denis Vlasenko @ 2005-02-11 9:58 UTC (permalink / raw)
To: autofs
Use exec*p() so that root can use PATH to direct automount
to desired mount binary and the like
--
vda
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 1/5] use PATH
2005-02-11 9:55 [PATCH 0/5] rediffed patches Denis Vlasenko
2005-02-11 9:58 ` [PATCH 1/5] use PATH Denis Vlasenko
@ 2005-02-11 9:59 ` Denis Vlasenko
2005-02-11 10:01 ` [PATCH 2/5] add --foreground option Denis Vlasenko
2005-02-13 12:26 ` [PATCH 0/5] rediffed patches raven
2005-02-13 13:25 ` raven
3 siblings, 1 reply; 20+ messages in thread
From: Denis Vlasenko @ 2005-02-11 9:59 UTC (permalink / raw)
To: autofs
[-- Attachment #1: Type: text/plain, Size: 143 bytes --]
Use exec*p() so that root can use PATH to direct automount
to desired mount binary and the like
This time, even with patch attached :)
--
vda
[-- Attachment #2: 414b1.01.exec.patch --]
[-- Type: text/x-diff, Size: 1680 bytes --]
diff -urpN autofs-4.1.4_beta1.orig/daemon/spawn.c autofs-4.1.4_beta1_1/daemon/spawn.c
--- autofs-4.1.4_beta1.orig/daemon/spawn.c Mon Jan 17 17:22:28 2005
+++ autofs-4.1.4_beta1_1/daemon/spawn.c Fri Feb 11 10:49:53 2005
@@ -225,8 +225,8 @@ static int do_spawn(int logpri, int use_
dup2(pipefd[1], STDERR_FILENO);
close(pipefd[1]);
- execv(prog, (char *const *) argv);
- _exit(255); /* execv() failed */
+ execvp(prog, (char *const *) argv);
+ _exit(255); /* exec() failed */
} else {
/* Careful here -- if we enable SIGCHLD yet we may not receive the
waitpid() at the end */
diff -urpN autofs-4.1.4_beta1.orig/modules/lookup_program.c autofs-4.1.4_beta1_1/modules/lookup_program.c
--- autofs-4.1.4_beta1.orig/modules/lookup_program.c Fri Dec 31 08:30:09 2004
+++ autofs-4.1.4_beta1_1/modules/lookup_program.c Fri Feb 11 10:49:53 2005
@@ -139,8 +139,8 @@ int lookup_mount(const char *root, const
dup2(epipefd[1], STDERR_FILENO);
close(pipefd[1]);
close(epipefd[1]);
- execl(ctxt->mapname, ctxt->mapname, name, NULL);
- _exit(255); /* execl() failed */
+ execlp(ctxt->mapname, ctxt->mapname, name, NULL);
+ _exit(255); /* exec() failed */
}
close(pipefd[1]);
close(epipefd[1]);
diff -urpN autofs-4.1.4_beta1.orig/modules/mount_autofs.c autofs-4.1.4_beta1_1/modules/mount_autofs.c
--- autofs-4.1.4_beta1.orig/modules/mount_autofs.c Mon Jan 10 15:28:29 2005
+++ autofs-4.1.4_beta1_1/modules/mount_autofs.c Fri Feb 11 10:49:53 2005
@@ -159,7 +159,7 @@ int mount_mount(const char *root, const
goto error;
} else if (slave == 0) {
/* Slave process */
- execv(PATH_AUTOMOUNT, argv);
+ execvp(PATH_AUTOMOUNT, argv);
_exit(255);
}
[-- Attachment #3: Type: text/plain, Size: 140 bytes --]
_______________________________________________
autofs mailing list
autofs@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/autofs
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 2/5] add --foreground option
2005-02-11 9:59 ` Denis Vlasenko
@ 2005-02-11 10:01 ` Denis Vlasenko
2005-02-11 10:03 ` [PATCH 3/5] logging to stderr Denis Vlasenko
0 siblings, 1 reply; 20+ messages in thread
From: Denis Vlasenko @ 2005-02-11 10:01 UTC (permalink / raw)
To: autofs
[-- Attachment #1: Type: text/plain, Size: 81 bytes --]
Add support for running in foreground:
-f --foreground do not daemonize
--
vda
[-- Attachment #2: 414b1.12.fg.patch --]
[-- Type: text/x-diff, Size: 2934 bytes --]
diff -urpN autofs-4.1.4_beta1_1/daemon/automount.c autofs-4.1.4_beta1_2/daemon/automount.c
--- autofs-4.1.4_beta1_1/daemon/automount.c Wed Jan 26 15:03:02 2005
+++ autofs-4.1.4_beta1_2/daemon/automount.c Fri Feb 11 10:49:55 2005
@@ -60,6 +60,7 @@ static int submount = 0;
int do_verbose = 0; /* Verbose feedback option */
int do_debug = 0; /* Enable full debug output */
+int daemonize = 1; /* Shall we daemonize? */
sigset_t ready_sigs; /* signals only accepted in ST_READY */
sigset_t lock_sigs; /* signals blocked for locking */
@@ -1282,7 +1283,7 @@ static void become_daemon(void)
chdir("/");
/* Detach from foreground process */
- if (!submount) {
+ if (!submount && daemonize) {
pid = fork();
if (pid > 0)
exit(0);
@@ -1300,7 +1301,7 @@ static void become_daemon(void)
my_pid = getpid();
/* Make our own process group for "magic" reason: processes that share
- our pgrp see the raw filesystem behine the magic. So if we are a
+ our pgrp see the raw filesystem behind the magic. So if we are a
submount, don't change -- otherwise we won't be able to actually
perform the mount. A pgrp is also useful for controlling all the
child processes we generate. */
@@ -1321,7 +1322,7 @@ static void become_daemon(void)
crit("redirecting file descriptors failed: %m");
exit(1);
}
- close(nullfd);
+ if (nullfd > 2) close(nullfd);
/* Write pid file if requested */
if (pid_file) {
@@ -1373,7 +1374,19 @@ static unsigned long getnumopt(char *str
static void usage(void)
{
- fprintf(stderr, "Usage: %s [options] path map_type [args...]\n", program);
+ fprintf(stderr,
+ "Usage: %s [options] path map_type [args...]\n"
+ " -h --help this text\n"
+ " -p --pid-file f write process id to file f\n"
+ " -t --timeout n auto-unmount in n seconds (0-disable)\n"
+ " -f --foreground do not daemonize\n"
+ " -v --verbose be verbose\n"
+ " -d --debug be even more verbose\n"
+ " -V --version print version and exit\n"
+ /* " -g --ghost \n" */
+ /* " --submount \n" */
+ , program
+ );
}
static void setup_signals(__sighandler_t event_handler, __sighandler_t cld_handler)
@@ -1660,6 +1673,7 @@ int main(int argc, char *argv[])
{"help", 0, 0, 'h'},
{"pid-file", 1, 0, 'p'},
{"timeout", 1, 0, 't'},
+ {"foreground", 0, 0, 'f'},
{"verbose", 0, 0, 'v'},
{"debug", 0, 0, 'd'},
{"version", 0, 0, 'V'},
@@ -1677,7 +1691,7 @@ int main(int argc, char *argv[])
ap.dir_created = 0; /* We haven't created the main directory yet */
opterr = 0;
- while ((opt = getopt_long(argc, argv, "+hp:t:vdVg", long_options, NULL)) != EOF) {
+ while ((opt = getopt_long(argc, argv, "+hp:t:fvdVg", long_options, NULL)) != EOF) {
switch (opt) {
case 'h':
usage();
@@ -1689,6 +1703,10 @@ int main(int argc, char *argv[])
case 't':
ap.exp_timeout = getnumopt(optarg, opt);
+ break;
+
+ case 'f':
+ daemonize = 0;
break;
case 'v':
[-- Attachment #3: Type: text/plain, Size: 140 bytes --]
_______________________________________________
autofs mailing list
autofs@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/autofs
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 3/5] logging to stderr
2005-02-11 10:01 ` [PATCH 2/5] add --foreground option Denis Vlasenko
@ 2005-02-11 10:03 ` Denis Vlasenko
2005-02-11 10:06 ` [PATCH 4/5] switch to new logging Denis Vlasenko
2005-02-14 15:21 ` [PATCH 3/5] logging to stderr Jeff Moyer
0 siblings, 2 replies; 20+ messages in thread
From: Denis Vlasenko @ 2005-02-11 10:03 UTC (permalink / raw)
To: autofs
[-- Attachment #1: Type: text/plain, Size: 67 bytes --]
Add code, but do not switch rest of program to use it, yet.
--
vda
[-- Attachment #2: 414b1.23.stderr.patch --]
[-- Type: text/x-diff, Size: 6840 bytes --]
diff -urpN autofs-4.1.4_beta1_2/daemon/automount.c autofs-4.1.4_beta1_3/daemon/automount.c
--- autofs-4.1.4_beta1_2/daemon/automount.c Fri Feb 11 10:49:55 2005
+++ autofs-4.1.4_beta1_3/daemon/automount.c Fri Feb 11 10:49:57 2005
@@ -62,6 +62,8 @@ int do_verbose = 0; /* Verbose feedback
int do_debug = 0; /* Enable full debug output */
int daemonize = 1; /* Shall we daemonize? */
+int log_stderr; /* Use stderr instead of syslog? */
+
sigset_t ready_sigs; /* signals only accepted in ST_READY */
sigset_t lock_sigs; /* signals blocked for locking */
sigset_t sigchld_mask;
@@ -1277,7 +1279,6 @@ static void become_daemon(void)
{
FILE *pidfp;
pid_t pid;
- int nullfd;
/* Don't BUSY any directories unnecessarily */
chdir("/");
@@ -1294,8 +1295,12 @@ static void become_daemon(void)
}
}
- /* Open syslog */
- openlog("automount", LOG_PID, LOG_DAEMON);
+ /* Initialize logging subsystem */
+ if(!log_stderr) {
+ log_to_syslog();
+ } else {
+ log_to_stderr();
+ }
/* Initialize global data */
my_pid = getpid();
@@ -1311,19 +1316,6 @@ static void become_daemon(void)
}
my_pgrp = getpgrp();
- /* Redirect all our file descriptors to /dev/null */
- if ((nullfd = open("/dev/null", O_RDWR)) < 0) {
- crit("cannot open /dev/null: %m");
- exit(1);
- }
-
- if (dup2(nullfd, STDIN_FILENO) < 0 ||
- dup2(nullfd, STDOUT_FILENO) < 0 || dup2(nullfd, STDERR_FILENO) < 0) {
- crit("redirecting file descriptors failed: %m");
- exit(1);
- }
- if (nullfd > 2) close(nullfd);
-
/* Write pid file if requested */
if (pid_file) {
if ((pidfp = fopen(pid_file, "wt"))) {
@@ -1380,6 +1372,7 @@ static void usage(void)
" -p --pid-file f write process id to file f\n"
" -t --timeout n auto-unmount in n seconds (0-disable)\n"
" -f --foreground do not daemonize\n"
+ " -s --stderr log to stderr instead of syslog\n"
" -v --verbose be verbose\n"
" -d --debug be even more verbose\n"
" -V --version print version and exit\n"
@@ -1674,6 +1667,7 @@ int main(int argc, char *argv[])
{"pid-file", 1, 0, 'p'},
{"timeout", 1, 0, 't'},
{"foreground", 0, 0, 'f'},
+ {"stderr", 0, 0, 's'},
{"verbose", 0, 0, 'v'},
{"debug", 0, 0, 'd'},
{"version", 0, 0, 'V'},
@@ -1691,7 +1685,7 @@ int main(int argc, char *argv[])
ap.dir_created = 0; /* We haven't created the main directory yet */
opterr = 0;
- while ((opt = getopt_long(argc, argv, "+hp:t:fvdVg", long_options, NULL)) != EOF) {
+ while ((opt = getopt_long(argc, argv, "+hp:t:fsvdVg", long_options, NULL)) != EOF) {
switch (opt) {
case 'h':
usage();
@@ -1707,6 +1701,10 @@ int main(int argc, char *argv[])
case 'f':
daemonize = 0;
+ break;
+
+ case 's':
+ log_stderr = 1;
break;
case 'v':
diff -urpN autofs-4.1.4_beta1_2/include/automount.h autofs-4.1.4_beta1_3/include/automount.h
--- autofs-4.1.4_beta1_2/include/automount.h Wed Jan 26 15:03:02 2005
+++ autofs-4.1.4_beta1_3/include/automount.h Fri Feb 11 11:42:54 2005
@@ -286,21 +286,16 @@ int allow_owner_mount(const char *);
extern int do_verbose;
extern int do_debug;
-#define info(msg, args...) \
-if (do_verbose || do_debug) \
- syslog(LOG_INFO, msg, ##args);
+extern void (*info)(const char* msg, ...);
+extern void (*notice)(const char* msg, ...);
+extern void (*warn)(const char* msg, ...);
+extern void (*error)(const char* msg, ...);
+extern void (*crit)(const char* msg, ...);
+extern void (*debug)(const char* msg, ...);
-#define warn(msg, args...) \
-if (do_verbose || do_debug) \
- syslog(LOG_WARNING, msg, ##args);
+void log_to_syslog();
+void log_to_stderr();
-#define error(msg, args...) syslog(LOG_ERR, msg, ##args);
-
-#define crit(msg, args...) syslog(LOG_CRIT, msg, ##args);
-
-#define debug(msg, args...) \
-if (do_debug) \
- syslog(LOG_DEBUG, msg, ##args);
#endif
diff -urpN autofs-4.1.4_beta1_2/lib/Makefile autofs-4.1.4_beta1_3/lib/Makefile
--- autofs-4.1.4_beta1_2/lib/Makefile Sun Jan 9 11:16:43 2005
+++ autofs-4.1.4_beta1_3/lib/Makefile Fri Feb 11 10:49:57 2005
@@ -12,7 +12,7 @@ RANLIB = /usr/bin/ranlib
SRCS = cache.c listmount.c cat_path.c rpc_subs.c mounts.c lock.c
RPCS = mount.h mount_clnt.c mount_xdr.c
OBJS = cache.o mount_clnt.o mount_xdr.o listmount.o \
- cat_path.o rpc_subs.o mounts.o lock.o
+ cat_path.o rpc_subs.o mounts.o lock.o log.o
LIB = autofs.a
@@ -47,6 +47,10 @@ mount_xdr.o: mount_xdr.c
listmount.o: listmount.c
$(CC) $(CFLAGS) -o listmount.o -c listmount.c
$(STRIP) listmount.o
+
+log.o: log.c
+ $(CC) $(CFLAGS) -o log.o -c log.c
+ $(STRIP) log.o
install: all
diff -urpN autofs-4.1.4_beta1_2/lib/log.c autofs-4.1.4_beta1_3/lib/log.c
--- autofs-4.1.4_beta1_2/lib/log.c Thu Jan 1 03:00:00 1970
+++ autofs-4.1.4_beta1_3/lib/log.c Fri Feb 11 10:49:57 2005
@@ -0,0 +1,103 @@
+#include <stdarg.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <unistd.h>
+#include <fcntl.h> /* open() */
+#include <stdlib.h> /* exit() */
+
+#include "automount.h"
+
+static void null(const char *msg, ...)
+{
+}
+
+static void syslog_debug(const char *msg, ...)
+{
+ va_list ap;
+ va_start(ap, msg);
+ syslog(LOG_DEBUG, msg, ap);
+ va_end(ap);
+}
+
+static void syslog_info(const char *msg, ...)
+{
+ va_list ap;
+ va_start(ap, msg);
+ syslog(LOG_INFO, msg, ap);
+ va_end(ap);
+}
+
+static void syslog_warn(const char *msg, ...)
+{
+ va_list ap;
+ va_start(ap, msg);
+ syslog(LOG_WARNING, msg, ap);
+ va_end(ap);
+}
+
+static void syslog_err(const char *msg, ...)
+{
+ va_list ap;
+ va_start(ap, msg);
+ syslog(LOG_ERR, msg, ap);
+ va_end(ap);
+}
+
+static void syslog_crit(const char *msg, ...)
+{
+ va_list ap;
+ va_start(ap, msg);
+ syslog(LOG_CRIT, msg, ap);
+ va_end(ap);
+}
+
+static void to_stderr(const char *msg, ...)
+{
+ va_list ap;
+ va_start(ap, msg);
+ vfprintf(stderr, msg, ap);
+ va_end(ap);
+}
+
+void log_to_syslog()
+{
+ int nullfd;
+
+ openlog("automount", LOG_PID, LOG_DAEMON);
+ if (do_debug) debug = syslog_debug;
+ if (do_verbose || do_debug) {
+ info = syslog_info;
+ warn = syslog_warn;
+ }
+ error = syslog_err;
+ crit = syslog_crit;
+
+ /* Redirect all our file descriptors to /dev/null */
+ if ((nullfd = open("/dev/null", O_RDWR)) < 0) {
+ crit("cannot open /dev/null: %m");
+ exit(1);
+ }
+ if (dup2(nullfd, STDIN_FILENO) < 0 ||
+ dup2(nullfd, STDOUT_FILENO) < 0 || dup2(nullfd, STDERR_FILENO) < 0) {
+ crit("redirecting file descriptors failed: %m");
+ exit(1);
+ }
+ if (nullfd > 2) close(nullfd);
+}
+
+void log_to_stderr()
+{
+ if (do_debug) debug = to_stderr;
+ if (do_verbose || do_debug) {
+ info = to_stderr;
+ warn = to_stderr;
+ }
+ error = to_stderr;
+ crit = to_stderr;
+}
+
+void (*info)(const char* msg, ...) = null;
+void (*warn)(const char* msg, ...) = null;
+void (*error)(const char* msg, ...) = null;
+void (*crit)(const char* msg, ...) = null;
+void (*debug)(const char* msg, ...) = null;
[-- Attachment #3: Type: text/plain, Size: 140 bytes --]
_______________________________________________
autofs mailing list
autofs@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/autofs
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 4/5] switch to new logging
2005-02-11 10:03 ` [PATCH 3/5] logging to stderr Denis Vlasenko
@ 2005-02-11 10:06 ` Denis Vlasenko
2005-02-11 10:09 ` [PATCH 5/5] Denis Vlasenko
2005-02-14 15:21 ` [PATCH 3/5] logging to stderr Jeff Moyer
1 sibling, 1 reply; 20+ messages in thread
From: Denis Vlasenko @ 2005-02-11 10:06 UTC (permalink / raw)
To: autofs
[-- Attachment #1: Type: text/plain, Size: 90 bytes --]
Convert rest of code to new logging functions.
Use --stderr option to activate it.
--
vda
[-- Attachment #2: 414b1.34.syslog.patch --]
[-- Type: text/x-diff, Size: 20596 bytes --]
diff -urpN autofs-4.1.4_beta1_3/daemon/automount.c autofs-4.1.4_beta1_4/daemon/automount.c
--- autofs-4.1.4_beta1_3/daemon/automount.c Fri Feb 11 10:49:57 2005
+++ autofs-4.1.4_beta1_4/daemon/automount.c Fri Feb 11 10:49:58 2005
@@ -39,7 +39,7 @@
#include <linux/auto_fs4.h>
#ifndef NDEBUG
-#define assert(x) do { if (!(x)) { syslog(LOG_CRIT, __FILE__ ":%d: assertion failed: " #x, __LINE__); } } while(0)
+#define assert(x) do { if (!(x)) { crit(__FILE__ ":%d: assertion failed: " #x, __LINE__); } } while(0)
#else
#define assert(x) do { } while(0)
#endif
@@ -162,7 +162,7 @@ static int umount_ent(const char *root,
umount_ok = 1;
if (umount_ok || is_smbfs) {
- rv = spawnll(LOG_DEBUG,
+ rv = spawnll(debug,
PATH_UMOUNT, PATH_UMOUNT, path_buf, NULL);
}
}
@@ -224,7 +224,7 @@ static int rm_unwanted_fn(const char *fi
if (st->st_dev != ap.dev)
return 0;
} else {
- info("rm_unwanted: %s\n", file);
+ info("rm_unwanted: %s", file);
if (S_ISDIR(st->st_mode))
rmdir(file);
else if (!S_ISLNK(st->st_mode) || rmsymlink)
@@ -257,7 +257,7 @@ static int umount_multi(const char *path
struct mnt_list *mntlist = NULL;
struct mnt_list *mptr;
- debug("umount_multi: path=%s incl=%d\n", path, incl);
+ debug("umount_multi: path=%s incl=%d", path, incl);
mntlist = get_mnt_list(_PATH_MOUNTED, path, incl);
@@ -269,7 +269,7 @@ static int umount_multi(const char *path
left = 0;
for (mptr = mntlist; mptr != NULL; mptr = mptr->next) {
- debug("umount_multi: unmounting dir=%s\n", mptr->path);
+ debug("umount_multi: unmounting dir=%s", mptr->path);
if (umount_ent("", mptr->path, mptr->fs_type)) {
left++;
}
@@ -316,13 +316,13 @@ static int do_umount_autofs(void)
struct stat st;
int ret;
- rv = spawnll(LOG_DEBUG,
+ rv = spawnll(debug,
PATH_UMOUNT, PATH_UMOUNT, ap.path, NULL);
if (rv & MTAB_NOTUPDATED) {
info("umount %s succeeded: "
"mtab not updated, retrying to clean\n",
ap.path);
- rv = spawnll(LOG_DEBUG,
+ rv = spawnll(debug,
PATH_UMOUNT, PATH_UMOUNT, ap.path, NULL);
}
ret = stat(ap.path, &st);
@@ -332,16 +332,16 @@ static int do_umount_autofs(void)
break;
}
if (i < retries - 1) {
- info("umount %s failed: retrying...\n", ap.path);
+ info("umount %s failed: retrying...", ap.path);
sleep(1);
}
}
if (rv != 0 || i == retries) {
- error("can't unmount %s\n", ap.path);
+ error("can't unmount %s", ap.path);
DB(kill(0, SIGSTOP));
} else {
if (i != 0)
- info("umount %s succeeded\n", ap.path);
+ info("umount %s succeeded", ap.path);
if (submount)
rm_unwanted(ap.path, 1, 1);
@@ -452,7 +452,7 @@ static int mount_autofs(char *path)
}
our_name[len] = '\0';
- if (spawnll(LOG_DEBUG, PATH_MOUNT, PATH_MOUNT,
+ if (spawnll(debug, PATH_MOUNT, PATH_MOUNT,
"-t", "autofs", "-o", options, our_name, path, NULL) != 0) {
crit("failed to mount autofs path %s", ap.path);
rmdir_path(ap.path);
@@ -530,7 +530,7 @@ static int send_ready(unsigned int wait_
{
if (wait_queue_token == 0)
return 0;
- debug("send_ready: token=%d\n", wait_queue_token);
+ debug("send_ready: token=%d", wait_queue_token);
if (ioctl(ap.ioctlfd, AUTOFS_IOC_READY, wait_queue_token) < 0) {
error("AUTOFS_IOC_READY: %m");
return 1;
@@ -542,9 +542,9 @@ static int send_fail(unsigned int wait_q
{
if (wait_queue_token == 0)
return 0;
- debug("send_fail: token=%d\n", wait_queue_token);
+ debug("send_fail: token=%d", wait_queue_token);
if (ioctl(ap.ioctlfd, AUTOFS_IOC_FAIL, wait_queue_token) < 0) {
- syslog(LOG_ERR, "AUTOFS_IOC_FAIL: %m");
+ error("AUTOFS_IOC_FAIL: %m");
return 1;
}
return 0;
@@ -562,7 +562,7 @@ static enum states handle_child(int hang
while ((pid = waitpid(-1, &status, hang ? 0 : WNOHANG)) > 0) {
struct pending_mount volatile *mt, *volatile *mtp;
- debug("handle_child: got pid %d, sig %d (%d), stat %d\n",
+ debug("handle_child: got pid %d, sig %d (%d), stat %d",
pid, WIFSIGNALED(status),
WTERMSIG(status), WEXITSTATUS(status));
@@ -676,7 +676,7 @@ static void sig_child(int sig)
static int st_ready(void)
{
- debug("st_ready(): state = %d\n", ap.state);
+ debug("st_ready(): state = %d", ap.state);
ap.state = ST_READY;
sigprocmask(SIG_UNBLOCK, &lock_sigs, NULL);
@@ -786,7 +786,7 @@ static enum expire expire_proc(int now)
* words) the umounts are done by the time we reach here
*/
if ((count = count_mounts(ap.path))) {
- debug("expire_proc: %d remaining in %s\n", count, ap.path);
+ debug("expire_proc: %d remaining in %s", count, ap.path);
exit(1);
}
exit(0);
@@ -841,7 +841,7 @@ static int st_prepare_shutdown(void)
/* Unmount everything */
exp = expire_proc(1);
- debug("prep_shutdown: expire returns %d\n", exp);
+ debug("prep_shutdown: expire returns %d", exp);
switch (exp) {
case EXP_ERROR:
@@ -865,7 +865,7 @@ static int st_prepare_shutdown(void)
static int st_prune(void)
{
- debug("st_prune(): state = %d\n", ap.state);
+ debug("st_prune(): state = %d", ap.state);
assert(ap.state == ST_READY);
@@ -893,7 +893,7 @@ static int st_prune(void)
static int st_expire(void)
{
- debug("st_expire(): state = %d\n", ap.state);
+ debug("st_expire(): state = %d", ap.state);
assert(ap.state == ST_READY);
@@ -950,7 +950,7 @@ static int get_pkt(int fd, union autofs_
if (poll(fds, 2, -1) == -1) {
if (errno == EINTR)
continue;
- syslog(LOG_ERR, "get_pkt: poll failed: %m");
+ error("get_pkt: poll failed: %s", strerror(errno));
return -1;
}
@@ -1022,7 +1022,7 @@ static int handle_packet_missing(const s
pid_t f;
struct pending_mount *mt = NULL;
- debug("handle_packet_missing: token %ld, name %s\n",
+ debug("handle_packet_missing: token %ld, name %s",
pkt->wait_queue_token, pkt->name);
/* Ignore packet if we're trying to shut down */
@@ -1172,7 +1172,7 @@ static void do_expire(const char *name,
chdir("/");
if (ret)
- error("failed to recover from partial expiry of %s\n",
+ error("failed to recover from partial expiry of %s",
buf);
}
}
@@ -1242,7 +1242,7 @@ static int handle_packet_expire_multi(co
{
int ret;
- debug("handle_packet_expire_multi: token %ld, name %s\n",
+ debug("handle_packet_expire_multi: token %ld, name %s",
pkt->wait_queue_token, pkt->name);
ret = handle_expire(pkt->name, pkt->len, pkt->wait_queue_token);
@@ -1259,7 +1259,7 @@ static int handle_packet(void)
if (get_pkt(ap.pipefd, &pkt))
return -1;
- debug("handle_packet: type = %d\n", pkt.hdr.type);
+ debug("handle_packet: type = %d", pkt.hdr.type);
switch (pkt.hdr.type) {
case autofs_ptype_missing:
@@ -1271,7 +1271,7 @@ static int handle_packet(void)
case autofs_ptype_expire_multi:
return handle_packet_expire_multi(&pkt.expire_multi);
}
- error("handle_packet: unknown packet type %d\n", pkt.hdr.type);
+ error("handle_packet: unknown packet type %d", pkt.hdr.type);
return -1;
}
@@ -1294,7 +1294,6 @@ static void become_daemon(void)
exit(1);
}
}
-
/* Initialize logging subsystem */
if(!log_stderr) {
log_to_syslog();
@@ -1322,7 +1321,8 @@ static void become_daemon(void)
fprintf(pidfp, "%lu\n", (unsigned long) my_pid);
fclose(pidfp);
} else {
- warn("failed to write pid file %s: %m", pid_file);
+ warn("failed to write pid file %s: %s", pid_file,
+ strerror(errno));
pid_file = NULL;
}
}
@@ -1731,7 +1731,7 @@ int main(int argc, char *argv[])
}
if (geteuid() != 0) {
- fprintf(stderr, "%s: This program must be run by root.\n", program);
+ fprintf(stderr, "%s: This program must be run by root\n", program);
exit(1);
}
@@ -1758,9 +1758,9 @@ int main(int argc, char *argv[])
#ifdef DEBUG
if (mapargc) {
int i;
- syslog(LOG_DEBUG, "Map argc = %d", mapargc);
+ debug("Map argc = %d", mapargc);
for (i = 0; i < mapargc; i++)
- syslog(LOG_DEBUG, "Map argv[%d] = %s", i, mapargv[i]);
+ debug("Map argv[%d] = %s", i, mapargv[i]);
}
#endif
diff -urpN autofs-4.1.4_beta1_3/daemon/spawn.c autofs-4.1.4_beta1_4/daemon/spawn.c
--- autofs-4.1.4_beta1_3/daemon/spawn.c Fri Feb 11 10:49:53 2005
+++ autofs-4.1.4_beta1_4/daemon/spawn.c Fri Feb 11 10:49:58 2005
@@ -196,7 +196,7 @@ out:
#define ERRBUFSIZ 2047 /* Max length of error string excl \0 */
-static int do_spawn(int logpri, int use_lock, const char *prog, const char *const *argv)
+static int do_spawn(logger* log, int use_lock, const char *prog, const char *const *argv)
{
pid_t f;
int status, pipefd[2];
@@ -257,7 +257,7 @@ static int do_spawn(int logpri, int use_
while (errp && (p = memchr(sp, '\n', errp))) {
*p++ = '\0';
if (sp[0]) /* Don't output empty lines */
- syslog(logpri, ">> %s", sp);
+ log(">> %s", sp);
errp -= (p - sp);
sp = p;
}
@@ -268,7 +268,7 @@ static int do_spawn(int logpri, int use_
if (errp >= ERRBUFSIZ) {
/* Line too long, split */
errbuf[errp] = '\0';
- syslog(logpri, ">> %s", errbuf);
+ log(">> %s", errbuf);
errp = 0;
}
}
@@ -278,7 +278,7 @@ static int do_spawn(int logpri, int use_
if (errp > 0) {
/* End of file without \n */
errbuf[errp] = '\0';
- syslog(logpri, ">> %s", errbuf);
+ log(">> %s", errbuf);
}
if (waitpid(f, &status, 0) != f)
@@ -293,12 +293,12 @@ static int do_spawn(int logpri, int use_
}
}
-int spawnv(int logpri, const char *prog, const char *const *argv)
+int spawnv(logger* log, const char *prog, const char *const *argv)
{
- return do_spawn(logpri, 0, prog, argv);
+ return do_spawn(log, 0, prog, argv);
}
-int spawnl(int logpri, const char *prog, ...)
+int spawnl(logger* log, const char *prog, ...)
{
va_list arg;
int argc;
@@ -316,10 +316,10 @@ int spawnl(int logpri, const char *prog,
while ((*p++ = va_arg(arg, char *)));
va_end(arg);
- return do_spawn(logpri, 0, prog, (const char **) argv);
+ return do_spawn(log, 0, prog, (const char **) argv);
}
-int spawnll(int logpri, const char *prog, ...)
+int spawnll(logger* log, const char *prog, ...)
{
va_list arg;
int argc;
@@ -337,5 +337,5 @@ int spawnll(int logpri, const char *prog
while ((*p++ = va_arg(arg, char *)));
va_end(arg);
- return do_spawn(logpri, 1, prog, (const char **) argv);
+ return do_spawn(log, 1, prog, (const char **) argv);
}
diff -urpN autofs-4.1.4_beta1_3/include/automount.h autofs-4.1.4_beta1_4/include/automount.h
--- autofs-4.1.4_beta1_3/include/automount.h Fri Feb 11 11:42:54 2005
+++ autofs-4.1.4_beta1_4/include/automount.h Fri Feb 11 10:59:20 2005
@@ -117,13 +117,29 @@ struct autofs_point {
extern struct autofs_point ap;
+/* log notification */
+extern int do_verbose;
+extern int do_debug;
+
+extern void (*info)(const char* msg, ...);
+extern void (*notice)(const char* msg, ...);
+extern void (*warn)(const char* msg, ...);
+extern void (*error)(const char* msg, ...);
+extern void (*crit)(const char* msg, ...);
+extern void (*debug)(const char* msg, ...);
+
+typedef void logger(const char* msg, ...);
+
+void log_to_syslog();
+void log_to_stderr();
+
/* Standard function used by daemon or modules */
int aquire_lock(void);
void release_lock(void);
-int spawnll(int logpri, const char *prog, ...);
-int spawnl(int logpri, const char *prog, ...);
-int spawnv(int logpri, const char *prog, const char *const *argv);
+int spawnll(logger* log, const char *prog, ...);
+int spawnl(logger* log, const char *prog, ...);
+int spawnv(logger* log, const char *prog, const char *const *argv);
void reset_signals(void);
void ignore_signals(void);
void discard_pending(int sig);
@@ -282,20 +298,4 @@ int is_mounted(const char *table, const
int has_fstab_option(const char *path, const char *opt);
int allow_owner_mount(const char *);
-/* log notification */
-extern int do_verbose;
-extern int do_debug;
-
-extern void (*info)(const char* msg, ...);
-extern void (*notice)(const char* msg, ...);
-extern void (*warn)(const char* msg, ...);
-extern void (*error)(const char* msg, ...);
-extern void (*crit)(const char* msg, ...);
-extern void (*debug)(const char* msg, ...);
-
-void log_to_syslog();
-void log_to_stderr();
-
-
#endif
-
diff -urpN autofs-4.1.4_beta1_3/lib/log.c autofs-4.1.4_beta1_4/lib/log.c
--- autofs-4.1.4_beta1_3/lib/log.c Fri Feb 11 10:49:57 2005
+++ autofs-4.1.4_beta1_4/lib/log.c Fri Feb 11 10:49:58 2005
@@ -11,6 +11,13 @@ static void null(const char *msg, ...)
{
}
+void (*info)(const char* msg, ...) = null;
+void (*notice)(const char* msg, ...) = null;
+void (*warn)(const char* msg, ...) = null;
+void (*error)(const char* msg, ...) = null;
+void (*crit)(const char* msg, ...) = null;
+void (*debug)(const char* msg, ...) = null;
+
static void syslog_debug(const char *msg, ...)
{
va_list ap;
@@ -27,6 +34,14 @@ static void syslog_info(const char *msg,
va_end(ap);
}
+static void syslog_notice(const char *msg, ...)
+{
+ va_list ap;
+ va_start(ap, msg);
+ syslog(LOG_NOTICE, msg, ap);
+ va_end(ap);
+}
+
static void syslog_warn(const char *msg, ...)
{
va_list ap;
@@ -56,6 +71,7 @@ static void to_stderr(const char *msg, .
va_list ap;
va_start(ap, msg);
vfprintf(stderr, msg, ap);
+ fputc('\n',stderr);
va_end(ap);
}
@@ -67,13 +83,15 @@ void log_to_syslog()
if (do_debug) debug = syslog_debug;
if (do_verbose || do_debug) {
info = syslog_info;
+ notice = syslog_notice;
warn = syslog_warn;
}
error = syslog_err;
crit = syslog_crit;
/* Redirect all our file descriptors to /dev/null */
- if ((nullfd = open("/dev/null", O_RDWR)) < 0) {
+ nullfd = open("/dev/null", O_RDWR);
+ if (nullfd < 0) {
crit("cannot open /dev/null: %m");
exit(1);
}
@@ -90,14 +108,9 @@ void log_to_stderr()
if (do_debug) debug = to_stderr;
if (do_verbose || do_debug) {
info = to_stderr;
+ notice = to_stderr;
warn = to_stderr;
}
error = to_stderr;
crit = to_stderr;
}
-
-void (*info)(const char* msg, ...) = null;
-void (*warn)(const char* msg, ...) = null;
-void (*error)(const char* msg, ...) = null;
-void (*crit)(const char* msg, ...) = null;
-void (*debug)(const char* msg, ...) = null;
diff -urpN autofs-4.1.4_beta1_3/modules/lookup_hesiod.c autofs-4.1.4_beta1_4/modules/lookup_hesiod.c
--- autofs-4.1.4_beta1_3/modules/lookup_hesiod.c Fri Dec 31 08:30:08 2004
+++ autofs-4.1.4_beta1_4/modules/lookup_hesiod.c Fri Feb 11 10:49:58 2005
@@ -82,7 +82,7 @@ int lookup_mount(const char *root, const
hes_result = hes_resolve(name, "filsys");
if (!hes_result || !hes_result[0]) {
- warn(MODPREFIX "entry \"%s\" not found in map\n", name);
+ warn(MODPREFIX "entry \"%s\" not found in map", name);
return 1;
}
diff -urpN autofs-4.1.4_beta1_3/modules/lookup_yp.c autofs-4.1.4_beta1_4/modules/lookup_yp.c
--- autofs-4.1.4_beta1_3/modules/lookup_yp.c Wed Jan 26 09:21:21 2005
+++ autofs-4.1.4_beta1_4/modules/lookup_yp.c Fri Feb 11 10:49:58 2005
@@ -69,7 +69,7 @@ int lookup_init(const char *mapfmt, int
/* This should, but doesn't, take a const char ** */
err = yp_get_default_domain((char **) &ctxt->domainname);
if (err) {
- crit(MODPREFIX "map %s: %s\n", ctxt->mapname,
+ crit(MODPREFIX "map %s: %s", ctxt->mapname,
yperr_string(err));
return 1;
}
diff -urpN autofs-4.1.4_beta1_3/modules/mount_bind.c autofs-4.1.4_beta1_4/modules/mount_bind.c
--- autofs-4.1.4_beta1_3/modules/mount_bind.c Mon Jan 10 15:28:29 2005
+++ autofs-4.1.4_beta1_4/modules/mount_bind.c Fri Feb 11 11:12:18 2005
@@ -59,7 +59,7 @@ int mount_init(void **context)
if (lstat(tmp1, &st1) == -1)
goto out;
- err = spawnl(LOG_DEBUG,
+ err = spawnl(debug,
PATH_MOUNT, PATH_MOUNT, "-n", "--bind", tmp1, tmp2, NULL);
if (err == 0 &&
@@ -68,8 +68,8 @@ int mount_init(void **context)
bind_works = 1;
}
- debug(MODPREFIX "bind_works = %d\n", bind_works);
- spawnl(LOG_DEBUG,
+ debug(MODPREFIX "bind_works = %d", bind_works);
+ spawnl(debug,
PATH_UMOUNT, PATH_UMOUNT, "-n", tmp2, NULL);
out:
@@ -131,7 +131,7 @@ int mount_mount(const char *root, const
"calling mount --bind " SLOPPY " -o %s %s %s",
options, what, fullpath);
- err = spawnll(LOG_NOTICE,
+ err = spawnll(notice,
PATH_MOUNT, PATH_MOUNT, "--bind",
SLOPPYOPT "-o", options,
what, fullpath, NULL);
diff -urpN autofs-4.1.4_beta1_3/modules/mount_changer.c autofs-4.1.4_beta1_4/modules/mount_changer.c
--- autofs-4.1.4_beta1_3/modules/mount_changer.c Sun Jan 9 11:16:43 2005
+++ autofs-4.1.4_beta1_4/modules/mount_changer.c Fri Feb 11 11:13:04 2005
@@ -68,7 +68,7 @@ int mount_mount(const char *root, const
debug(MODPREFIX "calling umount %s", what);
- err = spawnll(LOG_DEBUG,
+ err = spawnll(debug,
PATH_UMOUNT, PATH_UMOUNT, what, NULL);
if (err) {
error(MODPREFIX "umount of %s failed (all may be unmounted)",
@@ -98,14 +98,14 @@ int mount_mount(const char *root, const
debug(MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
fstype, options, what, fullpath);
- err = spawnll(LOG_DEBUG,
+ err = spawnll(debug,
PATH_MOUNT, PATH_MOUNT, "-t", fstype,
SLOPPYOPT "-o", options, what, fullpath, NULL);
} else {
debug(MODPREFIX "calling mount -t %s %s %s",
fstype, what, fullpath);
- err = spawnll(LOG_DEBUG, PATH_MOUNT, PATH_MOUNT,
+ err = spawnll(debug, PATH_MOUNT, PATH_MOUNT,
"-t", fstype, what, fullpath, NULL);
}
@@ -164,7 +164,7 @@ int swapCD(const char *device, const cha
/* close device */
status = close(fd);
if (status != 0) {
- error(MODPREFIX "close failed for `%s': %s\n",
+ error(MODPREFIX "close failed for `%s': %s",
device, strerror(errno));
return 1;
}
diff -urpN autofs-4.1.4_beta1_3/modules/mount_ext2.c autofs-4.1.4_beta1_4/modules/mount_ext2.c
--- autofs-4.1.4_beta1_3/modules/mount_ext2.c Mon Jan 10 15:28:29 2005
+++ autofs-4.1.4_beta1_4/modules/mount_ext2.c Fri Feb 11 11:45:49 2005
@@ -93,10 +93,10 @@ int mount_mount(const char *root, const
#endif
if (ro) {
debug(MODPREFIX "calling %s -n %s", fsck_prog, what);
- err = spawnl(LOG_DEBUG, fsck_prog, fsck_prog, "-n", what, NULL);
+ err = spawnl(debug, fsck_prog, fsck_prog, "-n", what, NULL);
} else {
debug(MODPREFIX "calling %s -p %s", fsck_prog, what);
- err = spawnl(LOG_DEBUG, fsck_prog, fsck_prog, "-p", what, NULL);
+ err = spawnl(debug, fsck_prog, fsck_prog, "-p", what, NULL);
}
if (err & ~6) {
@@ -108,13 +108,13 @@ int mount_mount(const char *root, const
if (options) {
debug(MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
fstype, options, what, fullpath);
- err = spawnll(LOG_NOTICE,
+ err = spawnll(notice,
PATH_MOUNT, PATH_MOUNT, "-t", fstype,
SLOPPYOPT "-o", options, what, fullpath, NULL);
} else {
debug(MODPREFIX "calling mount -t %s %s %s",
fstype, what, fullpath);
- err = spawnll(LOG_NOTICE,
+ err = spawnll(notice,
PATH_MOUNT, PATH_MOUNT, "-t", fstype,
what, fullpath, NULL);
}
diff -urpN autofs-4.1.4_beta1_3/modules/mount_generic.c autofs-4.1.4_beta1_4/modules/mount_generic.c
--- autofs-4.1.4_beta1_3/modules/mount_generic.c Mon Jan 10 15:28:29 2005
+++ autofs-4.1.4_beta1_4/modules/mount_generic.c Fri Feb 11 11:12:46 2005
@@ -77,13 +77,13 @@ int mount_mount(const char *root, const
debug(MODPREFIX "calling mount -t %s " SLOPPY "-o %s %s %s",
fstype, options, what, fullpath);
- err = spawnll(LOG_NOTICE,
+ err = spawnll(notice,
PATH_MOUNT, PATH_MOUNT, "-t", fstype,
SLOPPYOPT "-o", options, what, fullpath, NULL);
} else {
debug(MODPREFIX "calling mount -t %s %s %s",
fstype, what, fullpath);
- err = spawnll(LOG_NOTICE,
+ err = spawnll(notice,
PATH_MOUNT, PATH_MOUNT, "-t", fstype,
what, fullpath, NULL);
}
diff -urpN autofs-4.1.4_beta1_3/modules/mount_nfs.c autofs-4.1.4_beta1_4/modules/mount_nfs.c
--- autofs-4.1.4_beta1_3/modules/mount_nfs.c Mon Jan 10 15:28:29 2005
+++ autofs-4.1.4_beta1_4/modules/mount_nfs.c Fri Feb 11 10:49:58 2005
@@ -458,14 +458,14 @@ int mount_mount(const char *root, const
debug(MODPREFIX "calling mount -t nfs " SLOPPY
" -o %s %s %s", nfsoptions, whatstr, fullpath);
- err = spawnll(LOG_NOTICE,
+ err = spawnll(notice,
PATH_MOUNT, PATH_MOUNT, "-t",
"nfs", SLOPPYOPT "-o", nfsoptions,
whatstr, fullpath, NULL);
} else {
debug(MODPREFIX "calling mount -t nfs %s %s",
whatstr, fullpath);
- err = spawnll(LOG_NOTICE,
+ err = spawnll(notice,
PATH_MOUNT, PATH_MOUNT, "-t",
"nfs", whatstr, fullpath, NULL);
}
[-- Attachment #3: Type: text/plain, Size: 140 bytes --]
_______________________________________________
autofs mailing list
autofs@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/autofs
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 5/5]
2005-02-11 10:06 ` [PATCH 4/5] switch to new logging Denis Vlasenko
@ 2005-02-11 10:09 ` Denis Vlasenko
0 siblings, 0 replies; 20+ messages in thread
From: Denis Vlasenko @ 2005-02-11 10:09 UTC (permalink / raw)
To: autofs
[-- Attachment #1: Type: text/plain, Size: 219 bytes --]
Replace %m with %s + strerror(errno) because stderr logging
do not support %m.
While we're at it, fix lots of places with stray newlines.
I run tested all these patches applied on top of 4.1.4_beta1,
in order.
--
vda
[-- Attachment #2: 414b1.45.msg.patch --]
[-- Type: text/x-diff, Size: 25651 bytes --]
diff -urpN autofs-4.1.4_beta1_4/daemon/automount.c autofs-4.1.4_beta1_5/daemon/automount.c
--- autofs-4.1.4_beta1_4/daemon/automount.c Fri Feb 11 10:49:58 2005
+++ autofs-4.1.4_beta1_5/daemon/automount.c Fri Feb 11 11:46:11 2005
@@ -320,7 +320,7 @@ static int do_umount_autofs(void)
PATH_UMOUNT, PATH_UMOUNT, ap.path, NULL);
if (rv & MTAB_NOTUPDATED) {
info("umount %s succeeded: "
- "mtab not updated, retrying to clean\n",
+ "mtab not updated, retrying to clean",
ap.path);
rv = spawnll(debug,
PATH_UMOUNT, PATH_UMOUNT, ap.path, NULL);
@@ -484,7 +484,7 @@ static int mount_autofs(char *path)
static void nextstate(enum states next)
{
if (write(ap.state_pipe[1], &next, sizeof(next)) != sizeof(next))
- error("nextstate: write failed %m");
+ error("nextstate: write failed %s", strerror(errno));
}
/* Deal with all the signal-driven events in the state machine */
@@ -532,7 +532,7 @@ static int send_ready(unsigned int wait_
return 0;
debug("send_ready: token=%d", wait_queue_token);
if (ioctl(ap.ioctlfd, AUTOFS_IOC_READY, wait_queue_token) < 0) {
- error("AUTOFS_IOC_READY: %m");
+ error("AUTOFS_IOC_READY: %s", strerror(errno));
return 1;
}
return 0;
@@ -544,7 +544,7 @@ static int send_fail(unsigned int wait_q
return 0;
debug("send_fail: token=%d", wait_queue_token);
if (ioctl(ap.ioctlfd, AUTOFS_IOC_FAIL, wait_queue_token) < 0) {
- error("AUTOFS_IOC_FAIL: %m");
+ error("AUTOFS_IOC_FAIL: %s", strerror(errno));
return 1;
}
return 0;
@@ -792,7 +792,7 @@ static enum expire expire_proc(int now)
exit(0);
case -1:
- error("expire: fork failed: %m");
+ error("expire: fork failed: %s", strerror(errno));
sigprocmask(SIG_SETMASK, &old, NULL);
return EXP_ERROR;
@@ -809,7 +809,7 @@ static int st_readmap(void)
status = ap.lookup->lookup_ghost(ap.path, ap.ghost, 0, ap.lookup->context);
- debug("st_readmap: status %d\n", status);
+ debug("st_readmap: status %d", status);
/* If I don't exist in the map any more then exit */
if (status == LKP_FAIL)
@@ -822,7 +822,7 @@ static int st_prepare_shutdown(void)
{
int exp;
- info("prep_shutdown: state = %d\n", ap.state);
+ info("prep_shutdown: state = %d", ap.state);
assert(ap.state == ST_READY || ap.state == ST_EXPIRE);
@@ -1045,7 +1045,7 @@ static int handle_packet_missing(const s
junk_mounts = junk_mounts->next;
} else {
if (!(mt = malloc(sizeof(struct pending_mount)))) {
- error("handle_packet_missing: malloc: %m");
+ error("handle_packet_missing: malloc failure");
send_fail(pkt->wait_queue_token);
return 1;
}
@@ -1071,7 +1071,7 @@ static int handle_packet_missing(const s
f = fork();
if (f == -1) {
sigprocmask(SIG_SETMASK, &oldsig, NULL);
- error("handle_packet_missing: fork: %m");
+ error("handle_packet_missing: fork: %s", strerror(errno));
send_fail(pkt->wait_queue_token);
free(mt);
@@ -1196,7 +1196,7 @@ static int handle_expire(const char *nam
} else {
if (!(mt = malloc(sizeof(struct pending_mount)))) {
sigprocmask(SIG_SETMASK, &olds, NULL);
- error("handle_expire: malloc: %m");
+ error("handle_expire: malloc failure");
return 1;
}
}
@@ -1204,7 +1204,7 @@ static int handle_expire(const char *nam
f = fork();
if (f == -1) {
sigprocmask(SIG_SETMASK, &olds, NULL);
- error("handle_expire: fork: %m");
+ error("handle_expire: fork: %", strerror(errno));
free(mt);
return 1;
@@ -1310,7 +1310,7 @@ static void become_daemon(void)
perform the mount. A pgrp is also useful for controlling all the
child processes we generate. */
if (!submount && setpgrp()) {
- crit("setpgrp: %m");
+ crit("setpgrp: %s", strerror(errno));
exit(1);
}
my_pgrp = getpgrp();
@@ -1344,7 +1344,8 @@ static void cleanup_exit(const char *pat
if ((!ap.ghost || !submount) && (*(path + 1) != '-') && ap.dir_created)
if (rmdir(path) == -1)
- warn("failed to remove dir %s: %m", path);
+ warn("failed to remove dir %s: %s",
+ path, strerror(errno));
exit(exit_code);
}
@@ -1558,7 +1559,7 @@ int handle_mounts(char *path)
if (!ioctl(ap.ioctlfd, AUTOFS_IOC_PROTOVER, &kproto_version)) {
/* If this ioctl() doesn't work, kernel does not support ghosting */
if (ioctl(ap.ioctlfd, AUTOFS_IOC_PROTOSUBVER, &kproto_sub_version)) {
- debug("kproto sub: %m");
+ debug("kproto sub: %s", strerror(errno));
kproto_sub_version = 0;
if (ap.ghost) {
ap.ghost = 0;
@@ -1566,7 +1567,7 @@ int handle_mounts(char *path)
}
}
} else {
- debug("kproto: %m");
+ debug("kproto: %s", strerror(errno));
kproto_version = 2;
}
diff -urpN autofs-4.1.4_beta1_4/daemon/module.c autofs-4.1.4_beta1_5/daemon/module.c
--- autofs-4.1.4_beta1_4/daemon/module.c Thu Jan 29 18:01:22 2004
+++ autofs-4.1.4_beta1_5/daemon/module.c Fri Feb 11 11:46:11 2005
@@ -37,7 +37,7 @@ struct lookup_mod *open_lookup(const cha
mod = malloc(sizeof(struct lookup_mod));
if (!mod) {
if (err_prefix)
- crit("%s%m", err_prefix);
+ crit("%smalloc failure", err_prefix);
return NULL;
}
@@ -46,7 +46,7 @@ struct lookup_mod *open_lookup(const cha
if (!fnbuf) {
free(mod);
if (err_prefix)
- crit("%s%m", err_prefix);
+ crit("%salloca failure", err_prefix);
return NULL;
}
snprintf(fnbuf, size_fnbuf, "%s/lookup_%s.so", AUTOFS_LIB_DIR, name);
@@ -114,7 +114,7 @@ struct parse_mod *open_parse(const char
mod = malloc(sizeof(struct parse_mod));
if (!mod) {
if (err_prefix)
- crit("%s%m", err_prefix);
+ crit("%smalloc failure", err_prefix);
return NULL;
}
@@ -123,7 +123,7 @@ struct parse_mod *open_parse(const char
if (!fnbuf) {
free(mod);
if (err_prefix)
- crit("%s%m", err_prefix);
+ crit("%salloca failure", err_prefix);
return NULL;
}
snprintf(fnbuf, size_fnbuf, "%s/parse_%s.so", AUTOFS_LIB_DIR, name);
@@ -189,7 +189,7 @@ struct mount_mod *open_mount(const char
mod = malloc(sizeof(struct mount_mod));
if (!mod) {
if (err_prefix)
- crit("%s%m", err_prefix);
+ crit("%smalloc failure", err_prefix);
return NULL;
}
@@ -198,7 +198,7 @@ struct mount_mod *open_mount(const char
if (!fnbuf) {
free(mod);
if (err_prefix)
- crit("%s%m", err_prefix);
+ crit("%salloca failure", err_prefix);
return NULL;
}
snprintf(fnbuf, size_fnbuf, "%s/mount_%s.so", AUTOFS_LIB_DIR, name);
diff -urpN autofs-4.1.4_beta1_4/lib/cache.c autofs-4.1.4_beta1_5/lib/cache.c
--- autofs-4.1.4_beta1_4/lib/cache.c Mon Jan 24 16:10:19 2005
+++ autofs-4.1.4_beta1_5/lib/cache.c Fri Feb 11 11:46:11 2005
@@ -436,8 +436,8 @@ int cache_ghost(const char *root, int gh
if (stat(fullpath, &st) == -1 && errno == ENOENT) {
if (mkdir_path(fullpath, 0555) < 0)
warn("cache_ghost: mkdir_path %s "
- "failed: %m",
- fullpath);
+ "failed: %s",
+ fullpath, strerror(errno));
}
break;
diff -urpN autofs-4.1.4_beta1_4/lib/mounts.c autofs-4.1.4_beta1_5/lib/mounts.c
--- autofs-4.1.4_beta1_4/lib/mounts.c Mon Jan 17 17:09:28 2005
+++ autofs-4.1.4_beta1_5/lib/mounts.c Fri Feb 11 11:46:11 2005
@@ -22,6 +22,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
+#include <errno.h>
#include "automount.h"
@@ -43,7 +44,7 @@ struct mnt_list *get_mnt_list(const char
tab = setmntent(table, "r");
if (!tab) {
- error("get_mntlist: setmntent: %m");
+ error("get_mntlist: setmntent: %s", strerror(errno));
return NULL;
}
@@ -261,7 +262,7 @@ static int find_mntent(const char *table
tab = setmntent(table, "r");
if (!tab) {
- error("find_mntent: setmntent: %m");
+ error("find_mntent: setmntent: %s", strerror(errno));
return 0;
}
diff -urpN autofs-4.1.4_beta1_4/modules/lookup_file.c autofs-4.1.4_beta1_5/modules/lookup_file.c
--- autofs-4.1.4_beta1_4/modules/lookup_file.c Wed Jan 26 07:31:38 2005
+++ autofs-4.1.4_beta1_5/modules/lookup_file.c Fri Feb 11 11:46:11 2005
@@ -57,7 +57,7 @@ int lookup_init(const char *mapfmt, int
struct stat st;
if (!(*context = ctxt = malloc(sizeof(struct lookup_context)))) {
- crit(MODPREFIX "malloc: %m");
+ crit(MODPREFIX "malloc failure");
return 1;
}
diff -urpN autofs-4.1.4_beta1_4/modules/lookup_hesiod.c autofs-4.1.4_beta1_5/modules/lookup_hesiod.c
--- autofs-4.1.4_beta1_4/modules/lookup_hesiod.c Fri Feb 11 10:49:58 2005
+++ autofs-4.1.4_beta1_5/modules/lookup_hesiod.c Fri Feb 11 11:46:11 2005
@@ -42,7 +42,7 @@ int lookup_init(const char *mapfmt, int
/* If we can't build a context, bail. */
if ((*context = ctxt = (struct lookup_context *)
malloc(sizeof(struct lookup_context))) == NULL) {
- crit(MODPREFIX "malloc: %m");
+ crit(MODPREFIX "malloc failure");
return 1;
}
diff -urpN autofs-4.1.4_beta1_4/modules/lookup_ldap.c autofs-4.1.4_beta1_5/modules/lookup_ldap.c
--- autofs-4.1.4_beta1_4/modules/lookup_ldap.c Wed Jan 26 09:21:21 2005
+++ autofs-4.1.4_beta1_5/modules/lookup_ldap.c Fri Feb 11 11:46:11 2005
@@ -106,7 +106,7 @@ int lookup_init(const char *mapfmt, int
ctxt = (struct lookup_context *) malloc(sizeof(struct lookup_context));
*context = ctxt;
if (ctxt == NULL) {
- crit(MODPREFIX "malloc: %m");
+ crit(MODPREFIX "malloc failure");
return 1;
}
memset(ctxt, 0, sizeof(struct lookup_context));
@@ -207,7 +207,7 @@ static int read_one_map(const char *root
query = alloca(l);
if (query == NULL) {
- crit(MODPREFIX "malloc: %m");
+ crit(MODPREFIX "malloc failure");
return 0;
}
@@ -396,7 +396,7 @@ static int lookup_one(const char *root,
query = alloca(l);
if (query == NULL) {
- crit(MODPREFIX "malloc: %m");
+ crit(MODPREFIX "malloc failure");
return 0;
}
@@ -504,7 +504,7 @@ static int lookup_wild(const char *root,
query = alloca(l);
if (query == NULL) {
- crit(MODPREFIX "malloc: %m");
+ crit(MODPREFIX "malloc failure");
return 0;
}
diff -urpN autofs-4.1.4_beta1_4/modules/lookup_multi.c autofs-4.1.4_beta1_5/modules/lookup_multi.c
--- autofs-4.1.4_beta1_4/modules/lookup_multi.c Fri Dec 31 08:30:08 2004
+++ autofs-4.1.4_beta1_5/modules/lookup_multi.c Fri Feb 11 11:46:11 2005
@@ -107,7 +107,7 @@ int lookup_init(const char *my_mapfmt, i
return 0;
nomem:
- crit(MODPREFIX "malloc: %m");
+ crit(MODPREFIX "malloc failure");
return 1;
}
diff -urpN autofs-4.1.4_beta1_4/modules/lookup_nisplus.c autofs-4.1.4_beta1_5/modules/lookup_nisplus.c
--- autofs-4.1.4_beta1_4/modules/lookup_nisplus.c Fri Dec 31 08:30:08 2004
+++ autofs-4.1.4_beta1_5/modules/lookup_nisplus.c Fri Feb 11 11:46:11 2005
@@ -36,13 +36,14 @@ int lookup_init(const char *mapfmt, int
{
struct lookup_context *ctxt;
- if (!(*context = ctxt = malloc(sizeof(struct lookup_context)))) {
- crit(MODPREFIX "%m");
+ *context = ctxt = malloc(sizeof(struct lookup_context));
+ if (!ctxt) {
+ crit(MODPREFIX "malloc failure");
return 1;
}
if (argc < 1) {
- crit(MODPREFIX "No map name");
+ crit(MODPREFIX "no map name");
return 1;
}
ctxt->mapname = argv[0];
diff -urpN autofs-4.1.4_beta1_4/modules/lookup_program.c autofs-4.1.4_beta1_5/modules/lookup_program.c
--- autofs-4.1.4_beta1_4/modules/lookup_program.c Fri Feb 11 10:49:53 2005
+++ autofs-4.1.4_beta1_5/modules/lookup_program.c Fri Feb 11 11:46:11 2005
@@ -48,7 +48,7 @@ int lookup_init(const char *mapfmt, int
struct lookup_context *ctxt;
if (!(*context = ctxt = malloc(sizeof(struct lookup_context)))) {
- crit(MODPREFIX "malloc: %m");
+ crit(MODPREFIX "malloc failure");
return 1;
}
@@ -103,7 +103,7 @@ int lookup_mount(const char *root, const
mapent = (char *)malloc(MAPENT_MAX_LEN + 1);
if (!mapent) {
- error(MODPREFIX "malloc: %s\n", strerror(errno));
+ error(MODPREFIX "malloc: %s", strerror(errno));
return 1;
}
@@ -114,7 +114,7 @@ int lookup_mount(const char *root, const
*/
if (pipe(pipefd)) {
- error(MODPREFIX "pipe: %m");
+ error(MODPREFIX "pipe: %s", strerror(errno));
goto out_free;
}
if (pipe(epipefd)) {
@@ -129,7 +129,7 @@ int lookup_mount(const char *root, const
close(pipefd[1]);
close(epipefd[0]);
close(epipefd[1]);
- error(MODPREFIX "fork: %m");
+ error(MODPREFIX "fork: %s", strerror(errno));
goto out_free;
} else if (f == 0) {
reset_signals();
@@ -204,7 +204,7 @@ int lookup_mount(const char *root, const
++alloci));
if (!tmp) {
alloci--;
- error(MODPREFIX "realloc: %s\n",
+ error(MODPREFIX "realloc: %s",
strerror(errno));
break;
}
@@ -264,7 +264,7 @@ int lookup_mount(const char *root, const
close(epipefd[0]);
if (waitpid(f, &status, 0) != f) {
- error(MODPREFIX "waitpid: %m");
+ error(MODPREFIX "waitpid: %s", strerror(errno));
goto out_free;
}
diff -urpN autofs-4.1.4_beta1_4/modules/lookup_userhome.c autofs-4.1.4_beta1_5/modules/lookup_userhome.c
--- autofs-4.1.4_beta1_4/modules/lookup_userhome.c Fri Dec 31 08:30:09 2004
+++ autofs-4.1.4_beta1_5/modules/lookup_userhome.c Fri Feb 11 11:46:11 2005
@@ -15,6 +15,7 @@
* ----------------------------------------------------------------------- */
#include <stdio.h>
+#include <string.h> /* strerror() */
#include <malloc.h>
#include <errno.h>
#include <pwd.h>
@@ -56,12 +57,12 @@ int lookup_mount(const char *root, const
/* Create the appropriate symlink */
if (chdir(root)) {
- error(MODPREFIX "chdir failed: %m");
+ error(MODPREFIX "chdir failed: %s", strerror(errno));
return 1;
}
if (symlink(pw->pw_dir, name) && errno != EEXIST) {
- error(MODPREFIX "symlink failed: %m");
+ error(MODPREFIX "symlink failed: %s", strerror(errno));
return 1;
}
diff -urpN autofs-4.1.4_beta1_4/modules/lookup_yp.c autofs-4.1.4_beta1_5/modules/lookup_yp.c
--- autofs-4.1.4_beta1_4/modules/lookup_yp.c Fri Feb 11 10:49:58 2005
+++ autofs-4.1.4_beta1_5/modules/lookup_yp.c Fri Feb 11 11:46:11 2005
@@ -55,13 +55,14 @@ int lookup_init(const char *mapfmt, int
struct lookup_context *ctxt;
int err;
- if (!(*context = ctxt = malloc(sizeof(struct lookup_context)))) {
- crit(MODPREFIX "%m");
+ *context = ctxt = malloc(sizeof(struct lookup_context));
+ if (!ctxt) {
+ crit(MODPREFIX "malloc failure");
return 1;
}
if (argc < 1) {
- crit(MODPREFIX "No map name");
+ crit(MODPREFIX "no map name");
return 1;
}
ctxt->mapname = argv[0];
diff -urpN autofs-4.1.4_beta1_4/modules/mount_autofs.c autofs-4.1.4_beta1_5/modules/mount_autofs.c
--- autofs-4.1.4_beta1_4/modules/mount_autofs.c Fri Feb 11 10:49:53 2005
+++ autofs-4.1.4_beta1_5/modules/mount_autofs.c Fri Feb 11 11:46:11 2005
@@ -45,7 +45,7 @@ int mount_mount(const char *root, const
fullpath = alloca(strlen(root) + name_len + 2);
if (!fullpath) {
- error(MODPREFIX "alloca: %m");
+ error(MODPREFIX "alloca failure");
return 1;
}
sprintf(fullpath, "%s/%s", root, name);
@@ -53,7 +53,7 @@ int mount_mount(const char *root, const
if (c_options) {
options = alloca(strlen(c_options) + 1);
if (!options) {
- error(MODPREFIX "alloca: %m");
+ error(MODPREFIX "alloca failure");
return 1;
}
strcpy(options, c_options);
@@ -64,7 +64,8 @@ int mount_mount(const char *root, const
debug(MODPREFIX "calling mkdir_path %s", fullpath);
if (mkdir_path(fullpath, 0555) && errno != EEXIST) {
- error(MODPREFIX "mkdir_path %s failed: %m", name);
+ error(MODPREFIX "mkdir_path %s failed: %s",
+ name, strerror(errno));
return 1;
}
@@ -155,7 +156,7 @@ int mount_mount(const char *root, const
slave = fork();
if (slave < 0) {
- error(MODPREFIX "fork: %m");
+ error(MODPREFIX "fork: %s", strerror(errno));
goto error;
} else if (slave == 0) {
/* Slave process */
@@ -163,9 +164,11 @@ int mount_mount(const char *root, const
_exit(255);
}
- while ((wp = waitpid(slave, &status, WUNTRACED)) == -1 && errno == EINTR);
+ while ((wp = waitpid(slave, &status, WUNTRACED)) == -1 && errno == EINTR)
+ /* do nothing */;
+
if (wp != slave) {
- error(MODPREFIX "waitpid: %m");
+ error(MODPREFIX "waitpid: %s", strerror(errno));
goto error;
}
diff -urpN autofs-4.1.4_beta1_4/modules/mount_bind.c autofs-4.1.4_beta1_5/modules/mount_bind.c
--- autofs-4.1.4_beta1_4/modules/mount_bind.c Fri Feb 11 11:12:18 2005
+++ autofs-4.1.4_beta1_5/modules/mount_bind.c Fri Feb 11 11:46:11 2005
@@ -91,7 +91,7 @@ int mount_mount(const char *root, const
fullpath = alloca(strlen(root) + name_len + 2);
if (!fullpath) {
- error(MODPREFIX "alloca: %m");
+ error(MODPREFIX "alloca failure");
return 1;
}
@@ -114,7 +114,8 @@ int mount_mount(const char *root, const
status = mkdir_path(fullpath, 0555);
if (status && errno != EEXIST) {
- error(MODPREFIX "mkdir_path %s failed: %m", fullpath);
+ error(MODPREFIX "mkdir_path %s failed: %s", fullpath,
+ strerror(errno));
return 1;
}
@@ -163,8 +164,8 @@ int mount_mount(const char *root, const
} else {
debug(MODPREFIX "calling mkdir_path %s", basepath);
if (mkdir_path(basepath, 0555) && errno != EEXIST) {
- error(MODPREFIX "mkdir_path %s failed: %m",
- basepath);
+ error(MODPREFIX "mkdir_path %s failed: %s",
+ basepath, strerror(errno));
return 1;
}
}
diff -urpN autofs-4.1.4_beta1_4/modules/mount_changer.c autofs-4.1.4_beta1_5/modules/mount_changer.c
--- autofs-4.1.4_beta1_4/modules/mount_changer.c Fri Feb 11 11:13:04 2005
+++ autofs-4.1.4_beta1_5/modules/mount_changer.c Fri Feb 11 11:46:12 2005
@@ -57,7 +57,7 @@ int mount_mount(const char *root, const
fullpath = alloca(strlen(root) + name_len + 2);
if (!fullpath) {
- error(MODPREFIX "alloca: %m");
+ error(MODPREFIX "alloca failure");
return 1;
}
@@ -79,7 +79,8 @@ int mount_mount(const char *root, const
status = mkdir_path(fullpath, 0555);
if (status && errno != EEXIST) {
- error(MODPREFIX "mkdir_path %s failed: %m", fullpath);
+ error(MODPREFIX "mkdir_path %s failed: %s", fullpath,
+ strerror(errno));
return 1;
}
@@ -140,7 +141,7 @@ int swapCD(const char *device, const cha
/* open device */
fd = open(device, O_RDONLY | O_NONBLOCK);
if (fd < 0) {
- error(MODPREFIX "Opening device %s failed : %s",
+ error(MODPREFIX "Opening device %s failed: %s",
device, strerror(errno));
return 1;
}
@@ -149,7 +150,7 @@ int swapCD(const char *device, const cha
total_slots_available = ioctl(fd, CDROM_CHANGER_NSLOTS);
if (total_slots_available <= 1) {
error(MODPREFIX
- "Device %s is not an ATAPI compliant CD changer.\n",
+ "Device %s is not an ATAPI compliant CD changer",
device);
return 1;
}
diff -urpN autofs-4.1.4_beta1_4/modules/mount_ext2.c autofs-4.1.4_beta1_5/modules/mount_ext2.c
--- autofs-4.1.4_beta1_4/modules/mount_ext2.c Fri Feb 11 11:45:49 2005
+++ autofs-4.1.4_beta1_5/modules/mount_ext2.c Fri Feb 11 11:46:12 2005
@@ -49,7 +49,7 @@ int mount_mount(const char *root, const
fullpath = alloca(strlen(root) + name_len + 2);
if (!fullpath) {
- error(MODPREFIX "alloca: %m");
+ error(MODPREFIX "alloca failure");
return 1;
}
@@ -62,7 +62,8 @@ int mount_mount(const char *root, const
status = mkdir_path(fullpath, 0555);
if (status && errno != EEXIST) {
- error(MODPREFIX "mkdir_path %s failed: %m", fullpath);
+ error(MODPREFIX "mkdir_path %s failed: %s", fullpath,\
+ strerror(errno));
return 1;
}
diff -urpN autofs-4.1.4_beta1_4/modules/mount_generic.c autofs-4.1.4_beta1_5/modules/mount_generic.c
--- autofs-4.1.4_beta1_4/modules/mount_generic.c Fri Feb 11 11:12:46 2005
+++ autofs-4.1.4_beta1_5/modules/mount_generic.c Fri Feb 11 11:46:12 2005
@@ -48,7 +48,7 @@ int mount_mount(const char *root, const
fullpath = alloca(strlen(root) + name_len + 2);
if (!fullpath) {
- error(MODPREFIX "alloca: %m");
+ error(MODPREFIX "alloca failure");
return 1;
}
@@ -61,7 +61,8 @@ int mount_mount(const char *root, const
status = mkdir_path(fullpath, 0555);
if (status && errno != EEXIST) {
- error(MODPREFIX "mkdir_path %s failed: %m", fullpath);
+ error(MODPREFIX "mkdir_path %s failed: %s", fullpath,
+ strerror(errno));
return 1;
}
diff -urpN autofs-4.1.4_beta1_4/modules/mount_nfs.c autofs-4.1.4_beta1_5/modules/mount_nfs.c
--- autofs-4.1.4_beta1_4/modules/mount_nfs.c Fri Feb 11 10:49:58 2005
+++ autofs-4.1.4_beta1_5/modules/mount_nfs.c Fri Feb 11 11:46:12 2005
@@ -75,7 +75,7 @@ int is_local_addr(const char *host, cons
sock = socket(AF_INET, SOCK_DGRAM, udpproto);
if (sock < 0) {
- error(MODPREFIX "socket creation failed: %m");
+ error(MODPREFIX "socket creation failed: %s", strerror(errno));
return -1;
}
@@ -85,14 +85,15 @@ int is_local_addr(const char *host, cons
ret = connect(sock, (struct sockaddr *) &src_addr, src_len);
if (ret < 0 ) {
- error(MODPREFIX "connect failed for %s: %m", host);
+ error(MODPREFIX "connect failed for %s: %s",
+ host, strerror(errno));
close(sock);
return 0;
}
ret = getsockname(sock, (struct sockaddr *) &local_addr, &local_len);
if (ret < 0) {
- error(MODPREFIX "getsockname failed: %m");
+ error(MODPREFIX "getsockname failed: %s", strerror(errno));
close(sock);
return 0;
}
@@ -335,7 +336,7 @@ int mount_mount(const char *root, const
whatstr = alloca(strlen(what) + 1);
if (!whatstr) {
- error(MODPREFIX "alloca: %m");
+ error(MODPREFIX "alloca failure");
return 1;
}
strcpy(whatstr, what);
@@ -375,7 +376,7 @@ int mount_mount(const char *root, const
#if 0
debug(MODPREFIX "*comma=%x %c comma=%p %s cp=%p %s "
- "nfsoptions=%p nfsp=%p end=%p used=%d len=%d\n",
+ "nfsoptions=%p nfsp=%p end=%p used=%d len=%d",
*comma, *comma, comma, comma, cp, cp,
nfsoptions, nfsp, nfsoptions + len,
nfsp - nfsoptions, len);
@@ -414,7 +415,7 @@ int mount_mount(const char *root, const
fullpath = alloca(strlen(root) + name_len + 2);
if (!fullpath) {
- error(MODPREFIX "alloca: %m");
+ error(MODPREFIX "alloca failure");
return 1;
}
@@ -441,7 +442,8 @@ int mount_mount(const char *root, const
status = mkdir_path(fullpath, 0555);
if (status && errno != EEXIST) {
- error(MODPREFIX "mkdir_path %s failed: %m", fullpath);
+ error(MODPREFIX "mkdir_path %s failed: %s", fullpath,
+ strerror(errno));
return 1;
}
diff -urpN autofs-4.1.4_beta1_4/modules/parse_sun.c autofs-4.1.4_beta1_5/modules/parse_sun.c
--- autofs-4.1.4_beta1_4/modules/parse_sun.c Sun Jan 23 16:47:40 2005
+++ autofs-4.1.4_beta1_5/modules/parse_sun.c Fri Feb 11 11:46:12 2005
@@ -367,7 +367,7 @@ int parse_init(int argc, const char *con
/* Set up context and escape chain */
if (!(ctxt = (struct parse_context *) malloc(sizeof(struct parse_context)))) {
- crit(MODPREFIX "malloc: %m");
+ crit(MODPREFIX "malloc failure");
return 1;
}
*context = (void *) ctxt;
@@ -384,7 +384,7 @@ int parse_init(int argc, const char *con
case 'D':
sv = malloc(sizeof(struct substvar));
if (!sv) {
- error(MODPREFIX "malloc: %m");
+ error(MODPREFIX "malloc failure");
break;
}
if (argv[i][2])
@@ -397,7 +397,7 @@ int parse_init(int argc, const char *con
}
if (!sv->def) {
- error(MODPREFIX "strdup: %m");
+ error(MODPREFIX "strdup failure");
free(sv);
} else {
sv->val = strchr(sv->def, '=');
@@ -462,7 +462,7 @@ int parse_init(int argc, const char *con
}
if (!noptstr) {
kill_context(ctxt);
- crit(MODPREFIX "%m");
+ crit(MODPREFIX "malloc failure");
return 1;
}
ctxt->optstr = noptstr;
@@ -546,7 +546,7 @@ static char *concat_options(char *left,
ret = malloc(strlen(left) + strlen(right) + 2);
if (ret == NULL) {
- error(MODPREFIX "concat_options malloc: %m");
+ error(MODPREFIX "concat_options malloc failure");
return NULL;
}
@@ -658,7 +658,7 @@ static int sun_mount(const char *root, c
}
debug(MODPREFIX
- "mounting root %s, mountpoint %s, what %s, fstype %s, options %s\n",
+ "mounting root %s, mountpoint %s, what %s, fstype %s, options %s",
root, mountpoint, what, fstype, options);
if (!strcmp(fstype, "nfs")) {
@@ -756,7 +756,7 @@ int parse_mount(const char *root, const
mapent_len = expandsunent(mapent, NULL, name, ctxt->subst, ctxt->slashify_colons);
pmapent = alloca(mapent_len + 1);
if (!pmapent) {
- error(MODPREFIX "alloca: %m");
+ error(MODPREFIX "alloca failure");
return 1;
}
@@ -766,7 +766,7 @@ int parse_mount(const char *root, const
options = strdup(ctxt->optstr ? ctxt->optstr : "");
if (!options) {
- error(MODPREFIX "strdup: %m");
+ error(MODPREFIX "strdup failure");
return 1;
}
optlen = strlen(options);
@@ -782,7 +782,8 @@ int parse_mount(const char *root, const
options = concat_options(options, noptions);
if (options == NULL) {
- error(MODPREFIX "concat_options: %m");
+ error(MODPREFIX
+ "concat_options malloc failure");
return 1;
}
p = skipspace(p);
@@ -798,7 +799,7 @@ int parse_mount(const char *root, const
multi_root = alloca(strlen(root) + name_len + 2);
if (!multi_root) {
- error(MODPREFIX "alloca: %m");
+ error(MODPREFIX "alloca failure");
free(options);
return 1;
}
@@ -813,7 +814,7 @@ int parse_mount(const char *root, const
char *path, *loc;
if (myoptions == NULL) {
- error(MODPREFIX "multi strdup: %m");
+ error(MODPREFIX "multi strdup failure");
free(options);
multi_free_list(head);
return 1;
@@ -841,7 +842,7 @@ int parse_mount(const char *root, const
if (myoptions == NULL) {
error(MODPREFIX
- "multi concat_options: %m");
+ "multi concat_options malloc_failure");
free(options);
free(path);
multi_free_list(head);
[-- Attachment #3: Type: text/plain, Size: 140 bytes --]
_______________________________________________
autofs mailing list
autofs@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/autofs
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/5] rediffed patches
2005-02-11 9:55 [PATCH 0/5] rediffed patches Denis Vlasenko
2005-02-11 9:58 ` [PATCH 1/5] use PATH Denis Vlasenko
2005-02-11 9:59 ` Denis Vlasenko
@ 2005-02-13 12:26 ` raven
2005-02-13 13:25 ` raven
3 siblings, 0 replies; 20+ messages in thread
From: raven @ 2005-02-13 12:26 UTC (permalink / raw)
To: Denis Vlasenko; +Cc: autofs
On Fri, 11 Feb 2005, Denis Vlasenko wrote:
> Originally done against 4.1.3. Rediffed against 4.1.4_beta1 now
>
> Please comment /apply
I like em.
I can see you've put a lot of effort into them and first glance looks
good.
I was going to put out beta2 tonight but now I've received your patches
I'm going to have to delay a couple of days (it's already late).
The fact that you've broken them down so I can see what's going on and the
way you've done the logging goes further than what I set out to do when I
first changed it. It's just what I wanted originally.
However, I must push back on the PATH patch claiming it's a security hole.
I would feel better about it if we overroad the PATH within the daemon
with something suitable.
Ian
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/5] rediffed patches
2005-02-11 9:55 [PATCH 0/5] rediffed patches Denis Vlasenko
` (2 preceding siblings ...)
2005-02-13 12:26 ` [PATCH 0/5] rediffed patches raven
@ 2005-02-13 13:25 ` raven
2005-02-13 13:42 ` Steinar H. Gunderson
3 siblings, 1 reply; 20+ messages in thread
From: raven @ 2005-02-13 13:25 UTC (permalink / raw)
To: Denis Vlasenko; +Cc: autofs
On Fri, 11 Feb 2005, Denis Vlasenko wrote:
> Originally done against 4.1.3. Rediffed against 4.1.4_beta1 now
>
> Please comment /apply
All that glitters is not gold.
My Ultra SPARC doesn't like the logging patches much.
Managed to carsh automount in a flash.
Still it could be my fault I'll check further.
Feb 13 21:20:14 donald automount[1786]: starting automounter version \b, path = (null), maptype = (null), mapname = (null)
Feb 13 21:20:14 donald automount[1786]: mount(bind): bind_works = -268438712
Feb 13 21:20:14 donald automount[1786]: using kernel protocol version -268437552.00
Feb 13 21:20:14 donald automount[1786]: using timeout -268437552 seconds; freq 0 secs
Feb 13 21:20:14 donald automount[1786]: ghosting enabled
Feb 13 21:20:30 donald automount[1786]: sig -268438664 switching from 0 to 0
Feb 13 21:20:30 donald automount[1786]: get_pkt: state -268438184, next 8
Feb 13 21:20:30 donald automount[1786]: st_expire(): state = -268438288
Feb 13 21:20:30 donald automount[1786]: expire_proc: exp_proc=-268438808
Feb 13 21:20:30 donald automount[1786]: handle_child: got pid -268439072, sig 0 (0), stat 0
Feb 13 21:20:30 donald automount[1786]: sigchld: exp -268439072 finished, switching from 0 to 0
Feb 13 21:20:30 donald automount[1786]: get_pkt: state -268438184, next 8
Feb 13 21:20:30 donald automount[1786]: st_ready(): state = -268438288
Feb 13 21:20:38 donald automount[1786]: handle_packet: type = -268437928
Feb 13 21:20:38 donald automount[1786]: process -268445208 got unexpected signal 0!
Feb 13 21:20:38 donald automount[1786]: sig -268445208 switching from 0 to 0
Ian
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/5] rediffed patches
2005-02-13 13:25 ` raven
@ 2005-02-13 13:42 ` Steinar H. Gunderson
2005-02-14 1:10 ` Ian Kent
0 siblings, 1 reply; 20+ messages in thread
From: Steinar H. Gunderson @ 2005-02-13 13:42 UTC (permalink / raw)
To: autofs
On Sun, Feb 13, 2005 at 09:25:29PM +0800, raven@themaw.net wrote:
> My Ultra SPARC doesn't like the logging patches much.
> Managed to carsh automount in a flash.
Could we please postpone these patches for 4.1.5? I'd like as few things as
possible to break for 4.1.4, at least, since that's probably the version
we'll be using in Debian sarge.
/* Steinar */
--
Homepage: http://www.sesse.net/
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 0/5] rediffed patches
2005-02-13 13:42 ` Steinar H. Gunderson
@ 2005-02-14 1:10 ` Ian Kent
0 siblings, 0 replies; 20+ messages in thread
From: Ian Kent @ 2005-02-14 1:10 UTC (permalink / raw)
To: Steinar H. Gunderson; +Cc: autofs
On Sun, 13 Feb 2005, Steinar H. Gunderson wrote:
> On Sun, Feb 13, 2005 at 09:25:29PM +0800, raven@themaw.net wrote:
> > My Ultra SPARC doesn't like the logging patches much.
> > Managed to carsh automount in a flash.
>
> Could we please postpone these patches for 4.1.5? I'd like as few things as
> possible to break for 4.1.4, at least, since that's probably the version
> we'll be using in Debian sarge.
Yes. That would be good policy anyway.
We've had a lot of changes in circulation for a while now, with the beta.
To add the uncertainty of several more patches would be a mistake at this
stage.
4.1.5 it is.
Sorry Denis.
Ian
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 3/5] logging to stderr
2005-02-11 10:03 ` [PATCH 3/5] logging to stderr Denis Vlasenko
2005-02-11 10:06 ` [PATCH 4/5] switch to new logging Denis Vlasenko
@ 2005-02-14 15:21 ` Jeff Moyer
2005-02-14 16:07 ` Peter C. Norton
2005-02-15 1:26 ` Ian Kent
1 sibling, 2 replies; 20+ messages in thread
From: Jeff Moyer @ 2005-02-14 15:21 UTC (permalink / raw)
To: Denis Vlasenko; +Cc: autofs
==> Regarding [autofs] [PATCH 3/5] logging to stderr; Denis Vlasenko <vda@port.imtp.ilyichevsk.odessa.ua> adds:
vda> Add code, but do not switch rest of program to use it, yet.
I'm curious, what is the motivation for this?
-Jeff
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 3/5] logging to stderr
2005-02-14 15:21 ` [PATCH 3/5] logging to stderr Jeff Moyer
@ 2005-02-14 16:07 ` Peter C. Norton
2005-02-14 16:21 ` Steinar H. Gunderson
2005-02-14 16:32 ` ramana
2005-02-15 1:26 ` Ian Kent
1 sibling, 2 replies; 20+ messages in thread
From: Peter C. Norton @ 2005-02-14 16:07 UTC (permalink / raw)
To: Jeff Moyer; +Cc: autofs
On Mon, Feb 14, 2005 at 10:21:15AM -0500, Jeff Moyer wrote:
> ==> Regarding [autofs] [PATCH 3/5] logging to stderr; Denis Vlasenko <vda@port.imtp.ilyichevsk.odessa.ua> adds:
>
> vda> Add code, but do not switch rest of program to use it, yet.
>
> I'm curious, what is the motivation for this?
>
> -Jeff
There are sometimes good reasons to log to stderr instead of syslog.
syslog is slow, loses messages, inflexable, and can introduce delays
and huge volumes of crap to the disk. Using stderr loggers can
filter, or do things like rotate logs actively, etc.
I don't know if any of these are the motivations for the patch, but if
its not intrusive its a good idea.
-Peter
--
The 5 year plan:
In five years we'll make up another plan.
Or just re-use this one.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 3/5] logging to stderr
2005-02-14 16:07 ` Peter C. Norton
@ 2005-02-14 16:21 ` Steinar H. Gunderson
2005-02-14 16:38 ` Peter C. Norton
2005-02-14 16:32 ` ramana
1 sibling, 1 reply; 20+ messages in thread
From: Steinar H. Gunderson @ 2005-02-14 16:21 UTC (permalink / raw)
To: autofs
On Mon, Feb 14, 2005 at 08:07:40AM -0800, Peter C. Norton wrote:
> There are sometimes good reasons to log to stderr instead of syslog.
> syslog is slow, loses messages, inflexable, and can introduce delays
> and huge volumes of crap to the disk. Using stderr loggers can
> filter, or do things like rotate logs actively, etc.
OTOH, syslog makes it a lot easier to have unified systems for log rotation
etc. -- and I don't really see what you mean by "inflexible". I'd rather have
it all in one place than inventing a thousand new systems for (say) remote
logging.
Of course, having both isn't bad.
/* Steinar */
--
Homepage: http://www.sesse.net/
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 3/5] logging to stderr
2005-02-14 16:07 ` Peter C. Norton
2005-02-14 16:21 ` Steinar H. Gunderson
@ 2005-02-14 16:32 ` ramana
1 sibling, 0 replies; 20+ messages in thread
From: ramana @ 2005-02-14 16:32 UTC (permalink / raw)
To: Peter C. Norton; +Cc: autofs
Peter C. Norton wrote:
>There are sometimes good reasons to log to stderr instead of syslog.
>syslog is slow, loses messages, inflexable, and can introduce delays
>and huge volumes of crap to the disk. Using stderr loggers can
>filter, or do things like rotate logs actively, etc.
>
>I don't know if any of these are the motivations for the patch, but if
>its not intrusive its a good idea.
>
>-Peter
>
>
>
I put this feature right from the beginning in Autodir, not intended for
above reasons but it helped and helps debugging many bugs.
Regards
ramana
--
http://www.intraperson.com
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 3/5] logging to stderr
2005-02-14 16:21 ` Steinar H. Gunderson
@ 2005-02-14 16:38 ` Peter C. Norton
0 siblings, 0 replies; 20+ messages in thread
From: Peter C. Norton @ 2005-02-14 16:38 UTC (permalink / raw)
To: autofs
On Mon, Feb 14, 2005 at 05:21:45PM +0100, Steinar H. Gunderson wrote:
> On Mon, Feb 14, 2005 at 08:07:40AM -0800, Peter C. Norton wrote:
> > There are sometimes good reasons to log to stderr instead of syslog.
> > syslog is slow, loses messages, inflexable, and can introduce delays
> > and huge volumes of crap to the disk. Using stderr loggers can
> > filter, or do things like rotate logs actively, etc.
>
> OTOH, syslog makes it a lot easier to have unified systems for log rotation
> etc. -- and I don't really see what you mean by "inflexible". I'd rather have
> it all in one place than inventing a thousand new systems for (say) remote
> logging.
Yes, it does, and there's nothing wrong with having a verbose logging
sequence and process doing the equivelant of (for production) grep -v '(unimportant_messages)' | logger -p kern.err
> Of course, having both isn't bad.
No, its not.
-Peter
--
The 5 year plan:
In five years we'll make up another plan.
Or just re-use this one.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 3/5] logging to stderr
2005-02-14 15:21 ` [PATCH 3/5] logging to stderr Jeff Moyer
2005-02-14 16:07 ` Peter C. Norton
@ 2005-02-15 1:26 ` Ian Kent
2005-02-15 13:28 ` Jeff Moyer
1 sibling, 1 reply; 20+ messages in thread
From: Ian Kent @ 2005-02-15 1:26 UTC (permalink / raw)
To: Jeff Moyer; +Cc: autofs
On Mon, 14 Feb 2005, Jeff Moyer wrote:
> ==> Regarding [autofs] [PATCH 3/5] logging to stderr; Denis Vlasenko <vda@port.imtp.ilyichevsk.odessa.ua> adds:
>
> vda> Add code, but do not switch rest of program to use it, yet.
>
> I'm curious, what is the motivation for this?
I believe it relates to the patch before this.
Putting autofs in the foreground we want as much debug info as we can get.
Ian
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 3/5] logging to stderr
2005-02-15 1:26 ` Ian Kent
@ 2005-02-15 13:28 ` Jeff Moyer
2005-02-15 14:32 ` raven
2005-02-15 15:29 ` Greg Wooledge
0 siblings, 2 replies; 20+ messages in thread
From: Jeff Moyer @ 2005-02-15 13:28 UTC (permalink / raw)
To: Ian Kent; +Cc: autofs
==> Regarding Re: [autofs] [PATCH 3/5] logging to stderr; Ian Kent <raven@themaw.net> adds:
raven> On Mon, 14 Feb 2005, Jeff Moyer wrote:
>> ==> Regarding [autofs] [PATCH 3/5] logging to stderr; Denis Vlasenko
>> <vda@port.imtp.ilyichevsk.odessa.ua> adds:
>>
vda> Add code, but do not switch rest of program to use it, yet.
>> I'm curious, what is the motivation for this?
raven> I believe it relates to the patch before this. Putting autofs in
raven> the foreground we want as much debug info as we can get.
I still haven't heard an answer from the original poster.
Putting autofs in the foreground doesn't buy you much, except to debug
initialization. Much of the "business logic" is executed in forked
processes. I'm not against this, but I must say that I find all of the
information I need to debug autofs problems in the logs. That's why I'm
curious as to why someone would invest the time in these patches.
-Jeff
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 3/5] logging to stderr
2005-02-15 13:28 ` Jeff Moyer
@ 2005-02-15 14:32 ` raven
2005-02-15 15:29 ` Greg Wooledge
1 sibling, 0 replies; 20+ messages in thread
From: raven @ 2005-02-15 14:32 UTC (permalink / raw)
To: Jeff Moyer; +Cc: autofs
On Tue, 15 Feb 2005, Jeff Moyer wrote:
> ==> Regarding Re: [autofs] [PATCH 3/5] logging to stderr; Ian Kent <raven@themaw.net> adds:
>
> raven> On Mon, 14 Feb 2005, Jeff Moyer wrote:
>>> ==> Regarding [autofs] [PATCH 3/5] logging to stderr; Denis Vlasenko
>>> <vda@port.imtp.ilyichevsk.odessa.ua> adds:
>>>
> vda> Add code, but do not switch rest of program to use it, yet.
>>> I'm curious, what is the motivation for this?
>
> raven> I believe it relates to the patch before this. Putting autofs in
> raven> the foreground we want as much debug info as we can get.
>
> I still haven't heard an answer from the original poster.
>
> Putting autofs in the foreground doesn't buy you much, except to debug
> initialization. Much of the "business logic" is executed in forked
> processes. I'm not against this, but I must say that I find all of the
> information I need to debug autofs problems in the logs. That's why I'm
> curious as to why someone would invest the time in these patches.
Agreed, but I was keen on the logging changes.
Perhaps Denis can tell us more about this question.
Ian
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 3/5] logging to stderr
2005-02-15 13:28 ` Jeff Moyer
2005-02-15 14:32 ` raven
@ 2005-02-15 15:29 ` Greg Wooledge
1 sibling, 0 replies; 20+ messages in thread
From: Greg Wooledge @ 2005-02-15 15:29 UTC (permalink / raw)
To: autofs
On Tue, Feb 15, 2005 at 08:28:45AM -0500, Jeff Moyer wrote:
> Putting autofs in the foreground doesn't buy you much, except to debug
> initialization. Much of the "business logic" is executed in forked
> processes. I'm not against this, but I must say that I find all of the
> information I need to debug autofs problems in the logs. That's why I'm
> curious as to why someone would invest the time in these patches.
My first guess would be that he wants to manage autofs under daemontools
or runit.
http://cr.yp.to/daemontools.html
http://smarden.org/runit/
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2005-02-15 15:29 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-11 9:55 [PATCH 0/5] rediffed patches Denis Vlasenko
2005-02-11 9:58 ` [PATCH 1/5] use PATH Denis Vlasenko
2005-02-11 9:59 ` Denis Vlasenko
2005-02-11 10:01 ` [PATCH 2/5] add --foreground option Denis Vlasenko
2005-02-11 10:03 ` [PATCH 3/5] logging to stderr Denis Vlasenko
2005-02-11 10:06 ` [PATCH 4/5] switch to new logging Denis Vlasenko
2005-02-11 10:09 ` [PATCH 5/5] Denis Vlasenko
2005-02-14 15:21 ` [PATCH 3/5] logging to stderr Jeff Moyer
2005-02-14 16:07 ` Peter C. Norton
2005-02-14 16:21 ` Steinar H. Gunderson
2005-02-14 16:38 ` Peter C. Norton
2005-02-14 16:32 ` ramana
2005-02-15 1:26 ` Ian Kent
2005-02-15 13:28 ` Jeff Moyer
2005-02-15 14:32 ` raven
2005-02-15 15:29 ` Greg Wooledge
2005-02-13 12:26 ` [PATCH 0/5] rediffed patches raven
2005-02-13 13:25 ` raven
2005-02-13 13:42 ` Steinar H. Gunderson
2005-02-14 1:10 ` Ian Kent
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.