]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/mount/nfs4mount.c
Currently nfs4mount() sets the retry value to 10000 on both fg and bg
[nfs-utils.git] / utils / mount / nfs4mount.c
index 52b0261a6038fd6e6bf411a01fd4e28a7770fd2d..af70551f595e696a01a2a9bfbe98a53a1f87736d 100644 (file)
  * - Moved to nfs-utils/utils/mount from util-linux/mount.
  */
 
  * - Moved to nfs-utils/utils/mount from util-linux/mount.
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <unistd.h>
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <string.h>
@@ -39,7 +43,6 @@
 
 #include "pseudoflavors.h"
 #include "nls.h"
 
 #include "pseudoflavors.h"
 #include "nls.h"
-#include "conn.h"
 #include "xcommon.h"
 
 #include "mount_constants.h"
 #include "xcommon.h"
 
 #include "mount_constants.h"
@@ -167,7 +170,7 @@ static int get_my_ipv4addr(char *ip_addr, int len)
 }
 
 int nfs4mount(const char *spec, const char *node, int flags,
 }
 
 int nfs4mount(const char *spec, const char *node, int flags,
-             char **extra_opts, int fake)
+             char **extra_opts, int fake, int running_bg)
 {
        static struct nfs4_mount_data data;
        static char hostdir[1024];
 {
        static struct nfs4_mount_data data;
        static char hostdir[1024];
@@ -235,7 +238,7 @@ int nfs4mount(const char *spec, const char *node, int flags,
        nocto = 0;
        noac = 0;
        unshared = 0;
        nocto = 0;
        noac = 0;
        unshared = 0;
-       retry = 10000;          /* 10000 minutes ~ 1 week */
+       retry = -1;
 
        /*
         * NFSv4 specifies that the default port should be 2049
 
        /*
         * NFSv4 specifies that the default port should be 2049
@@ -322,13 +325,21 @@ int nfs4mount(const char *spec, const char *node, int flags,
                        else if (!strcmp(opt, "sharecache"))
                                unshared = !val;
                        else if (!sloppy) {
                        else if (!strcmp(opt, "sharecache"))
                                unshared = !val;
                        else if (!sloppy) {
-                               printf(_("unknown nfs mount option: "
-                                        "%s%s\n"), val ? "" : "no", opt);
+                               printf(_("unknown nfs mount option: %s%s\n"),
+                                               val ? "" : "no", opt);
                                goto fail;
                        }
                }
        }
 
                                goto fail;
                        }
                }
        }
 
+       /* if retry is still -1, then it wasn't set via an option */
+       if (retry == -1) {
+               if (bg)
+                       retry = 10000;  /* 10000 mins == ~1 week */
+               else
+                       retry = 2;      /* 2 min default on fg mounts */
+       }
+
        data.flags = (soft ? NFS4_MOUNT_SOFT : 0)
                | (intr ? NFS4_MOUNT_INTR : 0)
                | (nocto ? NFS4_MOUNT_NOCTO : 0)
        data.flags = (soft ? NFS4_MOUNT_SOFT : 0)
                | (intr ? NFS4_MOUNT_INTR : 0)
                | (nocto ? NFS4_MOUNT_NOCTO : 0)
@@ -368,14 +379,14 @@ int nfs4mount(const char *spec, const char *node, int flags,
        data.host_addrlen = sizeof(server_addr);
 
 #ifdef NFS_MOUNT_DEBUG
        data.host_addrlen = sizeof(server_addr);
 
 #ifdef NFS_MOUNT_DEBUG
-       printf("rsize = %d, wsize = %d, timeo = %d, retrans = %d\n",
+       printf(_("rsize = %d, wsize = %d, timeo = %d, retrans = %d\n"),
               data.rsize, data.wsize, data.timeo, data.retrans);
               data.rsize, data.wsize, data.timeo, data.retrans);
-       printf("acreg (min, max) = (%d, %d), acdir (min, max) = (%d, %d)\n",
+       printf(_("acreg (min, max) = (%d, %d), acdir (min, max) = (%d, %d)\n"),
               data.acregmin, data.acregmax, data.acdirmin, data.acdirmax);
               data.acregmin, data.acregmax, data.acdirmin, data.acdirmax);
-       printf("port = %d, bg = %d, retry = %d, flags = %.8x\n",
+       printf(_("port = %d, bg = %d, retry = %d, flags = %.8x\n"),
               ntohs(server_addr.sin_port), bg, retry, data.flags);
               ntohs(server_addr.sin_port), bg, retry, data.flags);
-       printf("soft = %d, intr = %d, nocto = %d, noac = %d, "
-              "nosharecache = %d\n",
+       printf(_("soft = %d, intr = %d, nocto = %d, noac = %d, "
+              "nosharecache = %d\n"),
               (data.flags & NFS4_MOUNT_SOFT) != 0,
               (data.flags & NFS4_MOUNT_INTR) != 0,
               (data.flags & NFS4_MOUNT_NOCTO) != 0,
               (data.flags & NFS4_MOUNT_SOFT) != 0,
               (data.flags & NFS4_MOUNT_INTR) != 0,
               (data.flags & NFS4_MOUNT_NOCTO) != 0,
@@ -385,7 +396,7 @@ int nfs4mount(const char *spec, const char *node, int flags,
        if (num_flavour > 0) {
                int pf_cnt, i;
 
        if (num_flavour > 0) {
                int pf_cnt, i;
 
-               printf("sec = ");
+               printf(_("sec = "));
                for (pf_cnt = 0; pf_cnt < num_flavour; pf_cnt++) {
                        for (i = 0; i < flav_map_size; i++) {
                                if (flav_map[i].fnum == pseudoflavour[pf_cnt]) {
                for (pf_cnt = 0; pf_cnt < num_flavour; pf_cnt++) {
                        for (i = 0; i < flav_map_size; i++) {
                                if (flav_map[i].fnum == pseudoflavour[pf_cnt]) {
@@ -396,7 +407,7 @@ int nfs4mount(const char *spec, const char *node, int flags,
                        printf("%s", (pf_cnt < num_flavour-1) ? ":" : "\n");
                }
        }
                        printf("%s", (pf_cnt < num_flavour-1) ? ":" : "\n");
                }
        }
-       printf("proto = %s\n", (data.proto == IPPROTO_TCP) ? "tcp" : "udp");
+       printf(_("proto = %s\n"), (data.proto == IPPROTO_TCP) ? _("tcp") : _("udp"));
 #endif
 
        timeout = time(NULL) + 60 * retry;
 #endif
 
        timeout = time(NULL) + 60 * retry;
@@ -429,15 +440,15 @@ int nfs4mount(const char *spec, const char *node, int flags,
                        if (errno == ETIMEDOUT)
                                break;
                default:
                        if (errno == ETIMEDOUT)
                                break;
                default:
-                       mount_errors(hostname, 0, bg);
+                       rpc_mount_errors(hostname, 0, bg);
                        goto fail;
                }
                t = time(NULL);
                if (t >= timeout) {
                        goto fail;
                }
                t = time(NULL);
                if (t >= timeout) {
-                       mount_errors(hostname, 0, bg);
+                       rpc_mount_errors(hostname, 0, bg);
                        goto fail;
                }
                        goto fail;
                }
-               mount_errors(hostname, 1, bg);
+               rpc_mount_errors(hostname, 1, bg);
                continue;
        }
 
                continue;
        }
 
@@ -449,7 +460,7 @@ int nfs4mount(const char *spec, const char *node, int flags,
                }
        }
 
                }
        }
 
-       return 0;
+       return EX_SUCCESS;
 
 fail:
        return retval;
 
 fail:
        return retval;