Skip to content

Commit

Permalink
exportfs: add FILEID_INVALID to indicate invalid fid_type
Browse files Browse the repository at this point in the history
This commit adds FILEID_INVALID = 0xff in fid_type to
indicate invalid fid_type

It avoids using magic number 255

Signed-off-by: Namjae Jeon <[email protected]>
Signed-off-by: Vivek Trivedi <[email protected]>
Signed-off-by: J. Bruce Fields <[email protected]>
  • Loading branch information
namjaejeon authored and J. Bruce Fields committed Nov 8, 2012
1 parent 6f0c058 commit 216b6cb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions fs/exportfs/expfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,10 @@ static int export_encode_fh(struct inode *inode, struct fid *fid,

if (parent && (len < 4)) {
*max_len = 4;
return 255;
return FILEID_INVALID;
} else if (len < 2) {
*max_len = 2;
return 255;
return FILEID_INVALID;
}

len = 2;
Expand Down
2 changes: 1 addition & 1 deletion fs/fhandle.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ static long do_sys_name_to_handle(struct path *path,
handle_bytes = handle_dwords * sizeof(u32);
handle->handle_bytes = handle_bytes;
if ((handle->handle_bytes > f_handle.handle_bytes) ||
(retval == 255) || (retval == -ENOSPC)) {
(retval == FILEID_INVALID) || (retval == -ENOSPC)) {
/* As per old exportfs_encode_fh documentation
* we could return ENOSPC to indicate overflow
* But file system returned 255 always. So handle
Expand Down
4 changes: 2 additions & 2 deletions fs/nfsd/nfsfh.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ fh_compose(struct svc_fh *fhp, struct svc_export *exp, struct dentry *dentry,

if (inode)
_fh_update(fhp, exp, dentry);
if (fhp->fh_handle.fh_fileid_type == 255) {
if (fhp->fh_handle.fh_fileid_type == FILEID_INVALID) {
fh_put(fhp);
return nfserr_opnotsupp;
}
Expand Down Expand Up @@ -603,7 +603,7 @@ fh_update(struct svc_fh *fhp)
goto out;

_fh_update(fhp, fhp->fh_export, dentry);
if (fhp->fh_handle.fh_fileid_type == 255)
if (fhp->fh_handle.fh_fileid_type == FILEID_INVALID)
return nfserr_opnotsupp;
}
out:
Expand Down
5 changes: 5 additions & 0 deletions include/linux/exportfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ enum fid_type {
* 64 bit parent inode number.
*/
FILEID_NILFS_WITH_PARENT = 0x62,

/*
* Filesystems must not use 0xff file ID.
*/
FILEID_INVALID = 0xff,
};

struct fid {
Expand Down

0 comments on commit 216b6cb

Please sign in to comment.