aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4xdr.c
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2011-08-15 11:49:30 -0400
committerJ. Bruce Fields <bfields@redhat.com>2011-08-26 18:22:47 -0400
commit3d2544b1e4909b6dffa0d140273628913e255e45 (patch)
tree83985c81fdd869336b80dd03a3870f2f4faf448a /fs/nfsd/nfs4xdr.c
parent11fd165c68b73434ca1273e21f21db5eecc90926 (diff)
nfsd4: clean up S_IS -> NF4 file type mapping
A slightly unconventional approach to make the code more compact I could live with, but let's give the poor reader *some* chance. Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4xdr.c')
-rw-r--r--fs/nfsd/nfs4xdr.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index f8109960525..51ec1f27450 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -1772,12 +1772,19 @@ static __be32 nfsd4_encode_fs_locations(struct svc_rqst *rqstp,
1772 return 0; 1772 return 0;
1773} 1773}
1774 1774
1775static u32 nfs4_ftypes[16] = { 1775static u32 nfs4_file_type(umode_t mode)
1776 NF4BAD, NF4FIFO, NF4CHR, NF4BAD, 1776{
1777 NF4DIR, NF4BAD, NF4BLK, NF4BAD, 1777 switch (mode & S_IFMT) {
1778 NF4REG, NF4BAD, NF4LNK, NF4BAD, 1778 case S_IFIFO: return NF4FIFO;
1779 NF4SOCK, NF4BAD, NF4LNK, NF4BAD, 1779 case S_IFCHR: return NF4CHR;
1780}; 1780 case S_IFDIR: return NF4DIR;
1781 case S_IFBLK: return NF4BLK;
1782 case S_IFLNK: return NF4LNK;
1783 case S_IFREG: return NF4REG;
1784 case S_IFSOCK: return NF4SOCK;
1785 default: return NF4BAD;
1786 };
1787}
1781 1788
1782static __be32 1789static __be32
1783nfsd4_encode_name(struct svc_rqst *rqstp, int whotype, uid_t id, int group, 1790nfsd4_encode_name(struct svc_rqst *rqstp, int whotype, uid_t id, int group,
@@ -1966,7 +1973,7 @@ nfsd4_encode_fattr(struct svc_fh *fhp, struct svc_export *exp,
1966 if (bmval0 & FATTR4_WORD0_TYPE) { 1973 if (bmval0 & FATTR4_WORD0_TYPE) {
1967 if ((buflen -= 4) < 0) 1974 if ((buflen -= 4) < 0)
1968 goto out_resource; 1975 goto out_resource;
1969 dummy = nfs4_ftypes[(stat.mode & S_IFMT) >> 12]; 1976 dummy = nfs4_file_type(stat.mode);
1970 if (dummy == NF4BAD) 1977 if (dummy == NF4BAD)
1971 goto out_serverfault; 1978 goto out_serverfault;
1972 WRITE32(dummy); 1979 WRITE32(dummy);