@@ -522,20 +522,17 @@ static int nfs4_stat_to_errno(int);
522522 decode_lookup_maxsz + \
523523 decode_fs_locations_maxsz)
524524
525- static struct {
526- unsigned int mode ;
527- unsigned int nfs2type ;
528- } nfs_type2fmt [] = {
529- { 0 , NFNON },
530- { S_IFREG , NFREG },
531- { S_IFDIR , NFDIR },
532- { S_IFBLK , NFBLK },
533- { S_IFCHR , NFCHR },
534- { S_IFLNK , NFLNK },
535- { S_IFSOCK , NFSOCK },
536- { S_IFIFO , NFFIFO },
537- { 0 , NFNON },
538- { 0 , NFNON },
525+ static const umode_t nfs_type2fmt [] = {
526+ [NF4BAD ] = 0 ,
527+ [NF4REG ] = S_IFREG ,
528+ [NF4DIR ] = S_IFDIR ,
529+ [NF4BLK ] = S_IFBLK ,
530+ [NF4CHR ] = S_IFCHR ,
531+ [NF4LNK ] = S_IFLNK ,
532+ [NF4SOCK ] = S_IFSOCK ,
533+ [NF4FIFO ] = S_IFIFO ,
534+ [NF4ATTRDIR ] = 0 ,
535+ [NF4NAMEDATTR ] = 0 ,
539536};
540537
541538struct compound_hdr {
@@ -2173,7 +2170,7 @@ static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *
21732170 }
21742171 bitmap [0 ] &= ~FATTR4_WORD0_TYPE ;
21752172 }
2176- dprintk ("%s: type=0%o\n" , __func__ , nfs_type2fmt [* type ]. nfs2type );
2173+ dprintk ("%s: type=0%o\n" , __func__ , nfs_type2fmt [* type ]);
21772174 return 0 ;
21782175}
21792176
@@ -2580,17 +2577,18 @@ static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32
25802577 return status ;
25812578}
25822579
2583- static int decode_attr_mode (struct xdr_stream * xdr , uint32_t * bitmap , uint32_t * mode )
2580+ static int decode_attr_mode (struct xdr_stream * xdr , uint32_t * bitmap , umode_t * mode )
25842581{
2582+ uint32_t tmp ;
25852583 __be32 * p ;
25862584
25872585 * mode = 0 ;
25882586 if (unlikely (bitmap [1 ] & (FATTR4_WORD1_MODE - 1U )))
25892587 return - EIO ;
25902588 if (likely (bitmap [1 ] & FATTR4_WORD1_MODE )) {
25912589 READ_BUF (4 );
2592- READ32 (* mode );
2593- * mode &= ~S_IFMT ;
2590+ READ32 (tmp );
2591+ * mode = tmp & ~S_IFMT ;
25942592 bitmap [1 ] &= ~FATTR4_WORD1_MODE ;
25952593 }
25962594 dprintk ("%s: file mode=0%o\n" , __func__ , (unsigned int )* mode );
@@ -2994,7 +2992,8 @@ static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, cons
29942992 uint32_t attrlen ,
29952993 bitmap [2 ] = {0 },
29962994 type ;
2997- int status , fmode = 0 ;
2995+ int status ;
2996+ umode_t fmode = 0 ;
29982997 uint64_t fileid ;
29992998
30002999 if ((status = decode_op_hdr (xdr , OP_GETATTR )) != 0 )
@@ -3008,8 +3007,7 @@ static int decode_getfattr(struct xdr_stream *xdr, struct nfs_fattr *fattr, cons
30083007
30093008 if ((status = decode_attr_type (xdr , bitmap , & type )) != 0 )
30103009 goto xdr_error ;
3011- fattr -> type = nfs_type2fmt [type ].nfs2type ;
3012- fattr -> mode = nfs_type2fmt [type ].mode ;
3010+ fattr -> mode = nfs_type2fmt [type ];
30133011
30143012 if ((status = decode_attr_change (xdr , bitmap , & fattr -> change_attr )) != 0 )
30153013 goto xdr_error ;
0 commit comments