X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=utils%2Fmountd%2Fmountd.c;h=971e4f4e2be8ca774328aed24c921bdea4f7edcc;hp=b5779716148d33eaeb6ec6949e8660f6439aea55;hb=8b064fcf464aaf3717d8940f97a7d3f8bf21de1a;hpb=8f4b4516cb37211057e775756b5701c4be050648 diff --git a/utils/mountd/mountd.c b/utils/mountd/mountd.c index b577971..971e4f4 100644 --- a/utils/mountd/mountd.c +++ b/utils/mountd/mountd.c @@ -31,7 +31,7 @@ static struct nfs_fh_len *get_rootfh(struct svc_req *, dirpath *, int *, int v3) static struct option longopts[] = { { "foreground", 0, 0, 'F' }, - { "descriptors", 0, 0, 'o' }, + { "descriptors", 1, 0, 'o' }, { "debug", 1, 0, 'd' }, { "help", 0, 0, 'h' }, { "exports-file", 1, 0, 'f' }, @@ -399,7 +399,7 @@ main(int argc, char **argv) /* Parse the command line options and arguments. */ opterr = 0; - while ((c = getopt_long(argc, argv, "o:Fd:f:p:P:hN:V:v", longopts, NULL)) != EOF) + while ((c = getopt_long(argc, argv, "on:Fd:f:p:P:hN:V:v", longopts, NULL)) != EOF) switch (c) { case 'o': descriptors = atoi(optarg); @@ -484,6 +484,13 @@ main(int argc, char **argv) /* WARNING: the following works on Linux and SysV, but not BSD! */ sigaction(SIGCHLD, &sa, NULL); + /* Daemons should close all extra filehandles ... *before* RPC init. */ + if (!foreground) { + int fd = sysconf (_SC_OPEN_MAX); + while (--fd > 2) + (void) close(fd); + } + if (nfs_version & 0x1) rpc_init("mountd", MOUNTPROG, MOUNTVERS, mount_dispatch, port);