aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2009-03-11 14:10:26 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2009-03-11 14:10:26 -0400
commitbca794785c2c12ecddeb09e70165b8ff80baa6ae (patch)
tree8e8fefa535c799240846082ba580dc87d0a98cbf /fs
parent1ca277d88dafdbc3c5a69d32590e7184b9af6371 (diff)
NFS: Fix the type of struct nfs_fattr->mode
There is no point in using anything other than umode_t, since we copy the content pretty much directly into inode->i_mode. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/nfs/getroot.c4
-rw-r--r--fs/nfs/nfs2xdr.c7
-rw-r--r--fs/nfs/nfs3xdr.c31
-rw-r--r--fs/nfs/nfs4xdr.c40
4 files changed, 37 insertions, 45 deletions
diff --git a/fs/nfs/getroot.c b/fs/nfs/getroot.c
index b7c9b2df1f29..46177cb87064 100644
--- a/fs/nfs/getroot.c
+++ b/fs/nfs/getroot.c
@@ -156,7 +156,7 @@ int nfs4_path_walk(struct nfs_server *server,
156 return ret; 156 return ret;
157 } 157 }
158 158
159 if (fattr.type != NFDIR) { 159 if (!S_ISDIR(fattr.mode)) {
160 printk(KERN_ERR "nfs4_get_root:" 160 printk(KERN_ERR "nfs4_get_root:"
161 " getroot encountered non-directory\n"); 161 " getroot encountered non-directory\n");
162 return -ENOTDIR; 162 return -ENOTDIR;
@@ -213,7 +213,7 @@ eat_dot_dir:
213 return ret; 213 return ret;
214 } 214 }
215 215
216 if (fattr.type != NFDIR) { 216 if (!S_ISDIR(fattr.mode)) {
217 printk(KERN_ERR "nfs4_get_root:" 217 printk(KERN_ERR "nfs4_get_root:"
218 " lookupfh encountered non-directory\n"); 218 " lookupfh encountered non-directory\n");
219 return -ENOTDIR; 219 return -ENOTDIR;
diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c
index bea99992c302..c862c9340f9a 100644
--- a/fs/nfs/nfs2xdr.c
+++ b/fs/nfs/nfs2xdr.c
@@ -120,8 +120,8 @@ xdr_decode_time(__be32 *p, struct timespec *timep)
120static __be32 * 120static __be32 *
121xdr_decode_fattr(__be32 *p, struct nfs_fattr *fattr) 121xdr_decode_fattr(__be32 *p, struct nfs_fattr *fattr)
122{ 122{
123 u32 rdev; 123 u32 rdev, type;
124 fattr->type = (enum nfs_ftype) ntohl(*p++); 124 type = ntohl(*p++);
125 fattr->mode = ntohl(*p++); 125 fattr->mode = ntohl(*p++);
126 fattr->nlink = ntohl(*p++); 126 fattr->nlink = ntohl(*p++);
127 fattr->uid = ntohl(*p++); 127 fattr->uid = ntohl(*p++);
@@ -138,8 +138,7 @@ xdr_decode_fattr(__be32 *p, struct nfs_fattr *fattr)
138 p = xdr_decode_time(p, &fattr->ctime); 138 p = xdr_decode_time(p, &fattr->ctime);
139 fattr->valid |= NFS_ATTR_FATTR_V2; 139 fattr->valid |= NFS_ATTR_FATTR_V2;
140 fattr->rdev = new_decode_dev(rdev); 140 fattr->rdev = new_decode_dev(rdev);
141 if (fattr->type == NFCHR && rdev == NFS2_FIFO_DEV) { 141 if (type == NFCHR && rdev == NFS2_FIFO_DEV) {
142 fattr->type = NFFIFO;
143 fattr->mode = (fattr->mode & ~S_IFMT) | S_IFIFO; 142 fattr->mode = (fattr->mode & ~S_IFMT) | S_IFIFO;
144 fattr->rdev = 0; 143 fattr->rdev = 0;
145 } 144 }
diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c
index c0f7d02aced9..e6a1932c7110 100644
--- a/fs/nfs/nfs3xdr.c
+++ b/fs/nfs/nfs3xdr.c
@@ -91,19 +91,15 @@
91/* 91/*
92 * Map file type to S_IFMT bits 92 * Map file type to S_IFMT bits
93 */ 93 */
94static struct { 94static const umode_t nfs_type2fmt[] = {
95 unsigned int mode; 95 [NF3BAD] = 0,
96 unsigned int nfs2type; 96 [NF3REG] = S_IFREG,
97} nfs_type2fmt[] = { 97 [NF3DIR] = S_IFDIR,
98 { 0, NFNON }, 98 [NF3BLK] = S_IFBLK,
99 { S_IFREG, NFREG }, 99 [NF3CHR] = S_IFCHR,
100 { S_IFDIR, NFDIR }, 100 [NF3LNK] = S_IFLNK,
101 { S_IFBLK, NFBLK }, 101 [NF3SOCK] = S_IFSOCK,
102 { S_IFCHR, NFCHR }, 102 [NF3FIFO] = S_IFIFO,
103 { S_IFLNK, NFLNK },
104 { S_IFSOCK, NFSOCK },
105 { S_IFIFO, NFFIFO },
106 { 0, NFBAD }
107}; 103};
108 104
109/* 105/*
@@ -148,13 +144,12 @@ static __be32 *
148xdr_decode_fattr(__be32 *p, struct nfs_fattr *fattr) 144xdr_decode_fattr(__be32 *p, struct nfs_fattr *fattr)
149{ 145{
150 unsigned int type, major, minor; 146 unsigned int type, major, minor;
151 int fmode; 147 umode_t fmode;
152 148
153 type = ntohl(*p++); 149 type = ntohl(*p++);
154 if (type >= NF3BAD) 150 if (type > NF3FIFO)
155 type = NF3BAD; 151 type = NF3NON;
156 fmode = nfs_type2fmt[type].mode; 152 fmode = nfs_type2fmt[type];
157 fattr->type = nfs_type2fmt[type].nfs2type;
158 fattr->mode = (ntohl(*p++) & ~S_IFMT) | fmode; 153 fattr->mode = (ntohl(*p++) & ~S_IFMT) | fmode;
159 fattr->nlink = ntohl(*p++); 154 fattr->nlink = ntohl(*p++);
160 fattr->uid = ntohl(*p++); 155 fattr->uid = ntohl(*p++);
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 9f1df8361974..c1906d2a226b 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -522,20 +522,17 @@ static int nfs4_stat_to_errno(int);
522 decode_lookup_maxsz + \ 522 decode_lookup_maxsz + \
523 decode_fs_locations_maxsz) 523 decode_fs_locations_maxsz)
524 524
525static struct { 525static const umode_t nfs_type2fmt[] = {
526 unsigned int mode; 526 [NF4BAD] = 0,
527 unsigned int nfs2type; 527 [NF4REG] = S_IFREG,
528} nfs_type2fmt[] = { 528 [NF4DIR] = S_IFDIR,
529 { 0, NFNON }, 529 [NF4BLK] = S_IFBLK,
530 { S_IFREG, NFREG }, 530 [NF4CHR] = S_IFCHR,
531 { S_IFDIR, NFDIR }, 531 [NF4LNK] = S_IFLNK,
532 { S_IFBLK, NFBLK }, 532 [NF4SOCK] = S_IFSOCK,
533 { S_IFCHR, NFCHR }, 533 [NF4FIFO] = S_IFIFO,
534 { S_IFLNK, NFLNK }, 534 [NF4ATTRDIR] = 0,
535 { S_IFSOCK, NFSOCK }, 535 [NF4NAMEDATTR] = 0,
536 { S_IFIFO, NFFIFO },
537 { 0, NFNON },
538 { 0, NFNON },
539}; 536};
540 537
541struct compound_hdr { 538struct compound_hdr {
@@ -2173,7 +2170,7 @@ static int decode_attr_type(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *
2173 } 2170 }
2174 bitmap[0] &= ~FATTR4_WORD0_TYPE; 2171 bitmap[0] &= ~FATTR4_WORD0_TYPE;
2175 } 2172 }
2176 dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type].nfs2type); 2173 dprintk("%s: type=0%o\n", __func__, nfs_type2fmt[*type]);
2177 return 0; 2174 return 0;
2178} 2175}
2179 2176
@@ -2580,8 +2577,9 @@ static int decode_attr_maxwrite(struct xdr_stream *xdr, uint32_t *bitmap, uint32
2580 return status; 2577 return status;
2581} 2578}
2582 2579
2583static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *mode) 2580static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, umode_t *mode)
2584{ 2581{
2582 uint32_t tmp;
2585 __be32 *p; 2583 __be32 *p;
2586 2584
2587 *mode = 0; 2585 *mode = 0;
@@ -2589,8 +2587,8 @@ static int decode_attr_mode(struct xdr_stream *xdr, uint32_t *bitmap, uint32_t *
2589 return -EIO; 2587 return -EIO;
2590 if (likely(bitmap[1] & FATTR4_WORD1_MODE)) { 2588 if (likely(bitmap[1] & FATTR4_WORD1_MODE)) {
2591 READ_BUF(4); 2589 READ_BUF(4);
2592 READ32(*mode); 2590 READ32(tmp);
2593 *mode &= ~S_IFMT; 2591 *mode = tmp & ~S_IFMT;
2594 bitmap[1] &= ~FATTR4_WORD1_MODE; 2592 bitmap[1] &= ~FATTR4_WORD1_MODE;
2595 } 2593 }
2596 dprintk("%s: file mode=0%o\n", __func__, (unsigned int)*mode); 2594 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
2994 uint32_t attrlen, 2992 uint32_t attrlen,
2995 bitmap[2] = {0}, 2993 bitmap[2] = {0},
2996 type; 2994 type;
2997 int status, fmode = 0; 2995 int status;
2996 umode_t fmode = 0;
2998 uint64_t fileid; 2997 uint64_t fileid;
2999 2998
3000 if ((status = decode_op_hdr(xdr, OP_GETATTR)) != 0) 2999 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
3008 3007
3009 if ((status = decode_attr_type(xdr, bitmap, &type)) != 0) 3008 if ((status = decode_attr_type(xdr, bitmap, &type)) != 0)
3010 goto xdr_error; 3009 goto xdr_error;
3011 fattr->type = nfs_type2fmt[type].nfs2type; 3010 fattr->mode = nfs_type2fmt[type];
3012 fattr->mode = nfs_type2fmt[type].mode;
3013 3011
3014 if ((status = decode_attr_change(xdr, bitmap, &fattr->change_attr)) != 0) 3012 if ((status = decode_attr_change(xdr, bitmap, &fattr->change_attr)) != 0)
3015 goto xdr_error; 3013 goto xdr_error;