patch-2.2.19 linux/fs/nfsd/nfsxdr.c
Next file: linux/fs/nfsd/vfs.c
Previous file: linux/fs/nfsd/nfsproc.c
Back to the patch index
Back to the overall index
- Lines: 119
- Date:
Sun Mar 25 11:37:38 2001
- Orig file:
v2.2.18/fs/nfsd/nfsxdr.c
- Orig date:
Sun Mar 25 11:28:34 2001
diff -u --new-file --recursive --exclude-from /usr/src/exclude v2.2.18/fs/nfsd/nfsxdr.c linux/fs/nfsd/nfsxdr.c
@@ -17,15 +17,6 @@
#define NFSDDBG_FACILITY NFSDDBG_XDR
-u32 nfs_ok, nfserr_perm, nfserr_noent, nfserr_io, nfserr_nxio,
- nfserr_acces, nfserr_exist, nfserr_xdev, nfserr_nodev,
- nfserr_notdir, nfserr_isdir, nfserr_inval, nfserr_fbig,
- nfserr_nospc, nfserr_rofs, nfserr_mlink,
- nfserr_nametoolong, nfserr_notempty, nfserr_dquot, nfserr_stale,
- nfserr_remote, nfserr_badhandle, nfserr_notsync,
- nfserr_badcookie, nfserr_notsupp, nfserr_toosmall,
- nfserr_serverfault, nfserr_badtype, nfserr_jukebox;
-
#ifdef NFSD_OPTIMIZE_SPACE
# define inline
@@ -35,57 +26,12 @@
* Mapping of S_IF* types to NFS file types
*/
static u32 nfs_ftypes[] = {
- NFNON, NFFIFO, NFCHR, NFBAD,
+ NFNON, NFCHR, NFCHR, NFBAD,
NFDIR, NFBAD, NFBLK, NFBAD,
NFREG, NFBAD, NFLNK, NFBAD,
NFSOCK, NFBAD, NFLNK, NFBAD,
};
-/*
- * Initialization of NFS status variables
- */
-void
-nfsd_xdr_init(void)
-{
- static int inited = 0;
-
- if (inited)
- return;
-
- nfs_ok = htonl(NFS_OK);
- nfserr_perm = htonl(NFSERR_PERM);
- nfserr_noent = htonl(NFSERR_NOENT);
- nfserr_io = htonl(NFSERR_IO);
- nfserr_inval = htonl(NFSERR_INVAL);
- nfserr_nxio = htonl(NFSERR_NXIO);
- nfserr_acces = htonl(NFSERR_ACCES);
- nfserr_exist = htonl(NFSERR_EXIST);
- nfserr_xdev = htonl(NFSERR_XDEV);
- nfserr_nodev = htonl(NFSERR_NODEV);
- nfserr_notdir = htonl(NFSERR_NOTDIR);
- nfserr_isdir = htonl(NFSERR_ISDIR);
- nfserr_inval = htonl(NFSERR_INVAL);
- nfserr_fbig = htonl(NFSERR_FBIG);
- nfserr_nospc = htonl(NFSERR_NOSPC);
- nfserr_rofs = htonl(NFSERR_ROFS);
- nfserr_mlink = htonl(NFSERR_MLINK);
- nfserr_nametoolong = htonl(NFSERR_NAMETOOLONG);
- nfserr_notempty = htonl(NFSERR_NOTEMPTY);
- nfserr_dquot = htonl(NFSERR_DQUOT);
- nfserr_stale = htonl(NFSERR_STALE);
- nfserr_remote = htonl(NFSERR_REMOTE);
- nfserr_badhandle = htonl(NFSERR_BADHANDLE);
- nfserr_notsync = htonl(NFSERR_NOT_SYNC);
- nfserr_badcookie = htonl(NFSERR_BAD_COOKIE);
- nfserr_notsupp = htonl(NFSERR_NOTSUPP);
- nfserr_toosmall = htonl(NFSERR_TOOSMALL);
- nfserr_serverfault = htonl(NFSERR_SERVERFAULT);
- nfserr_badtype = htonl(NFSERR_BADTYPE);
- nfserr_jukebox = htonl(NFSERR_JUKEBOX);
-
-
- inited = 1;
-}
/*
* XDR functions for basic NFS types
@@ -189,20 +135,25 @@
static inline u32 *
encode_fattr(struct svc_rqst *rqstp, u32 *p, struct inode *inode)
{
+ int type = (inode->i_mode & S_IFMT);
if (!inode)
return 0;
- *p++ = htonl(nfs_ftypes[(inode->i_mode & S_IFMT) >> 12]);
+ *p++ = htonl(nfs_ftypes[type >> 12]);
*p++ = htonl((u32) inode->i_mode);
*p++ = htonl((u32) inode->i_nlink);
*p++ = htonl((u32) nfsd_ruid(rqstp, inode->i_uid));
*p++ = htonl((u32) nfsd_rgid(rqstp, inode->i_gid));
- if (S_ISLNK(inode->i_mode) && inode->i_size > NFS_MAXPATHLEN) {
+
+ if (S_ISLNK(type) && inode->i_size > NFS_MAXPATHLEN) {
*p++ = htonl(NFS_MAXPATHLEN);
} else {
*p++ = htonl((u32) inode->i_size);
}
*p++ = htonl((u32) inode->i_blksize);
- *p++ = htonl((u32) inode->i_rdev);
+ if (S_ISCHR(type) || S_ISBLK(type))
+ *p++ = htonl((u32) inode->i_rdev);
+ else
+ *p++ = htonl(0xffffffff);
*p++ = htonl((u32) inode->i_blocks);
*p++ = htonl((u32) inode->i_dev);
*p++ = htonl((u32) inode->i_ino);
@@ -465,11 +416,9 @@
cd->eob = 1;
return -EINVAL;
}
- *p++ = xdr_one; /* mark entry present */
- *p++ = htonl((u32) ino); /* file id */
- *p++ = htonl((u32) namlen); /* name length & name */
- memcpy(p, name, namlen);
- p += slen;
+ *p++ = xdr_one; /* mark entry present */
+ *p++ = htonl((u32) ino); /* file id */
+ p = xdr_encode_string(p, name, namlen);/* name length & name */
cd->offset = p; /* remember pointer */
*p++ = ~(u32) 0; /* offset of next entry */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)