{
char *export_file = _PATH_EXPORTS;
char *state_dir = NFS_STATEDIR;
+ char *progname;
unsigned int listeners = 0;
int foreground = 0;
int port = 0;
struct sigaction sa;
struct rlimit rlim;
+ /* Set the basename */
+ if ((progname = strrchr(argv[0], '/')) != NULL)
+ progname++;
+ else
+ progname = argv[0];
+
/* Parse the command line options and arguments. */
opterr = 0;
while ((c = getopt_long(argc, argv, "o:nFd:f:p:P:hH:N:V:vrs:t:g", longopts, NULL)) != EOF)
descriptors = atoi(optarg);
if (descriptors <= 0) {
fprintf(stderr, "%s: bad descriptors: %s\n",
- argv [0], optarg);
- usage(argv [0], 1);
+ progname, optarg);
+ usage(progname, 1);
}
break;
case 'F':
ha_callout_prog = optarg;
break;
case 'h':
- usage(argv [0], 0);
+ usage(progname, 0);
break;
case 'P': /* XXX for nfs-server compatibility */
case 'p':
port = atoi(optarg);
if (port <= 0 || port > 65535) {
fprintf(stderr, "%s: bad port number: %s\n",
- argv [0], optarg);
- usage(argv [0], 1);
+ progname, optarg);
+ usage(progname, 1);
}
break;
case 'N':
case 's':
if ((state_dir = xstrdup(optarg)) == NULL) {
fprintf(stderr, "%s: xstrdup(%s) failed!\n",
- argv[0], optarg);
+ progname, optarg);
exit(1);
}
break;
nfs_version |= NFSVERSBIT(vers);
break;
case 'v':
- printf("kmountd %s\n", VERSION);
+ printf("%s version " VERSION "\n", progname);
exit(0);
case 0:
break;
case '?':
default:
- usage(argv [0], 1);
+ usage(progname, 1);
}
- /* No more arguments allowed.
- * Require at least one valid version (2, 3, or 4)
- */
+ /* No more arguments allowed. */
if (optind != argc || !version_any())
- usage(argv [0], 1);
+ usage(progname, 1);
if (chdir(state_dir)) {
fprintf(stderr, "%s: chdir(%s) failed: %s\n",
- argv [0], state_dir, strerror(errno));
+ progname, state_dir, strerror(errno));
exit(1);
}
if (getrlimit (RLIMIT_NOFILE, &rlim) != 0)
fprintf(stderr, "%s: getrlimit (RLIMIT_NOFILE) failed: %s\n",
- argv [0], strerror(errno));
+ progname, strerror(errno));
else {
/* glibc sunrpc code dies if getdtablesize > FD_SETSIZE */
if ((descriptors == 0 && rlim.rlim_cur > FD_SETSIZE) ||
rlim.rlim_cur = descriptors;
if (setrlimit (RLIMIT_NOFILE, &rlim) != 0) {
fprintf(stderr, "%s: setrlimit (RLIMIT_NOFILE) failed: %s\n",
- argv [0], strerror(errno));
+ progname, strerror(errno));
exit(1);
}
}
}
/* Initialize logging. */
if (!foreground) xlog_stderr(0);
- xlog_open("mountd");
+ xlog_open(progname);
sa.sa_handler = SIG_IGN;
sa.sa_flags = 0;
if (num_threads > 1)
fork_workers();
+ xlog(L_NOTICE, "Version " VERSION " starting");
my_svc_run();
xlog(L_ERROR, "RPC service loop terminated unexpectedly. Exiting...\n");