Skip to content

Commit 7d1cca7

Browse files
chuckleverTrond Myklebust
authored andcommitted
NFS: change NFS mount error return when hostname/pathname too long
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>
1 parent 350c73a commit 7d1cca7

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fs/nfs/super.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,13 +1155,13 @@ static int nfs_validate_mount_data(struct nfs_mount_data **options,
11551155
return -EINVAL;
11561156
len = c - dev_name;
11571157
if (len > sizeof(data->hostname))
1158-
return -EINVAL;
1158+
return -ENAMETOOLONG;
11591159
strncpy(data->hostname, dev_name, len);
11601160
args.nfs_server.hostname = data->hostname;
11611161

11621162
c++;
11631163
if (strlen(c) > NFS_MAXPATHLEN)
1164-
return -EINVAL;
1164+
return -ENAMETOOLONG;
11651165
args.nfs_server.export_path = c;
11661166

11671167
status = nfs_try_mount(&args, mntfh);
@@ -1677,7 +1677,7 @@ static int nfs4_validate_mount_data(struct nfs4_mount_data **options,
16771677
/* while calculating len, pretend ':' is '\0' */
16781678
len = c - dev_name;
16791679
if (len > NFS4_MAXNAMLEN)
1680-
return -EINVAL;
1680+
return -ENAMETOOLONG;
16811681
*hostname = kzalloc(len, GFP_KERNEL);
16821682
if (*hostname == NULL)
16831683
return -ENOMEM;
@@ -1686,7 +1686,7 @@ static int nfs4_validate_mount_data(struct nfs4_mount_data **options,
16861686
c++; /* step over the ':' */
16871687
len = strlen(c);
16881688
if (len > NFS4_MAXPATHLEN)
1689-
return -EINVAL;
1689+
return -ENAMETOOLONG;
16901690
*mntpath = kzalloc(len + 1, GFP_KERNEL);
16911691
if (*mntpath == NULL)
16921692
return -ENOMEM;

0 commit comments

Comments
 (0)