exportfs: add FILEID_INVALID to indicate invalid fid_type
authorNamjae Jeon <linkinjeon@gmail.com>
Wed, 29 Aug 2012 14:10:10 +0000 (10:10 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Thu, 8 Nov 2012 00:22:30 +0000 (19:22 -0500)
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 <linkinjeon@gmail.com>
Signed-off-by: Vivek Trivedi <vtrivedi018@gmail.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/exportfs/expfs.c
fs/fhandle.c
fs/nfsd/nfsfh.c
include/linux/exportfs.h

index 29ab099e3e0818a9d9c85f0449c8df2e4b9b5f70..f1f1c59c2966cc6aac49fa103cad3012bb495044 100644 (file)
@@ -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;
index f775bfdd6e4a7f3e0700b8ea556261ad8c13e3ba..26f12b95702a35f4ac5533936859a9ab449bb096 100644 (file)
@@ -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
index 032af381b3aa4bd1298b084c57d3c4022293668c..814afaa4458a9285fc3168c47d1df6a1f8164c12 100644 (file)
@@ -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;
                }
@@ -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:
index 12291a7ee2759164026ac602ab1712b5d66faef0..0e14525463005cb1c18f0622862103449578e0df 100644 (file)
@@ -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 {