Skip to content

Commit

Permalink
NFS: change NFS mount error return when hostname/pathname too long
Browse files Browse the repository at this point in the history
According to the mount(2) man page, the proper error return code for the
mount(2) system call when the special device name or the mounted-on
directory name is too long is ENAMETOOLONG.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
  • Loading branch information
Chuck Lever authored and Trond Myklebust committed Sep 1, 2007
1 parent 350c73a commit 7d1cca7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions fs/nfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1155,13 +1155,13 @@ static int nfs_validate_mount_data(struct nfs_mount_data **options,
return -EINVAL;
len = c - dev_name;
if (len > sizeof(data->hostname))
return -EINVAL;
return -ENAMETOOLONG;
strncpy(data->hostname, dev_name, len);
args.nfs_server.hostname = data->hostname;

c++;
if (strlen(c) > NFS_MAXPATHLEN)
return -EINVAL;
return -ENAMETOOLONG;
args.nfs_server.export_path = c;

status = nfs_try_mount(&args, mntfh);
Expand Down Expand Up @@ -1677,7 +1677,7 @@ static int nfs4_validate_mount_data(struct nfs4_mount_data **options,
/* while calculating len, pretend ':' is '\0' */
len = c - dev_name;
if (len > NFS4_MAXNAMLEN)
return -EINVAL;
return -ENAMETOOLONG;
*hostname = kzalloc(len, GFP_KERNEL);
if (*hostname == NULL)
return -ENOMEM;
Expand All @@ -1686,7 +1686,7 @@ static int nfs4_validate_mount_data(struct nfs4_mount_data **options,
c++; /* step over the ':' */
len = strlen(c);
if (len > NFS4_MAXPATHLEN)
return -EINVAL;
return -ENAMETOOLONG;
*mntpath = kzalloc(len + 1, GFP_KERNEL);
if (*mntpath == NULL)
return -ENOMEM;
Expand Down

0 comments on commit 7d1cca7

Please sign in to comment.