]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/mountd/mountd.c
1.0.6
[nfs-utils.git] / utils / mountd / mountd.c
index 6dbd224fc27af0e0422e0972d8ecf3599c415e0c..8f6f9cb9d85d8ad69754a9db1bdbda2233feab76 100644 (file)
@@ -283,7 +283,7 @@ get_rootfh(struct svc_req *rqstp, dirpath *path, int *error, int v3)
                     p, strerror(errno));
                *error = NFSERR_NOENT;
        } else if (estb.st_dev != stb.st_dev
-                  /* && (!new_cache || !(exp->m_export.e_flags & NFSEXP_CROSSMNT)) */
+                  /* && (!new_cache || !(exp->m_export.e_flags & NFSEXP_CROSSMOUNT)) */
                ) {
                xlog(L_WARNING, "request to export directory %s below nearest filesystem %s",
                     p, exp->m_export.e_path);
@@ -504,18 +504,21 @@ main(int argc, char **argv)
                exit(1);
        }
 
-       if (descriptors) {
-               if (getrlimit (RLIMIT_NOFILE, &rlim) != 0) {
-                       fprintf(stderr, "%s: getrlimit (RLIMIT_NOFILE) failed: %s\n",
+       if (getrlimit (RLIMIT_NOFILE, &rlim) != 0)
+               fprintf(stderr, "%s: getrlimit (RLIMIT_NOFILE) failed: %s\n",
                                argv [0], strerror(errno));
-                       exit(1);
-               }
-
-               rlim.rlim_cur = descriptors;
-               if (setrlimit (RLIMIT_NOFILE, &rlim) != 0) {
-                       fprintf(stderr, "%s: setrlimit (RLIMIT_NOFILE) failed: %s\n",
-                               argv [0], strerror(errno));
-                       exit(1);
+       else {
+               /* glibc sunrpc code dies if getdtablesize > FD_SETSIZE */
+               if ((descriptors == 0 && rlim.rlim_cur > FD_SETSIZE) ||
+                   descriptors > FD_SETSIZE)
+                       descriptors = FD_SETSIZE;
+               if (descriptors) {
+                       rlim.rlim_cur = descriptors;
+                       if (setrlimit (RLIMIT_NOFILE, &rlim) != 0) {
+                               fprintf(stderr, "%s: setrlimit (RLIMIT_NOFILE) failed: %s\n",
+                                       argv [0], strerror(errno));
+                               exit(1);
+                       }
                }
        }
        /* Initialize logging. */