Reverse logic so when network logging, it by default does not log locally.
[oweals/busybox.git] / nfsmount.c
index 5c29b5f6b56768aaa2d522b249d60dfc495032cb..ae9b99552ff9fdabc0e68d5d87b8df78d54fffc1 100644 (file)
@@ -33,7 +33,7 @@
  * nfsmount.c,v 1.1.1.1 1993/11/18 08:40:51 jrs Exp
  */
 
-#include "internal.h"
+#include "busybox.h"
 #undef FALSE
 #undef TRUE
 #include <unistd.h>
 #include <sys/socket.h>
 #include <sys/time.h>
 #include <sys/utsname.h>
-#include <sys/stat.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 
 #include "nfsmount.h"
 #include <linux/nfs.h>  /* For the kernels nfs stuff */
 
+#ifndef NFS_FHSIZE
+#define NFS_FHSIZE     32
+#endif
+#ifndef NFS_PORT
+#define NFS_PORT       2049
+#endif
 
 /* Disable the nls stuff */
 # undef bindtextdomain
@@ -161,20 +166,6 @@ static char *nfs_strerror(int stat);
 #define EX_BG                  256       /* retry in background (internal only) */
 
 
-static int
-linux_version_code(void) {
-       struct utsname my_utsname;
-       int p, q, r;
-
-       if (uname(&my_utsname) == 0) {
-               p = atoi(strtok(my_utsname.release, "."));
-               q = atoi(strtok(NULL, "."));
-               r = atoi(strtok(NULL, "."));
-               return MAKE_VERSION(p,q,r);
-       }
-       return 0;
-}
-
 /*
  * nfs_mount_version according to the sources seen at compile time.
  */
@@ -198,7 +189,7 @@ find_kernel_nfs_mount_version(void) {
        if (kernel_version)
                return;
 
-       kernel_version = linux_version_code();
+       kernel_version = get_kernel_revision();
 
        if (kernel_version) {
             if (kernel_version < MAKE_VERSION(2,1,32))
@@ -315,7 +306,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
        msock = fsock = -1;
        mclient = NULL;
        if (strlen(spec) >= sizeof(hostdir)) {
-               errorMsg("excessively long host:dir argument\n");
+               error_msg("excessively long host:dir argument\n");
                goto fail;
        }
        strcpy(hostdir, spec);
@@ -327,10 +318,10 @@ int nfsmount(const char *spec, const char *node, int *flags,
                   until they can be fully supported. (mack@sgi.com) */
                if ((s = strchr(hostdir, ','))) {
                        *s = '\0';
-                       errorMsg("warning: multiple hostnames not supported\n");
+                       error_msg("warning: multiple hostnames not supported\n");
                }
        } else {
-               errorMsg("directory to mount not in host:dir format\n");
+               error_msg("directory to mount not in host:dir format\n");
                goto fail;
        }
 
@@ -340,11 +331,11 @@ int nfsmount(const char *spec, const char *node, int *flags,
 #endif
        {
                if ((hp = gethostbyname(hostname)) == NULL) {
-                       errorMsg("can't get address for %s\n", hostname);
+                       error_msg("can't get address for %s\n", hostname);
                        goto fail;
                } else {
                        if (hp->h_length > sizeof(struct in_addr)) {
-                               errorMsg("got bad hp->h_length\n");
+                               error_msg("got bad hp->h_length\n");
                                hp->h_length = sizeof(struct in_addr);
                        }
                        memcpy(&server_addr.sin_addr,
@@ -361,7 +352,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
        if (!old_opts)
                old_opts = "";
        if (strlen(old_opts) + strlen(s) + 10 >= sizeof(new_opts)) {
-               errorMsg("excessively long option argument\n");
+               error_msg("excessively long option argument\n");
                goto fail;
        }
        sprintf(new_opts, "%s%saddr=%s",
@@ -521,11 +512,11 @@ int nfsmount(const char *spec, const char *node, int *flags,
                data.flags |= (nolock ? NFS_MOUNT_NONLM : 0);
 #endif
        if (nfsvers > MAX_NFSPROT) {
-               errorMsg("NFSv%d not supported!\n", nfsvers);
+               error_msg("NFSv%d not supported!\n", nfsvers);
                return 0;
        }
        if (mountvers > MAX_NFSPROT) {
-               errorMsg("NFSv%d not supported!\n", nfsvers);
+               error_msg("NFSv%d not supported!\n", nfsvers);
                return 0;
        }
        if (nfsvers && !mountvers)
@@ -585,11 +576,11 @@ int nfsmount(const char *spec, const char *node, int *flags,
            mount_server_addr.sin_addr.s_addr = inet_addr(hostname);
          } else {
                  if ((hp = gethostbyname(mounthost)) == NULL) {
-                         errorMsg("can't get address for %s\n", hostname);
+                         error_msg("can't get address for %s\n", hostname);
                          goto fail;
                  } else {
                          if (hp->h_length > sizeof(struct in_addr)) {
-                                 errorMsg("got bad hp->h_length?\n");
+                                 error_msg("got bad hp->h_length?\n");
                                  hp->h_length = sizeof(struct in_addr);
                          }
                          mount_server_addr.sin_family = AF_INET;
@@ -724,7 +715,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
 
        if (nfsvers == 2) {
                if (status.nfsv2.fhs_status != 0) {
-                       errorMsg("%s:%s failed, reason given by server: %s\n",
+                       error_msg("%s:%s failed, reason given by server: %s\n",
                                hostname, dirname,
                                nfs_strerror(status.nfsv2.fhs_status));
                        goto fail;
@@ -742,7 +733,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
 #if NFS_MOUNT_VERSION >= 4
                fhandle3 *fhandle;
                if (status.nfsv3.fhs_status != 0) {
-                       errorMsg("%s:%s failed, reason given by server: %s\n",
+                       error_msg("%s:%s failed, reason given by server: %s\n",
                                hostname, dirname,
                                nfs_strerror(status.nfsv3.fhs_status));
                        goto fail;
@@ -797,7 +788,7 @@ int nfsmount(const char *spec, const char *node, int *flags,
          * to avoid problems with multihomed hosts.
          * --Swen
          */
-       if (linux_version_code() <= 66314
+       if (get_kernel_revision() <= 66314
            && connect(fsock, (struct sockaddr *) &server_addr,
                       sizeof (server_addr)) < 0) {
                perror(_("nfs connect"));