]> git.sur5r.net Git - u-boot/blobdiff - net/nfs.c
net: nfs: Remove separate buffer for default name
[u-boot] / net / nfs.c
index 78968d82e94b25d5accec9b655c6bb37918dc38b..d7aeef916207d037f579e09b3c5576247c4f51a0 100644 (file)
--- a/net/nfs.c
+++ b/net/nfs.c
@@ -65,7 +65,6 @@ static int nfs_state;
 #define STATE_READ_REQ                 6
 #define STATE_READLINK_REQ             7
 
-static char default_filename[64];
 static char *nfs_filename;
 static char *nfs_path;
 static char nfs_path_buff[2048];
@@ -132,7 +131,7 @@ static char *dirname(char *path)
 /**************************************************************************
 RPC_ADD_CREDENTIALS - Add RPC authentication/verifier entries
 **************************************************************************/
-static long *rpc_add_credentials(long *p)
+static uint32_t *rpc_add_credentials(uint32_t *p)
 {
        int hl;
        int hostnamelen;
@@ -241,7 +240,7 @@ static void nfs_mount_req(char *path)
        pathlen = strlen(path);
 
        p = &(data[0]);
-       p = (uint32_t *)rpc_add_credentials((long *)p);
+       p = rpc_add_credentials(p);
 
        *p++ = htonl(pathlen);
        if (pathlen & 3)
@@ -268,7 +267,7 @@ static void nfs_umountall_req(void)
                return;
 
        p = &(data[0]);
-       p = (uint32_t *)rpc_add_credentials((long *)p);
+       p = rpc_add_credentials(p);
 
        len = (uint32_t *)p - (uint32_t *)&(data[0]);
 
@@ -289,7 +288,7 @@ static void nfs_readlink_req(void)
        int len;
 
        p = &(data[0]);
-       p = (uint32_t *)rpc_add_credentials((long *)p);
+       p = rpc_add_credentials(p);
 
        memcpy(p, filefh, NFS_FHSIZE);
        p += (NFS_FHSIZE / 4);
@@ -312,7 +311,7 @@ static void nfs_lookup_req(char *fname)
        fnamelen = strlen(fname);
 
        p = &(data[0]);
-       p = (uint32_t *)rpc_add_credentials((long *)p);
+       p = rpc_add_credentials(p);
 
        memcpy(p, dirfh, NFS_FHSIZE);
        p += (NFS_FHSIZE / 4);
@@ -337,7 +336,7 @@ static void nfs_read_req(int offset, int readlen)
        int len;
 
        p = &(data[0]);
-       p = (uint32_t *)rpc_add_credentials((long *)p);
+       p = rpc_add_credentials(p);
 
        memcpy(p, filefh, NFS_FHSIZE);
        p += (NFS_FHSIZE / 4);
@@ -481,8 +480,23 @@ static int nfs_lookup_reply(uchar *pkt, unsigned len)
        if (rpc_pkt.u.reply.rstatus  ||
            rpc_pkt.u.reply.verifier ||
            rpc_pkt.u.reply.astatus  ||
-           rpc_pkt.u.reply.data[0])
+           rpc_pkt.u.reply.data[0]) {
+               switch (ntohl(rpc_pkt.u.reply.astatus)) {
+               case 0: /* Not an error */
+                       break;
+               case 2: /* Remote can't support NFS version */
+                       printf("*** ERROR: NFS version not supported: Requested: V%d, accepted: min V%d - max V%d\n",
+                              2,
+                              ntohl(rpc_pkt.u.reply.data[0]),
+                              ntohl(rpc_pkt.u.reply.data[1]));
+                       break;
+               default: /* Unknown error on 'accept state' flag */
+                       printf("*** ERROR: accept state error (%d)\n",
+                              ntohl(rpc_pkt.u.reply.astatus));
+                       break;
+               }
                return -1;
+       }
 
        memcpy(filefh, rpc_pkt.u.reply.data + 1, NFS_FHSIZE);
 
@@ -705,12 +719,11 @@ void nfs_start(void)
        }
 
        if (net_boot_file_name[0] == '\0') {
-               sprintf(default_filename, "/nfsroot/%02X%02X%02X%02X.img",
+               sprintf(nfs_path, "/nfsroot/%02X%02X%02X%02X.img",
                        net_ip.s_addr & 0xFF,
                        (net_ip.s_addr >>  8) & 0xFF,
                        (net_ip.s_addr >> 16) & 0xFF,
                        (net_ip.s_addr >> 24) & 0xFF);
-               strcpy(nfs_path, default_filename);
 
                printf("*** Warning: no boot file name; using '%s'\n",
                       nfs_path);