Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions net/nfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ static int nfs_offset = -1;
static int nfs_len;
static const ulong nfs_timeout = CONFIG_NFS_TIMEOUT;

static char dirfh[NFS_FHSIZE]; /* NFSv2 / NFSv3 file handle of directory */
static char dirfh[NFS3_FHSIZE]; /* NFSv2 / NFSv3 file handle of directory */
static unsigned int dirfh3_length; /* (variable) length of dirfh when NFSv3 */
static char filefh[NFS3_FHSIZE]; /* NFSv2 / NFSv3 file handle */
static unsigned int filefh3_length; /* (variable) length of filefh when NFSv3 */

Expand Down Expand Up @@ -377,9 +378,9 @@ static void nfs_lookup_req(char *fname)

rpc_req(PROG_NFS, NFS_LOOKUP, data, len);
} else { /* NFS_V3 */
*p++ = htonl(NFS_FHSIZE); /* Dir handle length */
memcpy(p, dirfh, NFS_FHSIZE);
p += (NFS_FHSIZE / 4);
*p++ = htonl(dirfh3_length); /* Dir handle length */
memcpy(p, dirfh, dirfh3_length);
p += (dirfh3_length / 4);
*p++ = htonl(fnamelen);
if (fnamelen & 3)
*(p + fnamelen / 4) = 0;
Expand Down Expand Up @@ -565,7 +566,14 @@ static int nfs_mount_reply(uchar *pkt, unsigned len)

fs_mounted = 1;
/* NFSv2 and NFSv3 use same structure */
memcpy(dirfh, rpc_pkt.u.reply.data + 1, NFS_FHSIZE);
if (choosen_nfs_version != NFS_V3) {
memcpy(dirfh, rpc_pkt.u.reply.data + 1, NFS_FHSIZE);
} else {
dirfh3_length = ntohl(rpc_pkt.u.reply.data[1]);
if (dirfh3_length > NFS3_FHSIZE)
dirfh3_length = NFS3_FHSIZE;
memcpy(dirfh, rpc_pkt.u.reply.data + 2, dirfh3_length);
}

return 0;
}
Expand Down