diff -Nur nfs-server-2.2beta48/Makefile.in cp-new/Makefile.in --- nfs-server-2.2beta48/Makefile.in Mon Oct 4 05:29:47 1999 +++ cp-new/Makefile.in Tue Feb 22 13:49:42 2000 @@ -99,7 +99,7 @@ haccess.c daemon.c signals.c XDRFILES = mount.x nfs_prot.x GENFILES = mount.h mount_xdr.c mount_svc.c nfs_prot.h nfs_prot_xdr.c \ - ugid.h ugid_xdr.c ugid_clnt.c + ugid.h ugid_xdr.c ugid_clnt.c nfs_prot_clnt.c HDRS = system.h nfsd.h auth.h fh.h logging.h fakefsuid.h \ rpcmisc.h faccess.h rquotad.h rquota.h haccess.h LIBHDRS = fsusage.h getopt.h mountlist.h daemon.h signals.h @@ -112,7 +112,8 @@ signals.o @LIBOBJS@ @ALLOCA@ OBJS = logging.o fh.o devtab.o auth_init.o auth_clnt.o auth.o NFSD_OBJS = nfsd.o rpcmisc.o nfs_dispatch.o getattr.o setattr.o \ - nfs_prot_xdr.o ugid_clnt.o ugid_map.o ugid_xdr.o $(OBJS) + nfs_prot_xdr.o ugid_clnt.o ugid_map.o ugid_xdr.o \ + nfs_prot_clnt.o $(OBJS) MOUNTD_OBJS = mountd.o rpcmisc.o mount_dispatch.o mount_xdr.o rmtab.o \ $(OBJS) SHOWMOUNT_OBJS = showmount.o mount_xdr.o @@ -199,6 +200,10 @@ $(RPCGEN) -c $? | \ sed 's;^#include ".*/nfs_prot.h"$$;#include "nfs_prot.h";' >$@ +nfs_prot_clnt.c: nfs_prot.x + rm -f $@ + $(RPCGEN) -l -o $@ $? + mount.h: mount.x rm -f $@ $(RPCGEN) -h -o $@ $? @@ -224,6 +229,8 @@ nfs_prot_xdr.o: nfs_prot_xdr.c $(COMPILE) $(RPC_WARNFLAGS) -c nfs_prot_xdr.c +nfs_prot_clnt.o: nfs_prot_clnt.c + $(COMPILE) $(RPC_WARNFLAGS) -c nfs_prot_clnt.c mount_xdr.o: mount_xdr.c $(COMPILE) $(RPC_WARNFLAGS) -c mount_xdr.c mount_svc.o: mount_svc.c diff -Nur nfs-server-2.2beta48/nfs_dispatch.c cp-new/nfs_dispatch.c --- nfs-server-2.2beta48/nfs_dispatch.c Thu Nov 12 06:18:44 1998 +++ cp-new/nfs_dispatch.c Thu Feb 24 11:23:44 2000 @@ -9,6 +9,9 @@ * This software may be used for any purpose provided * the above copyright notice is retained. It is supplied * as is, with no warranty expressed or implied. + * + * Thu Feb 24 11:23:09 CST 2000 {paurea,nemo}@gsyc.escet.urjc.es + * Added support for copy. */ #include "nfsd.h" @@ -79,6 +82,8 @@ static char *pr_linkargs(linkargs *argp); static char *pr_symlinkargs(symlinkargs *argp); static char *pr_readdirargs(readdirargs *argp); +static char *pr_copyargs(copyargs *argp); + static struct dispatch_entry dtable[] = { table_ent(nil,nil,null), /* NULL */ @@ -99,18 +104,20 @@ table_ent(nfsstat,diropargs,rmdir), /* RMDIR */ table_ent(readdirres,readdirargs,readdir), /* READDIR */ table_ent(statfsres,nfs_fh,statfs), /* STATFS */ + table_ent(copyres,copyargs,copy), /* COPY */ }; #ifdef CALL_PROFILING #define PATH_PROFILE "/tmp/nfsd.profile" -static struct timeval rtimes[18] = { +static struct timeval rtimes[19] = { + {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, - {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0} + {0,0}, }; -static int calls[18] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +static int calls[19] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; static struct timeval t0, t1; #endif @@ -128,7 +135,7 @@ _rpcsvcdirty = 1; /* Reset our credentials to some sane default. - * Root privs will be needed in auth_fh/fh_find in order + * Root privs will be needed in auth_fh/fh_find in order * to successfully stat() existing file handles */ auth_override_uid(ROOT_UID); @@ -273,6 +280,15 @@ fh_pr(&argp->file), argp->count, argp->offset); return (printbuf); } + + +static char * +pr_copyargs(copyargs *argp) +{ + /* [nemo] BUG: sprintf arguments in printbuf */ + return (printbuf); +} + static char * pr_writeargs(writeargs *argp) diff -Nur nfs-server-2.2beta48/nfs_prot.h cp-new/nfs_prot.h --- nfs-server-2.2beta48/nfs_prot.h Fri Dec 12 07:16:05 1997 +++ cp-new/nfs_prot.h Thu Feb 24 13:08:44 2000 @@ -8,6 +8,11 @@ #include + +#ifdef __cplusplus +extern "C" { +#endif + /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for * unrestricted use provided that this legend is included on all tape @@ -41,6 +46,11 @@ * Copyright (c) 1987, 1990 by Sun Microsystems, Inc. */ +/* + * Thu Feb 24 11:24:21 CST 2000 {paurea,nemo}@gsyc.escet.urjc.es + * Added copy op. + */ + /* from @(#)nfs_prot.x 1.3 91/03/11 TIRPC 1.0 */ #ifndef _rpcsvc_nfs_prot_h #define _rpcsvc_nfs_prot_h @@ -48,6 +58,7 @@ #define NFS_MAXDATA 8192 #define NFS_MAXPATHLEN 1024 #define NFS_MAXNAMLEN 255 +#define NFS_MAXHOSTLEN 255 #define NFS_FHSIZE 32 #define NFS_COOKIESIZE 4 #define NFS_FIFO_DEV -1 @@ -82,14 +93,6 @@ NFSERR_WFLUSH = 99, }; typedef enum nfsstat nfsstat; -#ifdef __cplusplus -extern "C" bool_t xdr_nfsstat(XDR *, nfsstat*); -#elif __STDC__ -extern bool_t xdr_nfsstat(XDR *, nfsstat*); -#else /* Old Style C */ -bool_t xdr_nfsstat(); -#endif /* Old Style C */ - enum ftype { NFNON = 0, @@ -103,41 +106,17 @@ NFFIFO = 8, }; typedef enum ftype ftype; -#ifdef __cplusplus -extern "C" bool_t xdr_ftype(XDR *, ftype*); -#elif __STDC__ -extern bool_t xdr_ftype(XDR *, ftype*); -#else /* Old Style C */ -bool_t xdr_ftype(); -#endif /* Old Style C */ - struct nfs_fh { char data[NFS_FHSIZE]; }; typedef struct nfs_fh nfs_fh; -#ifdef __cplusplus -extern "C" bool_t xdr_nfs_fh(XDR *, nfs_fh*); -#elif __STDC__ -extern bool_t xdr_nfs_fh(XDR *, nfs_fh*); -#else /* Old Style C */ -bool_t xdr_nfs_fh(); -#endif /* Old Style C */ - struct nfstime { u_int seconds; u_int useconds; }; typedef struct nfstime nfstime; -#ifdef __cplusplus -extern "C" bool_t xdr_nfstime(XDR *, nfstime*); -#elif __STDC__ -extern bool_t xdr_nfstime(XDR *, nfstime*); -#else /* Old Style C */ -bool_t xdr_nfstime(); -#endif /* Old Style C */ - struct fattr { ftype type; @@ -156,14 +135,6 @@ nfstime ctime; }; typedef struct fattr fattr; -#ifdef __cplusplus -extern "C" bool_t xdr_fattr(XDR *, fattr*); -#elif __STDC__ -extern bool_t xdr_fattr(XDR *, fattr*); -#else /* Old Style C */ -bool_t xdr_fattr(); -#endif /* Old Style C */ - struct sattr { u_int mode; @@ -174,34 +145,12 @@ nfstime mtime; }; typedef struct sattr sattr; -#ifdef __cplusplus -extern "C" bool_t xdr_sattr(XDR *, sattr*); -#elif __STDC__ -extern bool_t xdr_sattr(XDR *, sattr*); -#else /* Old Style C */ -bool_t xdr_sattr(); -#endif /* Old Style C */ - typedef char *filename; -#ifdef __cplusplus -extern "C" bool_t xdr_filename(XDR *, filename*); -#elif __STDC__ -extern bool_t xdr_filename(XDR *, filename*); -#else /* Old Style C */ -bool_t xdr_filename(); -#endif /* Old Style C */ - typedef char *nfspath; -#ifdef __cplusplus -extern "C" bool_t xdr_nfspath(XDR *, nfspath*); -#elif __STDC__ -extern bool_t xdr_nfspath(XDR *, nfspath*); -#else /* Old Style C */ -bool_t xdr_nfspath(); -#endif /* Old Style C */ +typedef char *host; struct attrstat { nfsstat status; @@ -210,56 +159,24 @@ } attrstat_u; }; typedef struct attrstat attrstat; -#ifdef __cplusplus -extern "C" bool_t xdr_attrstat(XDR *, attrstat*); -#elif __STDC__ -extern bool_t xdr_attrstat(XDR *, attrstat*); -#else /* Old Style C */ -bool_t xdr_attrstat(); -#endif /* Old Style C */ - struct sattrargs { nfs_fh file; sattr attributes; }; typedef struct sattrargs sattrargs; -#ifdef __cplusplus -extern "C" bool_t xdr_sattrargs(XDR *, sattrargs*); -#elif __STDC__ -extern bool_t xdr_sattrargs(XDR *, sattrargs*); -#else /* Old Style C */ -bool_t xdr_sattrargs(); -#endif /* Old Style C */ - struct diropargs { nfs_fh dir; filename name; }; typedef struct diropargs diropargs; -#ifdef __cplusplus -extern "C" bool_t xdr_diropargs(XDR *, diropargs*); -#elif __STDC__ -extern bool_t xdr_diropargs(XDR *, diropargs*); -#else /* Old Style C */ -bool_t xdr_diropargs(); -#endif /* Old Style C */ - struct diropokres { nfs_fh file; fattr attributes; }; typedef struct diropokres diropokres; -#ifdef __cplusplus -extern "C" bool_t xdr_diropokres(XDR *, diropokres*); -#elif __STDC__ -extern bool_t xdr_diropokres(XDR *, diropokres*); -#else /* Old Style C */ -bool_t xdr_diropokres(); -#endif /* Old Style C */ - struct diropres { nfsstat status; @@ -268,14 +185,6 @@ } diropres_u; }; typedef struct diropres diropres; -#ifdef __cplusplus -extern "C" bool_t xdr_diropres(XDR *, diropres*); -#elif __STDC__ -extern bool_t xdr_diropres(XDR *, diropres*); -#else /* Old Style C */ -bool_t xdr_diropres(); -#endif /* Old Style C */ - struct readlinkres { nfsstat status; @@ -284,14 +193,6 @@ } readlinkres_u; }; typedef struct readlinkres readlinkres; -#ifdef __cplusplus -extern "C" bool_t xdr_readlinkres(XDR *, readlinkres*); -#elif __STDC__ -extern bool_t xdr_readlinkres(XDR *, readlinkres*); -#else /* Old Style C */ -bool_t xdr_readlinkres(); -#endif /* Old Style C */ - struct readargs { nfs_fh file; @@ -300,14 +201,16 @@ u_int totalcount; }; typedef struct readargs readargs; -#ifdef __cplusplus -extern "C" bool_t xdr_readargs(XDR *, readargs*); -#elif __STDC__ -extern bool_t xdr_readargs(XDR *, readargs*); -#else /* Old Style C */ -bool_t xdr_readargs(); -#endif /* Old Style C */ +struct copyargs { + nfs_fh filedest; + nfs_fh filesrc; + u_int offsetdest; + u_int offsetsrc; + u_int count; + host hostname; +}; +typedef struct copyargs copyargs; struct readokres { fattr attributes; @@ -317,14 +220,6 @@ } data; }; typedef struct readokres readokres; -#ifdef __cplusplus -extern "C" bool_t xdr_readokres(XDR *, readokres*); -#elif __STDC__ -extern bool_t xdr_readokres(XDR *, readokres*); -#else /* Old Style C */ -bool_t xdr_readokres(); -#endif /* Old Style C */ - struct readres { nfsstat status; @@ -333,14 +228,25 @@ } readres_u; }; typedef struct readres readres; -#ifdef __cplusplus -extern "C" bool_t xdr_readres(XDR *, readres*); -#elif __STDC__ -extern bool_t xdr_readres(XDR *, readres*); -#else /* Old Style C */ -bool_t xdr_readres(); -#endif /* Old Style C */ +struct copyokres { + fattr attributesdest; + fattr attributessrc; + u_int count; + struct { + u_int data_len; + char *data_val; + } data; +}; +typedef struct copyokres copyokres; + +struct copyres { + nfsstat status; + union { + copyokres reply; + } copyres_u; +}; +typedef struct copyres copyres; struct writeargs { nfs_fh file; @@ -353,56 +259,24 @@ } data; }; typedef struct writeargs writeargs; -#ifdef __cplusplus -extern "C" bool_t xdr_writeargs(XDR *, writeargs*); -#elif __STDC__ -extern bool_t xdr_writeargs(XDR *, writeargs*); -#else /* Old Style C */ -bool_t xdr_writeargs(); -#endif /* Old Style C */ - struct createargs { diropargs where; sattr attributes; }; typedef struct createargs createargs; -#ifdef __cplusplus -extern "C" bool_t xdr_createargs(XDR *, createargs*); -#elif __STDC__ -extern bool_t xdr_createargs(XDR *, createargs*); -#else /* Old Style C */ -bool_t xdr_createargs(); -#endif /* Old Style C */ - struct renameargs { diropargs from; diropargs to; }; typedef struct renameargs renameargs; -#ifdef __cplusplus -extern "C" bool_t xdr_renameargs(XDR *, renameargs*); -#elif __STDC__ -extern bool_t xdr_renameargs(XDR *, renameargs*); -#else /* Old Style C */ -bool_t xdr_renameargs(); -#endif /* Old Style C */ - struct linkargs { nfs_fh from; diropargs to; }; typedef struct linkargs linkargs; -#ifdef __cplusplus -extern "C" bool_t xdr_linkargs(XDR *, linkargs*); -#elif __STDC__ -extern bool_t xdr_linkargs(XDR *, linkargs*); -#else /* Old Style C */ -bool_t xdr_linkargs(); -#endif /* Old Style C */ - struct symlinkargs { diropargs from; @@ -410,24 +284,8 @@ sattr attributes; }; typedef struct symlinkargs symlinkargs; -#ifdef __cplusplus -extern "C" bool_t xdr_symlinkargs(XDR *, symlinkargs*); -#elif __STDC__ -extern bool_t xdr_symlinkargs(XDR *, symlinkargs*); -#else /* Old Style C */ -bool_t xdr_symlinkargs(); -#endif /* Old Style C */ - typedef char nfscookie[NFS_COOKIESIZE]; -#ifdef __cplusplus -extern "C" bool_t xdr_nfscookie(XDR *, nfscookie); -#elif __STDC__ -extern bool_t xdr_nfscookie(XDR *, nfscookie); -#else /* Old Style C */ -bool_t xdr_nfscookie(); -#endif /* Old Style C */ - struct readdirargs { nfs_fh dir; @@ -435,14 +293,6 @@ u_int count; }; typedef struct readdirargs readdirargs; -#ifdef __cplusplus -extern "C" bool_t xdr_readdirargs(XDR *, readdirargs*); -#elif __STDC__ -extern bool_t xdr_readdirargs(XDR *, readdirargs*); -#else /* Old Style C */ -bool_t xdr_readdirargs(); -#endif /* Old Style C */ - struct entry { u_int fileid; @@ -451,28 +301,12 @@ struct entry *nextentry; }; typedef struct entry entry; -#ifdef __cplusplus -extern "C" bool_t xdr_entry(XDR *, entry*); -#elif __STDC__ -extern bool_t xdr_entry(XDR *, entry*); -#else /* Old Style C */ -bool_t xdr_entry(); -#endif /* Old Style C */ - struct dirlist { entry *entries; bool_t eof; }; typedef struct dirlist dirlist; -#ifdef __cplusplus -extern "C" bool_t xdr_dirlist(XDR *, dirlist*); -#elif __STDC__ -extern bool_t xdr_dirlist(XDR *, dirlist*); -#else /* Old Style C */ -bool_t xdr_dirlist(); -#endif /* Old Style C */ - struct readdirres { nfsstat status; @@ -481,14 +315,6 @@ } readdirres_u; }; typedef struct readdirres readdirres; -#ifdef __cplusplus -extern "C" bool_t xdr_readdirres(XDR *, readdirres*); -#elif __STDC__ -extern bool_t xdr_readdirres(XDR *, readdirres*); -#else /* Old Style C */ -bool_t xdr_readdirres(); -#endif /* Old Style C */ - struct statfsokres { u_int tsize; @@ -498,14 +324,6 @@ u_int bavail; }; typedef struct statfsokres statfsokres; -#ifdef __cplusplus -extern "C" bool_t xdr_statfsokres(XDR *, statfsokres*); -#elif __STDC__ -extern bool_t xdr_statfsokres(XDR *, statfsokres*); -#else /* Old Style C */ -bool_t xdr_statfsokres(); -#endif /* Old Style C */ - struct statfsres { nfsstat status; @@ -514,186 +332,208 @@ } statfsres_u; }; typedef struct statfsres statfsres; -#ifdef __cplusplus -extern "C" bool_t xdr_statfsres(XDR *, statfsres*); -#elif __STDC__ -extern bool_t xdr_statfsres(XDR *, statfsres*); -#else /* Old Style C */ -bool_t xdr_statfsres(); -#endif /* Old Style C */ - #endif /*!_rpcsvc_nfs_prot_h*/ -#define NFS_PROGRAM ((u_long)100003) -#define NFS_VERSION ((u_long)2) - -#ifdef __cplusplus -#define NFSPROC_NULL ((u_long)0) -extern "C" void * nfsproc_null_2(void *, CLIENT *); -extern "C" void * nfsproc_null_2_svc(void *, struct svc_req *); -#define NFSPROC_GETATTR ((u_long)1) -extern "C" attrstat * nfsproc_getattr_2(nfs_fh *, CLIENT *); -extern "C" attrstat * nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *); -#define NFSPROC_SETATTR ((u_long)2) -extern "C" attrstat * nfsproc_setattr_2(sattrargs *, CLIENT *); -extern "C" attrstat * nfsproc_setattr_2_svc(sattrargs *, struct svc_req *); -#define NFSPROC_ROOT ((u_long)3) -extern "C" void * nfsproc_root_2(void *, CLIENT *); -extern "C" void * nfsproc_root_2_svc(void *, struct svc_req *); -#define NFSPROC_LOOKUP ((u_long)4) -extern "C" diropres * nfsproc_lookup_2(diropargs *, CLIENT *); -extern "C" diropres * nfsproc_lookup_2_svc(diropargs *, struct svc_req *); -#define NFSPROC_READLINK ((u_long)5) -extern "C" readlinkres * nfsproc_readlink_2(nfs_fh *, CLIENT *); -extern "C" readlinkres * nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *); -#define NFSPROC_READ ((u_long)6) -extern "C" readres * nfsproc_read_2(readargs *, CLIENT *); -extern "C" readres * nfsproc_read_2_svc(readargs *, struct svc_req *); -#define NFSPROC_WRITECACHE ((u_long)7) -extern "C" void * nfsproc_writecache_2(void *, CLIENT *); -extern "C" void * nfsproc_writecache_2_svc(void *, struct svc_req *); -#define NFSPROC_WRITE ((u_long)8) -extern "C" attrstat * nfsproc_write_2(writeargs *, CLIENT *); -extern "C" attrstat * nfsproc_write_2_svc(writeargs *, struct svc_req *); -#define NFSPROC_CREATE ((u_long)9) -extern "C" diropres * nfsproc_create_2(createargs *, CLIENT *); -extern "C" diropres * nfsproc_create_2_svc(createargs *, struct svc_req *); -#define NFSPROC_REMOVE ((u_long)10) -extern "C" nfsstat * nfsproc_remove_2(diropargs *, CLIENT *); -extern "C" nfsstat * nfsproc_remove_2_svc(diropargs *, struct svc_req *); -#define NFSPROC_RENAME ((u_long)11) -extern "C" nfsstat * nfsproc_rename_2(renameargs *, CLIENT *); -extern "C" nfsstat * nfsproc_rename_2_svc(renameargs *, struct svc_req *); -#define NFSPROC_LINK ((u_long)12) -extern "C" nfsstat * nfsproc_link_2(linkargs *, CLIENT *); -extern "C" nfsstat * nfsproc_link_2_svc(linkargs *, struct svc_req *); -#define NFSPROC_SYMLINK ((u_long)13) -extern "C" nfsstat * nfsproc_symlink_2(symlinkargs *, CLIENT *); -extern "C" nfsstat * nfsproc_symlink_2_svc(symlinkargs *, struct svc_req *); -#define NFSPROC_MKDIR ((u_long)14) -extern "C" diropres * nfsproc_mkdir_2(createargs *, CLIENT *); -extern "C" diropres * nfsproc_mkdir_2_svc(createargs *, struct svc_req *); -#define NFSPROC_RMDIR ((u_long)15) -extern "C" nfsstat * nfsproc_rmdir_2(diropargs *, CLIENT *); -extern "C" nfsstat * nfsproc_rmdir_2_svc(diropargs *, struct svc_req *); -#define NFSPROC_READDIR ((u_long)16) -extern "C" readdirres * nfsproc_readdir_2(readdirargs *, CLIENT *); -extern "C" readdirres * nfsproc_readdir_2_svc(readdirargs *, struct svc_req *); -#define NFSPROC_STATFS ((u_long)17) -extern "C" statfsres * nfsproc_statfs_2(nfs_fh *, CLIENT *); -extern "C" statfsres * nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *); +#define NFS_PROGRAM 100003 +#define NFS_VERSION 2 -#elif __STDC__ -#define NFSPROC_NULL ((u_long)0) +#if defined(__STDC__) || defined(__cplusplus) +#define NFSPROC_NULL 0 extern void * nfsproc_null_2(void *, CLIENT *); extern void * nfsproc_null_2_svc(void *, struct svc_req *); -#define NFSPROC_GETATTR ((u_long)1) +#define NFSPROC_GETATTR 1 extern attrstat * nfsproc_getattr_2(nfs_fh *, CLIENT *); extern attrstat * nfsproc_getattr_2_svc(nfs_fh *, struct svc_req *); -#define NFSPROC_SETATTR ((u_long)2) +#define NFSPROC_SETATTR 2 extern attrstat * nfsproc_setattr_2(sattrargs *, CLIENT *); extern attrstat * nfsproc_setattr_2_svc(sattrargs *, struct svc_req *); -#define NFSPROC_ROOT ((u_long)3) +#define NFSPROC_ROOT 3 extern void * nfsproc_root_2(void *, CLIENT *); extern void * nfsproc_root_2_svc(void *, struct svc_req *); -#define NFSPROC_LOOKUP ((u_long)4) +#define NFSPROC_LOOKUP 4 extern diropres * nfsproc_lookup_2(diropargs *, CLIENT *); extern diropres * nfsproc_lookup_2_svc(diropargs *, struct svc_req *); -#define NFSPROC_READLINK ((u_long)5) +#define NFSPROC_READLINK 5 extern readlinkres * nfsproc_readlink_2(nfs_fh *, CLIENT *); extern readlinkres * nfsproc_readlink_2_svc(nfs_fh *, struct svc_req *); -#define NFSPROC_READ ((u_long)6) +#define NFSPROC_READ 6 extern readres * nfsproc_read_2(readargs *, CLIENT *); extern readres * nfsproc_read_2_svc(readargs *, struct svc_req *); -#define NFSPROC_WRITECACHE ((u_long)7) +#define NFSPROC_WRITECACHE 7 extern void * nfsproc_writecache_2(void *, CLIENT *); extern void * nfsproc_writecache_2_svc(void *, struct svc_req *); -#define NFSPROC_WRITE ((u_long)8) +#define NFSPROC_WRITE 8 extern attrstat * nfsproc_write_2(writeargs *, CLIENT *); extern attrstat * nfsproc_write_2_svc(writeargs *, struct svc_req *); -#define NFSPROC_CREATE ((u_long)9) +#define NFSPROC_CREATE 9 extern diropres * nfsproc_create_2(createargs *, CLIENT *); extern diropres * nfsproc_create_2_svc(createargs *, struct svc_req *); -#define NFSPROC_REMOVE ((u_long)10) +#define NFSPROC_REMOVE 10 extern nfsstat * nfsproc_remove_2(diropargs *, CLIENT *); extern nfsstat * nfsproc_remove_2_svc(diropargs *, struct svc_req *); -#define NFSPROC_RENAME ((u_long)11) +#define NFSPROC_RENAME 11 extern nfsstat * nfsproc_rename_2(renameargs *, CLIENT *); extern nfsstat * nfsproc_rename_2_svc(renameargs *, struct svc_req *); -#define NFSPROC_LINK ((u_long)12) +#define NFSPROC_LINK 12 extern nfsstat * nfsproc_link_2(linkargs *, CLIENT *); extern nfsstat * nfsproc_link_2_svc(linkargs *, struct svc_req *); -#define NFSPROC_SYMLINK ((u_long)13) +#define NFSPROC_SYMLINK 13 extern nfsstat * nfsproc_symlink_2(symlinkargs *, CLIENT *); extern nfsstat * nfsproc_symlink_2_svc(symlinkargs *, struct svc_req *); -#define NFSPROC_MKDIR ((u_long)14) +#define NFSPROC_MKDIR 14 extern diropres * nfsproc_mkdir_2(createargs *, CLIENT *); extern diropres * nfsproc_mkdir_2_svc(createargs *, struct svc_req *); -#define NFSPROC_RMDIR ((u_long)15) +#define NFSPROC_RMDIR 15 extern nfsstat * nfsproc_rmdir_2(diropargs *, CLIENT *); extern nfsstat * nfsproc_rmdir_2_svc(diropargs *, struct svc_req *); -#define NFSPROC_READDIR ((u_long)16) +#define NFSPROC_READDIR 16 extern readdirres * nfsproc_readdir_2(readdirargs *, CLIENT *); extern readdirres * nfsproc_readdir_2_svc(readdirargs *, struct svc_req *); -#define NFSPROC_STATFS ((u_long)17) +#define NFSPROC_STATFS 17 extern statfsres * nfsproc_statfs_2(nfs_fh *, CLIENT *); extern statfsres * nfsproc_statfs_2_svc(nfs_fh *, struct svc_req *); +#define NFSPROC_COPY 18 +extern copyres * nfsproc_copy_2(copyargs *, CLIENT *); +extern copyres * nfsproc_copy_2_svc(copyargs *, struct svc_req *); +extern int nfs_program_2_freeresult (SVCXPRT *, xdrproc_t, caddr_t); -#else /* Old Style C */ -#define NFSPROC_NULL ((u_long)0) +#else /* K&R C */ +#define NFSPROC_NULL 0 extern void * nfsproc_null_2(); extern void * nfsproc_null_2_svc(); -#define NFSPROC_GETATTR ((u_long)1) +#define NFSPROC_GETATTR 1 extern attrstat * nfsproc_getattr_2(); extern attrstat * nfsproc_getattr_2_svc(); -#define NFSPROC_SETATTR ((u_long)2) +#define NFSPROC_SETATTR 2 extern attrstat * nfsproc_setattr_2(); extern attrstat * nfsproc_setattr_2_svc(); -#define NFSPROC_ROOT ((u_long)3) +#define NFSPROC_ROOT 3 extern void * nfsproc_root_2(); extern void * nfsproc_root_2_svc(); -#define NFSPROC_LOOKUP ((u_long)4) +#define NFSPROC_LOOKUP 4 extern diropres * nfsproc_lookup_2(); extern diropres * nfsproc_lookup_2_svc(); -#define NFSPROC_READLINK ((u_long)5) +#define NFSPROC_READLINK 5 extern readlinkres * nfsproc_readlink_2(); extern readlinkres * nfsproc_readlink_2_svc(); -#define NFSPROC_READ ((u_long)6) +#define NFSPROC_READ 6 extern readres * nfsproc_read_2(); extern readres * nfsproc_read_2_svc(); -#define NFSPROC_WRITECACHE ((u_long)7) +#define NFSPROC_WRITECACHE 7 extern void * nfsproc_writecache_2(); extern void * nfsproc_writecache_2_svc(); -#define NFSPROC_WRITE ((u_long)8) +#define NFSPROC_WRITE 8 extern attrstat * nfsproc_write_2(); extern attrstat * nfsproc_write_2_svc(); -#define NFSPROC_CREATE ((u_long)9) +#define NFSPROC_CREATE 9 extern diropres * nfsproc_create_2(); extern diropres * nfsproc_create_2_svc(); -#define NFSPROC_REMOVE ((u_long)10) +#define NFSPROC_REMOVE 10 extern nfsstat * nfsproc_remove_2(); extern nfsstat * nfsproc_remove_2_svc(); -#define NFSPROC_RENAME ((u_long)11) +#define NFSPROC_RENAME 11 extern nfsstat * nfsproc_rename_2(); extern nfsstat * nfsproc_rename_2_svc(); -#define NFSPROC_LINK ((u_long)12) +#define NFSPROC_LINK 12 extern nfsstat * nfsproc_link_2(); extern nfsstat * nfsproc_link_2_svc(); -#define NFSPROC_SYMLINK ((u_long)13) +#define NFSPROC_SYMLINK 13 extern nfsstat * nfsproc_symlink_2(); extern nfsstat * nfsproc_symlink_2_svc(); -#define NFSPROC_MKDIR ((u_long)14) +#define NFSPROC_MKDIR 14 extern diropres * nfsproc_mkdir_2(); extern diropres * nfsproc_mkdir_2_svc(); -#define NFSPROC_RMDIR ((u_long)15) +#define NFSPROC_RMDIR 15 extern nfsstat * nfsproc_rmdir_2(); extern nfsstat * nfsproc_rmdir_2_svc(); -#define NFSPROC_READDIR ((u_long)16) +#define NFSPROC_READDIR 16 extern readdirres * nfsproc_readdir_2(); extern readdirres * nfsproc_readdir_2_svc(); -#define NFSPROC_STATFS ((u_long)17) +#define NFSPROC_STATFS 17 extern statfsres * nfsproc_statfs_2(); extern statfsres * nfsproc_statfs_2_svc(); -#endif /* Old Style C */ +#define NFSPROC_COPY 18 +extern copyres * nfsproc_copy_2(); +extern copyres * nfsproc_copy_2_svc(); +extern int nfs_program_2_freeresult (); +#endif /* K&R C */ + +/* the xdr functions */ + +#if defined(__STDC__) || defined(__cplusplus) +extern bool_t xdr_nfsstat (XDR *, nfsstat*); +extern bool_t xdr_ftype (XDR *, ftype*); +extern bool_t xdr_nfs_fh (XDR *, nfs_fh*); +extern bool_t xdr_nfstime (XDR *, nfstime*); +extern bool_t xdr_fattr (XDR *, fattr*); +extern bool_t xdr_sattr (XDR *, sattr*); +extern bool_t xdr_filename (XDR *, filename*); +extern bool_t xdr_nfspath (XDR *, nfspath*); +extern bool_t xdr_host (XDR *, host*); +extern bool_t xdr_attrstat (XDR *, attrstat*); +extern bool_t xdr_sattrargs (XDR *, sattrargs*); +extern bool_t xdr_diropargs (XDR *, diropargs*); +extern bool_t xdr_diropokres (XDR *, diropokres*); +extern bool_t xdr_diropres (XDR *, diropres*); +extern bool_t xdr_readlinkres (XDR *, readlinkres*); +extern bool_t xdr_readargs (XDR *, readargs*); +extern bool_t xdr_copyargs (XDR *, copyargs*); +extern bool_t xdr_readokres (XDR *, readokres*); +extern bool_t xdr_readres (XDR *, readres*); +extern bool_t xdr_copyokres (XDR *, copyokres*); +extern bool_t xdr_copyres (XDR *, copyres*); +extern bool_t xdr_writeargs (XDR *, writeargs*); +extern bool_t xdr_createargs (XDR *, createargs*); +extern bool_t xdr_renameargs (XDR *, renameargs*); +extern bool_t xdr_linkargs (XDR *, linkargs*); +extern bool_t xdr_symlinkargs (XDR *, symlinkargs*); +extern bool_t xdr_nfscookie (XDR *, nfscookie); +extern bool_t xdr_readdirargs (XDR *, readdirargs*); +extern bool_t xdr_entry (XDR *, entry*); +extern bool_t xdr_dirlist (XDR *, dirlist*); +extern bool_t xdr_readdirres (XDR *, readdirres*); +extern bool_t xdr_statfsokres (XDR *, statfsokres*); +extern bool_t xdr_statfsres (XDR *, statfsres*); + +#else /* K&R C */ +extern bool_t xdr_nfsstat (); +extern bool_t xdr_ftype (); +extern bool_t xdr_nfs_fh (); +extern bool_t xdr_nfstime (); +extern bool_t xdr_fattr (); +extern bool_t xdr_sattr (); +extern bool_t xdr_filename (); +extern bool_t xdr_nfspath (); +extern bool_t xdr_host (); +extern bool_t xdr_attrstat (); +extern bool_t xdr_sattrargs (); +extern bool_t xdr_diropargs (); +extern bool_t xdr_diropokres (); +extern bool_t xdr_diropres (); +extern bool_t xdr_readlinkres (); +extern bool_t xdr_readargs (); +extern bool_t xdr_copyargs (); +extern bool_t xdr_readokres (); +extern bool_t xdr_readres (); +extern bool_t xdr_copyokres (); +extern bool_t xdr_copyres (); +extern bool_t xdr_writeargs (); +extern bool_t xdr_createargs (); +extern bool_t xdr_renameargs (); +extern bool_t xdr_linkargs (); +extern bool_t xdr_symlinkargs (); +extern bool_t xdr_nfscookie (); +extern bool_t xdr_readdirargs (); +extern bool_t xdr_entry (); +extern bool_t xdr_dirlist (); +extern bool_t xdr_readdirres (); +extern bool_t xdr_statfsokres (); +extern bool_t xdr_statfsres (); + +#endif /* K&R C */ + +#ifdef __cplusplus +} +#endif #endif /* !_NFS_PROT_H_RPCGEN */ diff -Nur nfs-server-2.2beta48/nfs_prot.x cp-new/nfs_prot.x --- nfs-server-2.2beta48/nfs_prot.x Sat Aug 17 10:54:24 1996 +++ cp-new/nfs_prot.x Thu Feb 24 11:25:05 2000 @@ -32,6 +32,11 @@ % * Copyright (c) 1987, 1990 by Sun Microsystems, Inc. % */ % +%/* +% * Thu Feb 24 11:24:21 CST 2000 {paurea,nemo}@gsyc.escet.urjc.es +% * Added copy op. +% */ +% %/* from @(#)nfs_prot.x 1.3 91/03/11 TIRPC 1.0 */ #ifdef RPC_HDR @@ -43,6 +48,7 @@ const NFS_MAXDATA = 8192; const NFS_MAXPATHLEN = 1024; const NFS_MAXNAMLEN = 255; +const NFS_MAXHOSTLEN = 255; const NFS_FHSIZE = 32; const NFS_COOKIESIZE = 4; const NFS_FIFO_DEV = -1; /* size kludge for named pipes */ @@ -106,7 +112,7 @@ opaque data[NFS_FHSIZE]; }; -/* +/* * Timeval */ struct nfstime { @@ -148,8 +154,9 @@ }; -typedef string filename; +typedef string filename; typedef string nfspath; +typedef string host; /* * Reply status with file attributes @@ -206,6 +213,20 @@ unsigned totalcount; /* total read count (from this offset)*/ }; + +/* + * Arguments to remote copy + */ +struct copyargs { + nfs_fh filedest; /* handle for destination file */ + nfs_fh filesrc; /* handle for source file */ + unsigned offsetdest; /* byte offset in dest file */ + unsigned offsetsrc; /* byte offset in src file */ + unsigned count; /* immediate read count */ + host hostname; +}; + + /* * Status OK portion of remote read reply */ @@ -221,8 +242,27 @@ void; }; + /* - * Arguments to remote write + * Status OK portion of remote copy reply + */ +struct copyokres { + fattr attributesdest; /* attributes, need for pagin*/ + fattr attributessrc; /* attributes, need for pagin*/ + unsigned count; + opaque data ; +}; + +union copyres switch (nfsstat status) { +case NFS_OK: + copyokres reply; +default: + void; +}; + + +/* + * Arguments to remote write */ struct writeargs { nfs_fh file; /* handle for file */ @@ -304,28 +344,28 @@ */ program NFS_PROGRAM { version NFS_VERSION { - void + void NFSPROC_NULL(void) = 0; - attrstat + attrstat NFSPROC_GETATTR(nfs_fh) = 1; - attrstat + attrstat NFSPROC_SETATTR(sattrargs) = 2; - void + void NFSPROC_ROOT(void) = 3; - diropres + diropres NFSPROC_LOOKUP(diropargs) = 4; - readlinkres + readlinkres NFSPROC_READLINK(nfs_fh) = 5; - readres + readres NFSPROC_READ(readargs) = 6; - void + void NFSPROC_WRITECACHE(void) = 7; attrstat @@ -357,9 +397,17 @@ statfsres NFSPROC_STATFS(nfs_fh) = 17; + + copyres + NFSPROC_COPY(copyargs) = 18; } = 2; } = 100003; #ifdef RPC_HDR %#endif /*!_rpcsvc_nfs_prot_h*/ #endif + + + + + diff -Nur nfs-server-2.2beta48/nfs_prot_xdr.c cp-new/nfs_prot_xdr.c --- nfs-server-2.2beta48/nfs_prot_xdr.c Mon Sep 28 04:36:29 1998 +++ cp-new/nfs_prot_xdr.c Thu Feb 24 13:23:34 2000 @@ -3,9 +3,6 @@ * It was generated using rpcgen. */ -#include -#include - #include "nfs_prot.h" /* * Sun RPC is a product of Sun Microsystems, Inc. and is provided for @@ -40,840 +37,779 @@ * Copyright (c) 1987, 1990 by Sun Microsystems, Inc. */ +/* + * Thu Feb 24 11:24:21 CST 2000 {paurea,nemo}@gsyc.escet.urjc.es + * Added copy op. + */ + /* from @(#)nfs_prot.x 1.3 91/03/11 TIRPC 1.0 */ bool_t -xdr_nfsstat(XDR *xdrs, nfsstat *objp) +xdr_nfsstat (XDR *xdrs, nfsstat *objp) { + register int32_t *buf; - register long *buf=buf; + if (!xdr_enum (xdrs, (enum_t *) objp)) + return FALSE; + return TRUE; +} + +bool_t +xdr_ftype (XDR *xdrs, ftype *objp) +{ + register int32_t *buf; - if (!xdr_enum(xdrs, (enum_t *)objp)) { - return (FALSE); - } - return (TRUE); + if (!xdr_enum (xdrs, (enum_t *) objp)) + return FALSE; + return TRUE; } bool_t -xdr_ftype(XDR *xdrs, ftype *objp) +xdr_nfs_fh (XDR *xdrs, nfs_fh *objp) { + register int32_t *buf; - register long *buf=buf; + int i; + if (!xdr_opaque (xdrs, objp->data, NFS_FHSIZE)) + return FALSE; + return TRUE; +} + +bool_t +xdr_nfstime (XDR *xdrs, nfstime *objp) +{ + register int32_t *buf; - if (!xdr_enum(xdrs, (enum_t *)objp)) { - return (FALSE); - } - return (TRUE); + if (!xdr_u_int (xdrs, &objp->seconds)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->useconds)) + return FALSE; + return TRUE; } bool_t -xdr_nfs_fh(XDR *xdrs, nfs_fh *objp) +xdr_fattr (XDR *xdrs, fattr *objp) { + register int32_t *buf; - register long *buf=buf; - int i=i; - if (!xdr_opaque(xdrs, objp->data, NFS_FHSIZE)) { - return (FALSE); - } - return (TRUE); + if (xdrs->x_op == XDR_ENCODE) { + if (!xdr_ftype (xdrs, &objp->type)) + return FALSE; + buf = XDR_INLINE (xdrs, 10 * BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_u_int (xdrs, &objp->mode)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->nlink)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->uid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->gid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->size)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->blocksize)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->rdev)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->blocks)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->fsid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->fileid)) + return FALSE; + + } else { + IXDR_PUT_U_LONG(buf, objp->mode); + IXDR_PUT_U_LONG(buf, objp->nlink); + IXDR_PUT_U_LONG(buf, objp->uid); + IXDR_PUT_U_LONG(buf, objp->gid); + IXDR_PUT_U_LONG(buf, objp->size); + IXDR_PUT_U_LONG(buf, objp->blocksize); + IXDR_PUT_U_LONG(buf, objp->rdev); + IXDR_PUT_U_LONG(buf, objp->blocks); + IXDR_PUT_U_LONG(buf, objp->fsid); + IXDR_PUT_U_LONG(buf, objp->fileid); + } + if (!xdr_nfstime (xdrs, &objp->atime)) + return FALSE; + if (!xdr_nfstime (xdrs, &objp->mtime)) + return FALSE; + if (!xdr_nfstime (xdrs, &objp->ctime)) + return FALSE; + return TRUE; + } else if (xdrs->x_op == XDR_DECODE) { + if (!xdr_ftype (xdrs, &objp->type)) + return FALSE; + buf = XDR_INLINE (xdrs, 10 * BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_u_int (xdrs, &objp->mode)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->nlink)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->uid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->gid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->size)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->blocksize)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->rdev)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->blocks)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->fsid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->fileid)) + return FALSE; + + } else { + objp->mode = IXDR_GET_U_LONG(buf); + objp->nlink = IXDR_GET_U_LONG(buf); + objp->uid = IXDR_GET_U_LONG(buf); + objp->gid = IXDR_GET_U_LONG(buf); + objp->size = IXDR_GET_U_LONG(buf); + objp->blocksize = IXDR_GET_U_LONG(buf); + objp->rdev = IXDR_GET_U_LONG(buf); + objp->blocks = IXDR_GET_U_LONG(buf); + objp->fsid = IXDR_GET_U_LONG(buf); + objp->fileid = IXDR_GET_U_LONG(buf); + } + if (!xdr_nfstime (xdrs, &objp->atime)) + return FALSE; + if (!xdr_nfstime (xdrs, &objp->mtime)) + return FALSE; + if (!xdr_nfstime (xdrs, &objp->ctime)) + return FALSE; + return TRUE; + } + + if (!xdr_ftype (xdrs, &objp->type)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->mode)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->nlink)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->uid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->gid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->size)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->blocksize)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->rdev)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->blocks)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->fsid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->fileid)) + return FALSE; + if (!xdr_nfstime (xdrs, &objp->atime)) + return FALSE; + if (!xdr_nfstime (xdrs, &objp->mtime)) + return FALSE; + if (!xdr_nfstime (xdrs, &objp->ctime)) + return FALSE; + return TRUE; } bool_t -xdr_nfstime(XDR *xdrs, nfstime *objp) +xdr_sattr (XDR *xdrs, sattr *objp) { + register int32_t *buf; + + + if (xdrs->x_op == XDR_ENCODE) { + buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_u_int (xdrs, &objp->mode)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->uid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->gid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->size)) + return FALSE; + + } else { + IXDR_PUT_U_LONG(buf, objp->mode); + IXDR_PUT_U_LONG(buf, objp->uid); + IXDR_PUT_U_LONG(buf, objp->gid); + IXDR_PUT_U_LONG(buf, objp->size); + } + if (!xdr_nfstime (xdrs, &objp->atime)) + return FALSE; + if (!xdr_nfstime (xdrs, &objp->mtime)) + return FALSE; + return TRUE; + } else if (xdrs->x_op == XDR_DECODE) { + buf = XDR_INLINE (xdrs, 4 * BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_u_int (xdrs, &objp->mode)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->uid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->gid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->size)) + return FALSE; - register long *buf=buf; + } else { + objp->mode = IXDR_GET_U_LONG(buf); + objp->uid = IXDR_GET_U_LONG(buf); + objp->gid = IXDR_GET_U_LONG(buf); + objp->size = IXDR_GET_U_LONG(buf); + } + if (!xdr_nfstime (xdrs, &objp->atime)) + return FALSE; + if (!xdr_nfstime (xdrs, &objp->mtime)) + return FALSE; + return TRUE; + } - if (!xdr_u_int(xdrs, &objp->seconds)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->useconds)) { - return (FALSE); - } - return (TRUE); + if (!xdr_u_int (xdrs, &objp->mode)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->uid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->gid)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->size)) + return FALSE; + if (!xdr_nfstime (xdrs, &objp->atime)) + return FALSE; + if (!xdr_nfstime (xdrs, &objp->mtime)) + return FALSE; + return TRUE; } bool_t -xdr_fattr(XDR *xdrs, fattr *objp) +xdr_filename (XDR *xdrs, filename *objp) { + register int32_t *buf; - register long *buf=buf; + if (!xdr_string (xdrs, objp, NFS_MAXNAMLEN)) + return FALSE; + return TRUE; +} +bool_t +xdr_nfspath (XDR *xdrs, nfspath *objp) +{ + register int32_t *buf; - if (xdrs->x_op == XDR_ENCODE) { - if (!xdr_ftype(xdrs, &objp->type)) { - return (FALSE); - } - buf = XDR_INLINE(xdrs,10 * BYTES_PER_XDR_UNIT); - if (buf == NULL) { - if (!xdr_u_int(xdrs, &objp->mode)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->nlink)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->uid)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->gid)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->size)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->blocksize)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->rdev)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->blocks)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->fsid)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->fileid)) { - return (FALSE); - } + if (!xdr_string (xdrs, objp, NFS_MAXPATHLEN)) + return FALSE; + return TRUE; +} - } - else { - IXDR_PUT_U_LONG(buf,objp->mode); - IXDR_PUT_U_LONG(buf,objp->nlink); - IXDR_PUT_U_LONG(buf,objp->uid); - IXDR_PUT_U_LONG(buf,objp->gid); - IXDR_PUT_U_LONG(buf,objp->size); - IXDR_PUT_U_LONG(buf,objp->blocksize); - IXDR_PUT_U_LONG(buf,objp->rdev); - IXDR_PUT_U_LONG(buf,objp->blocks); - IXDR_PUT_U_LONG(buf,objp->fsid); - IXDR_PUT_U_LONG(buf,objp->fileid); - } - if (!xdr_nfstime(xdrs, &objp->atime)) { - return (FALSE); - } - if (!xdr_nfstime(xdrs, &objp->mtime)) { - return (FALSE); - } - if (!xdr_nfstime(xdrs, &objp->ctime)) { - return (FALSE); - } +bool_t +xdr_host (XDR *xdrs, host *objp) +{ + register int32_t *buf; - return (TRUE); - } else if (xdrs->x_op == XDR_DECODE) { - if (!xdr_ftype(xdrs, &objp->type)) { - return (FALSE); - } - buf = XDR_INLINE(xdrs,10 * BYTES_PER_XDR_UNIT); - if (buf == NULL) { - if (!xdr_u_int(xdrs, &objp->mode)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->nlink)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->uid)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->gid)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->size)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->blocksize)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->rdev)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->blocks)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->fsid)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->fileid)) { - return (FALSE); - } - - } - else { - objp->mode = IXDR_GET_U_LONG(buf); - objp->nlink = IXDR_GET_U_LONG(buf); - objp->uid = IXDR_GET_U_LONG(buf); - objp->gid = IXDR_GET_U_LONG(buf); - objp->size = IXDR_GET_U_LONG(buf); - objp->blocksize = IXDR_GET_U_LONG(buf); - objp->rdev = IXDR_GET_U_LONG(buf); - objp->blocks = IXDR_GET_U_LONG(buf); - objp->fsid = IXDR_GET_U_LONG(buf); - objp->fileid = IXDR_GET_U_LONG(buf); - } - if (!xdr_nfstime(xdrs, &objp->atime)) { - return (FALSE); - } - if (!xdr_nfstime(xdrs, &objp->mtime)) { - return (FALSE); - } - if (!xdr_nfstime(xdrs, &objp->ctime)) { - return (FALSE); - } - return(TRUE); - } - - if (!xdr_ftype(xdrs, &objp->type)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->mode)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->nlink)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->uid)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->gid)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->size)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->blocksize)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->rdev)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->blocks)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->fsid)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->fileid)) { - return (FALSE); - } - if (!xdr_nfstime(xdrs, &objp->atime)) { - return (FALSE); - } - if (!xdr_nfstime(xdrs, &objp->mtime)) { - return (FALSE); - } - if (!xdr_nfstime(xdrs, &objp->ctime)) { - return (FALSE); - } - return (TRUE); -} - -bool_t -xdr_sattr(XDR *xdrs, sattr *objp) -{ - - register long *buf=buf; - - - if (xdrs->x_op == XDR_ENCODE) { - buf = XDR_INLINE(xdrs,4 * BYTES_PER_XDR_UNIT); - if (buf == NULL) { - if (!xdr_u_int(xdrs, &objp->mode)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->uid)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->gid)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->size)) { - return (FALSE); - } - - } - else { - IXDR_PUT_U_LONG(buf,objp->mode); - IXDR_PUT_U_LONG(buf,objp->uid); - IXDR_PUT_U_LONG(buf,objp->gid); - IXDR_PUT_U_LONG(buf,objp->size); - } - if (!xdr_nfstime(xdrs, &objp->atime)) { - return (FALSE); - } - if (!xdr_nfstime(xdrs, &objp->mtime)) { - return (FALSE); - } + if (!xdr_string (xdrs, objp, NFS_MAXHOSTLEN)) + return FALSE; + return TRUE; +} - return (TRUE); - } else if (xdrs->x_op == XDR_DECODE) { - buf = XDR_INLINE(xdrs,4 * BYTES_PER_XDR_UNIT); - if (buf == NULL) { - if (!xdr_u_int(xdrs, &objp->mode)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->uid)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->gid)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->size)) { - return (FALSE); - } - - } - else { - objp->mode = IXDR_GET_U_LONG(buf); - objp->uid = IXDR_GET_U_LONG(buf); - objp->gid = IXDR_GET_U_LONG(buf); - objp->size = IXDR_GET_U_LONG(buf); - } - if (!xdr_nfstime(xdrs, &objp->atime)) { - return (FALSE); - } - if (!xdr_nfstime(xdrs, &objp->mtime)) { - return (FALSE); - } - return(TRUE); - } - - if (!xdr_u_int(xdrs, &objp->mode)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->uid)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->gid)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->size)) { - return (FALSE); - } - if (!xdr_nfstime(xdrs, &objp->atime)) { - return (FALSE); - } - if (!xdr_nfstime(xdrs, &objp->mtime)) { - return (FALSE); - } - return (TRUE); -} - -bool_t -xdr_filename(XDR *xdrs, filename *objp) -{ - - register long *buf=buf; - - if (!xdr_string(xdrs, objp, NFS_MAXNAMLEN)) { - return (FALSE); - } - return (TRUE); -} - -bool_t -xdr_nfspath(XDR *xdrs, nfspath *objp) -{ - - register long *buf=buf; - - if (!xdr_string(xdrs, objp, NFS_MAXPATHLEN)) { - return (FALSE); - } - return (TRUE); -} - -bool_t -xdr_attrstat(XDR *xdrs, attrstat *objp) -{ - - register long *buf=buf; - - if (!xdr_nfsstat(xdrs, &objp->status)) { - return (FALSE); - } +bool_t +xdr_attrstat (XDR *xdrs, attrstat *objp) +{ + register int32_t *buf; + + if (!xdr_nfsstat (xdrs, &objp->status)) + return FALSE; switch (objp->status) { case NFS_OK: - if (!xdr_fattr(xdrs, &objp->attrstat_u.attributes)) { - return (FALSE); - } + if (!xdr_fattr (xdrs, &objp->attrstat_u.attributes)) + return FALSE; break; default: break; } - return (TRUE); + return TRUE; } bool_t -xdr_sattrargs(XDR *xdrs, sattrargs *objp) +xdr_sattrargs (XDR *xdrs, sattrargs *objp) { + register int32_t *buf; - register long *buf=buf; - - if (!xdr_nfs_fh(xdrs, &objp->file)) { - return (FALSE); - } - if (!xdr_sattr(xdrs, &objp->attributes)) { - return (FALSE); - } - return (TRUE); + if (!xdr_nfs_fh (xdrs, &objp->file)) + return FALSE; + if (!xdr_sattr (xdrs, &objp->attributes)) + return FALSE; + return TRUE; } bool_t -xdr_diropargs(XDR *xdrs, diropargs *objp) +xdr_diropargs (XDR *xdrs, diropargs *objp) { + register int32_t *buf; - register long *buf=buf; - - if (!xdr_nfs_fh(xdrs, &objp->dir)) { - return (FALSE); - } - if (!xdr_filename(xdrs, &objp->name)) { - return (FALSE); - } - return (TRUE); + if (!xdr_nfs_fh (xdrs, &objp->dir)) + return FALSE; + if (!xdr_filename (xdrs, &objp->name)) + return FALSE; + return TRUE; } bool_t -xdr_diropokres(XDR *xdrs, diropokres *objp) +xdr_diropokres (XDR *xdrs, diropokres *objp) { + register int32_t *buf; - register long *buf=buf; - - if (!xdr_nfs_fh(xdrs, &objp->file)) { - return (FALSE); - } - if (!xdr_fattr(xdrs, &objp->attributes)) { - return (FALSE); - } - return (TRUE); + if (!xdr_nfs_fh (xdrs, &objp->file)) + return FALSE; + if (!xdr_fattr (xdrs, &objp->attributes)) + return FALSE; + return TRUE; } bool_t -xdr_diropres(XDR *xdrs, diropres *objp) +xdr_diropres (XDR *xdrs, diropres *objp) { + register int32_t *buf; - register long *buf=buf; - - if (!xdr_nfsstat(xdrs, &objp->status)) { - return (FALSE); - } + if (!xdr_nfsstat (xdrs, &objp->status)) + return FALSE; switch (objp->status) { case NFS_OK: - if (!xdr_diropokres(xdrs, &objp->diropres_u.diropres)) { - return (FALSE); - } + if (!xdr_diropokres (xdrs, &objp->diropres_u.diropres)) + return FALSE; break; default: break; } - return (TRUE); + return TRUE; } bool_t -xdr_readlinkres(XDR *xdrs, readlinkres *objp) +xdr_readlinkres (XDR *xdrs, readlinkres *objp) { + register int32_t *buf; - register long *buf=buf; - - if (!xdr_nfsstat(xdrs, &objp->status)) { - return (FALSE); - } + if (!xdr_nfsstat (xdrs, &objp->status)) + return FALSE; switch (objp->status) { case NFS_OK: - if (!xdr_nfspath(xdrs, &objp->readlinkres_u.data)) { - return (FALSE); - } + if (!xdr_nfspath (xdrs, &objp->readlinkres_u.data)) + return FALSE; break; default: break; } - return (TRUE); + return TRUE; } bool_t -xdr_readargs(XDR *xdrs, readargs *objp) +xdr_readargs (XDR *xdrs, readargs *objp) { + register int32_t *buf; - register long *buf=buf; - - if (!xdr_nfs_fh(xdrs, &objp->file)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->offset)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->count)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->totalcount)) { - return (FALSE); - } - return (TRUE); + if (!xdr_nfs_fh (xdrs, &objp->file)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->offset)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->count)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->totalcount)) + return FALSE; + return TRUE; } bool_t -xdr_readokres(XDR *xdrs, readokres *objp) +xdr_copyargs (XDR *xdrs, copyargs *objp) { + register int32_t *buf; + - register long *buf=buf; + if (xdrs->x_op == XDR_ENCODE) { + if (!xdr_nfs_fh (xdrs, &objp->filedest)) + return FALSE; + if (!xdr_nfs_fh (xdrs, &objp->filesrc)) + return FALSE; + buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_u_int (xdrs, &objp->offsetdest)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->offsetsrc)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->count)) + return FALSE; - if (!xdr_fattr(xdrs, &objp->attributes)) { - return (FALSE); - } - if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (u_int *)&objp->data.data_len, NFS_MAXDATA)) { - return (FALSE); - } - return (TRUE); + } else { + IXDR_PUT_U_LONG(buf, objp->offsetdest); + IXDR_PUT_U_LONG(buf, objp->offsetsrc); + IXDR_PUT_U_LONG(buf, objp->count); + } + if (!xdr_host (xdrs, &objp->hostname)) + return FALSE; + return TRUE; + } else if (xdrs->x_op == XDR_DECODE) { + if (!xdr_nfs_fh (xdrs, &objp->filedest)) + return FALSE; + if (!xdr_nfs_fh (xdrs, &objp->filesrc)) + return FALSE; + buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT); + if (buf == NULL) { + if (!xdr_u_int (xdrs, &objp->offsetdest)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->offsetsrc)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->count)) + return FALSE; + + } else { + objp->offsetdest = IXDR_GET_U_LONG(buf); + objp->offsetsrc = IXDR_GET_U_LONG(buf); + objp->count = IXDR_GET_U_LONG(buf); + } + if (!xdr_host (xdrs, &objp->hostname)) + return FALSE; + return TRUE; + } + + if (!xdr_nfs_fh (xdrs, &objp->filedest)) + return FALSE; + if (!xdr_nfs_fh (xdrs, &objp->filesrc)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->offsetdest)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->offsetsrc)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->count)) + return FALSE; + if (!xdr_host (xdrs, &objp->hostname)) + return FALSE; + return TRUE; } bool_t -xdr_readres(XDR *xdrs, readres *objp) +xdr_readokres (XDR *xdrs, readokres *objp) { + register int32_t *buf; - register long *buf=buf; + if (!xdr_fattr (xdrs, &objp->attributes)) + return FALSE; + if (!xdr_bytes (xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, NFS_MAXDATA)) + return FALSE; + return TRUE; +} - if (!xdr_nfsstat(xdrs, &objp->status)) { - return (FALSE); - } +bool_t +xdr_readres (XDR *xdrs, readres *objp) +{ + register int32_t *buf; + + if (!xdr_nfsstat (xdrs, &objp->status)) + return FALSE; switch (objp->status) { case NFS_OK: - if (!xdr_readokres(xdrs, &objp->readres_u.reply)) { - return (FALSE); - } + if (!xdr_readokres (xdrs, &objp->readres_u.reply)) + return FALSE; break; default: break; } - return (TRUE); + return TRUE; } bool_t -xdr_writeargs(XDR *xdrs, writeargs *objp) +xdr_copyokres (XDR *xdrs, copyokres *objp) { + register int32_t *buf; - register long *buf = buf; + if (!xdr_fattr (xdrs, &objp->attributesdest)) + return FALSE; + if (!xdr_fattr (xdrs, &objp->attributessrc)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->count)) + return FALSE; + if (!xdr_bytes (xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, NFS_MAXDATA)) + return FALSE; + return TRUE; +} + +bool_t +xdr_copyres (XDR *xdrs, copyres *objp) +{ + register int32_t *buf; + + if (!xdr_nfsstat (xdrs, &objp->status)) + return FALSE; + switch (objp->status) { + case NFS_OK: + if (!xdr_copyokres (xdrs, &objp->copyres_u.reply)) + return FALSE; + break; + default: + break; + } + return TRUE; +} + +bool_t +xdr_writeargs (XDR *xdrs, writeargs *objp) +{ + register int32_t *buf; if (xdrs->x_op == XDR_ENCODE) { - if (!xdr_nfs_fh(xdrs, &objp->file)) { - return (FALSE); - } - buf = XDR_INLINE(xdrs, 3 * BYTES_PER_XDR_UNIT); + if (!xdr_nfs_fh (xdrs, &objp->file)) + return FALSE; + buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT); if (buf == NULL) { - if (!xdr_u_int(xdrs, &objp->beginoffset)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->offset)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->totalcount)) { - return (FALSE); - } + if (!xdr_u_int (xdrs, &objp->beginoffset)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->offset)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->totalcount)) + return FALSE; + } else { - IXDR_PUT_U_LONG(buf, objp->beginoffset); - IXDR_PUT_U_LONG(buf, objp->offset); - IXDR_PUT_U_LONG(buf, objp->totalcount); - } - if (!xdr_bytes(xdrs, (char **) &objp->data.data_val, (u_int *) & objp->data.data_len, NFS_MAXDATA)) { - return (FALSE); + IXDR_PUT_U_LONG(buf, objp->beginoffset); + IXDR_PUT_U_LONG(buf, objp->offset); + IXDR_PUT_U_LONG(buf, objp->totalcount); } - return (TRUE); + if (!xdr_bytes (xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, NFS_MAXDATA)) + return FALSE; + return TRUE; } else if (xdrs->x_op == XDR_DECODE) { - if (!xdr_nfs_fh(xdrs, &objp->file)) { - return (FALSE); - } - buf = XDR_INLINE(xdrs, 3 * BYTES_PER_XDR_UNIT); + if (!xdr_nfs_fh (xdrs, &objp->file)) + return FALSE; + buf = XDR_INLINE (xdrs, 3 * BYTES_PER_XDR_UNIT); if (buf == NULL) { - if (!xdr_u_int(xdrs, &objp->beginoffset)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->offset)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->totalcount)) { - return (FALSE); - } + if (!xdr_u_int (xdrs, &objp->beginoffset)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->offset)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->totalcount)) + return FALSE; + } else { - objp->beginoffset = IXDR_GET_U_LONG(buf); - objp->offset = IXDR_GET_U_LONG(buf); - objp->totalcount = IXDR_GET_U_LONG(buf); - } - if (!xdr_bytes(xdrs, (char **) &objp->data.data_val, (u_int *) & objp->data.data_len, NFS_MAXDATA)) { - return (FALSE); + objp->beginoffset = IXDR_GET_U_LONG(buf); + objp->offset = IXDR_GET_U_LONG(buf); + objp->totalcount = IXDR_GET_U_LONG(buf); } - return (TRUE); - } - if (!xdr_nfs_fh(xdrs, &objp->file)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->beginoffset)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->offset)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->totalcount)) { - return (FALSE); - } - if (!xdr_bytes(xdrs, (char **) &objp->data.data_val, (u_int *) & objp->data.data_len, NFS_MAXDATA)) { - return (FALSE); + if (!xdr_bytes (xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, NFS_MAXDATA)) + return FALSE; + return TRUE; } - return (TRUE); + + if (!xdr_nfs_fh (xdrs, &objp->file)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->beginoffset)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->offset)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->totalcount)) + return FALSE; + if (!xdr_bytes (xdrs, (char **)&objp->data.data_val, (u_int *) &objp->data.data_len, NFS_MAXDATA)) + return FALSE; + return TRUE; } bool_t -xdr_createargs(XDR *xdrs, createargs *objp) +xdr_createargs (XDR *xdrs, createargs *objp) { + register int32_t *buf; - register long *buf=buf; - - if (!xdr_diropargs(xdrs, &objp->where)) { - return (FALSE); - } - if (!xdr_sattr(xdrs, &objp->attributes)) { - return (FALSE); - } - return (TRUE); + if (!xdr_diropargs (xdrs, &objp->where)) + return FALSE; + if (!xdr_sattr (xdrs, &objp->attributes)) + return FALSE; + return TRUE; } bool_t -xdr_renameargs(XDR *xdrs, renameargs *objp) +xdr_renameargs (XDR *xdrs, renameargs *objp) { + register int32_t *buf; - register long *buf=buf; - - if (!xdr_diropargs(xdrs, &objp->from)) { - return (FALSE); - } - if (!xdr_diropargs(xdrs, &objp->to)) { - return (FALSE); - } - return (TRUE); + if (!xdr_diropargs (xdrs, &objp->from)) + return FALSE; + if (!xdr_diropargs (xdrs, &objp->to)) + return FALSE; + return TRUE; } bool_t -xdr_linkargs(XDR *xdrs, linkargs *objp) +xdr_linkargs (XDR *xdrs, linkargs *objp) { + register int32_t *buf; - register long *buf=buf; - - if (!xdr_nfs_fh(xdrs, &objp->from)) { - return (FALSE); - } - if (!xdr_diropargs(xdrs, &objp->to)) { - return (FALSE); - } - return (TRUE); + if (!xdr_nfs_fh (xdrs, &objp->from)) + return FALSE; + if (!xdr_diropargs (xdrs, &objp->to)) + return FALSE; + return TRUE; } bool_t -xdr_symlinkargs(XDR *xdrs, symlinkargs *objp) +xdr_symlinkargs (XDR *xdrs, symlinkargs *objp) { + register int32_t *buf; - register long *buf=buf; - - if (!xdr_diropargs(xdrs, &objp->from)) { - return (FALSE); - } - if (!xdr_nfspath(xdrs, &objp->to)) { - return (FALSE); - } - if (!xdr_sattr(xdrs, &objp->attributes)) { - return (FALSE); - } - return (TRUE); + if (!xdr_diropargs (xdrs, &objp->from)) + return FALSE; + if (!xdr_nfspath (xdrs, &objp->to)) + return FALSE; + if (!xdr_sattr (xdrs, &objp->attributes)) + return FALSE; + return TRUE; } bool_t -xdr_nfscookie(XDR *xdrs, nfscookie objp) +xdr_nfscookie (XDR *xdrs, nfscookie objp) { + register int32_t *buf; - register long *buf=buf; - - if (!xdr_opaque(xdrs, objp, NFS_COOKIESIZE)) { - return (FALSE); - } - return (TRUE); + if (!xdr_opaque (xdrs, objp, NFS_COOKIESIZE)) + return FALSE; + return TRUE; } bool_t -xdr_readdirargs(XDR *xdrs, readdirargs *objp) +xdr_readdirargs (XDR *xdrs, readdirargs *objp) { + register int32_t *buf; - register long *buf=buf; - - if (!xdr_nfs_fh(xdrs, &objp->dir)) { - return (FALSE); - } - if (!xdr_nfscookie(xdrs, objp->cookie)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->count)) { - return (FALSE); - } - return (TRUE); + if (!xdr_nfs_fh (xdrs, &objp->dir)) + return FALSE; + if (!xdr_nfscookie (xdrs, objp->cookie)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->count)) + return FALSE; + return TRUE; } bool_t -xdr_entry(XDR *xdrs, entry *objp) +xdr_entry (XDR *xdrs, entry *objp) { + register int32_t *buf; - register long *buf=buf; - - if (!xdr_u_int(xdrs, &objp->fileid)) { - return (FALSE); - } - if (!xdr_filename(xdrs, &objp->name)) { - return (FALSE); - } - if (!xdr_nfscookie(xdrs, objp->cookie)) { - return (FALSE); - } - if (!xdr_pointer(xdrs, (char **)&objp->nextentry, sizeof(entry), (xdrproc_t)xdr_entry)) { - return (FALSE); - } - return (TRUE); + if (!xdr_u_int (xdrs, &objp->fileid)) + return FALSE; + if (!xdr_filename (xdrs, &objp->name)) + return FALSE; + if (!xdr_nfscookie (xdrs, objp->cookie)) + return FALSE; + if (!xdr_pointer (xdrs, (char **)&objp->nextentry, sizeof (entry), (xdrproc_t) xdr_entry)) + return FALSE; + return TRUE; } bool_t -xdr_dirlist(XDR *xdrs, dirlist *objp) +xdr_dirlist (XDR *xdrs, dirlist *objp) { + register int32_t *buf; - register long *buf=buf; - - if (!xdr_pointer(xdrs, (char **)&objp->entries, sizeof(entry), (xdrproc_t)xdr_entry)) { - return (FALSE); - } - if (!xdr_bool(xdrs, &objp->eof)) { - return (FALSE); - } - return (TRUE); + if (!xdr_pointer (xdrs, (char **)&objp->entries, sizeof (entry), (xdrproc_t) xdr_entry)) + return FALSE; + if (!xdr_bool (xdrs, &objp->eof)) + return FALSE; + return TRUE; } bool_t -xdr_readdirres(XDR *xdrs, readdirres *objp) +xdr_readdirres (XDR *xdrs, readdirres *objp) { + register int32_t *buf; - register long *buf=buf; - - if (!xdr_nfsstat(xdrs, &objp->status)) { - return (FALSE); - } + if (!xdr_nfsstat (xdrs, &objp->status)) + return FALSE; switch (objp->status) { case NFS_OK: - if (!xdr_dirlist(xdrs, &objp->readdirres_u.reply)) { - return (FALSE); - } + if (!xdr_dirlist (xdrs, &objp->readdirres_u.reply)) + return FALSE; break; default: break; } - return (TRUE); + return TRUE; } bool_t -xdr_statfsokres(XDR *xdrs, statfsokres *objp) +xdr_statfsokres (XDR *xdrs, statfsokres *objp) { - - register long *buf=buf; + register int32_t *buf; - if (xdrs->x_op == XDR_ENCODE) { + if (xdrs->x_op == XDR_ENCODE) { buf = XDR_INLINE(xdrs,5 * BYTES_PER_XDR_UNIT); if (buf == NULL) { - if (!xdr_u_int(xdrs, &objp->tsize)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->bsize)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->blocks)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->bfree)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->bavail)) { - return (FALSE); - } - - } - else { - IXDR_PUT_U_LONG(buf,objp->tsize); - IXDR_PUT_U_LONG(buf,objp->bsize); - IXDR_PUT_U_LONG(buf,objp->blocks); - IXDR_PUT_U_LONG(buf,objp->bfree); - IXDR_PUT_U_LONG(buf,objp->bavail); - } - - return (TRUE); + if (!xdr_u_int (xdrs, &objp->tsize)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->bsize)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->blocks)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->bfree)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->bavail)) + return FALSE; + } else { + IXDR_PUT_U_LONG(buf, objp->tsize); + IXDR_PUT_U_LONG(buf, objp->bsize); + IXDR_PUT_U_LONG(buf, objp->blocks); + IXDR_PUT_U_LONG(buf, objp->bfree); + IXDR_PUT_U_LONG(buf, objp->bavail); + } + return TRUE; } else if (xdrs->x_op == XDR_DECODE) { buf = XDR_INLINE(xdrs,5 * BYTES_PER_XDR_UNIT); if (buf == NULL) { - if (!xdr_u_int(xdrs, &objp->tsize)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->bsize)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->blocks)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->bfree)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->bavail)) { - return (FALSE); - } - - } - else { - objp->tsize = IXDR_GET_U_LONG(buf); - objp->bsize = IXDR_GET_U_LONG(buf); - objp->blocks = IXDR_GET_U_LONG(buf); - objp->bfree = IXDR_GET_U_LONG(buf); - objp->bavail = IXDR_GET_U_LONG(buf); - } - return(TRUE); - } - - if (!xdr_u_int(xdrs, &objp->tsize)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->bsize)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->blocks)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->bfree)) { - return (FALSE); - } - if (!xdr_u_int(xdrs, &objp->bavail)) { - return (FALSE); - } - return (TRUE); + if (!xdr_u_int (xdrs, &objp->tsize)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->bsize)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->blocks)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->bfree)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->bavail)) + return FALSE; + } else { + objp->tsize = IXDR_GET_U_LONG(buf); + objp->bsize = IXDR_GET_U_LONG(buf); + objp->blocks = IXDR_GET_U_LONG(buf); + objp->bfree = IXDR_GET_U_LONG(buf); + objp->bavail = IXDR_GET_U_LONG(buf); + } + return TRUE; + } + + if (!xdr_u_int (xdrs, &objp->tsize)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->bsize)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->blocks)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->bfree)) + return FALSE; + if (!xdr_u_int (xdrs, &objp->bavail)) + return FALSE; + return TRUE; } bool_t -xdr_statfsres(XDR *xdrs, statfsres *objp) -{ - - register long *buf=buf; - - if (!xdr_nfsstat(xdrs, &objp->status)) { - return (FALSE); - } +xdr_statfsres (XDR *xdrs, statfsres *objp) +{ + register int32_t *buf; + + if (!xdr_nfsstat (xdrs, &objp->status)) + return FALSE; switch (objp->status) { case NFS_OK: - if (!xdr_statfsokres(xdrs, &objp->statfsres_u.reply)) { - return (FALSE); - } + if (!xdr_statfsokres (xdrs, &objp->statfsres_u.reply)) + return FALSE; break; default: break; } - return (TRUE); + return TRUE; } diff -Nur nfs-server-2.2beta48/nfsd.c cp-new/nfsd.c --- nfs-server-2.2beta48/nfsd.c Tue Nov 9 15:42:44 1999 +++ cp-new/nfsd.c Tue Feb 29 19:28:09 2000 @@ -16,6 +16,15 @@ * as is, with no warranty expressed or implied. */ +/* + * Thu Feb 24 11:26:16 CST 2000 {paurea,nemo}@gsyc.escet.urjc.es + * Added support for copy + */ + + +#include "nfs_prot.h" /*now when we call copy we are clients as well servers*/ + + #include "nfsd.h" #include #include "getopt.h" @@ -38,8 +47,8 @@ #define CHK_NOACCESS 2 /* Make larger reads possible. Without crashing the machine :-) */ -#undef NFS_MAXDATA -#define NFS_MAXDATA (16 * 1024) +#undef NFS_MAXDATA /* BUG */ +#define NFS_MAXDATA (8 * 1024) static char iobuf[NFS_MAXDATA]; static char pathbuf[NFS_MAXPATHLEN + NFS_MAXNAMLEN + 1]; @@ -69,7 +78,7 @@ { "no-spoof-trace", 0, 0, 't' }, { "version", 0, 0, 'v' }, { "no-cross-mounts", 0, 0, 'x' }, - { "fail-safe", optional_argument, 0, 'z' }, + { "fail-safe", optional_argument, 0, 'z' }, { "no-tcp", 0, 0, OPT_NOTCP }, { "udp-only", 0, 0, OPT_NOTCP }, { "loopback-only", 0, 0, OPT_LOOPBACK }, @@ -97,7 +106,7 @@ static nfsstat build_path(struct svc_req *rqstp, char *buf, diropargs *dopa, int flags); -static fhcache *auth_fh(struct svc_req *rqstp, nfs_fh *fh, +static fhcache *auth_fh(struct svc_req *rqstp, nfs_fh *fh, nfsstat *statp, int flags); static void usage(FILE *, int); static void terminate(void); @@ -468,8 +477,164 @@ return (fhc_getattr(fhc, &(res->attributes), NULL, rqstp)); } -int -nfsd_nfsproc_writecache_2(void *argp, struct svc_req *rqstp) + +static int +getfd(nfs_fh *fhp, struct svc_req *rqstp, u_int off, nfsstat *status, + int m, fhcache **fhc) +{ + int fd; + int mode= ((m==O_WRONLY)? CHK_WRITE : CHK_READ) | CHK_NOACCESS; + char *which = (m==O_WRONLY) ? "dst" : "src"; + + if (!(*fhc= auth_fh(rqstp, fhp, status, mode))){ + Dprintf(L_ERROR,"null %s fh",which); + return -1; + } + if ((fd = fh_fd(*fhc, status, m)) < 0) { + Dprintf(L_ERROR,"null %s fd",which); + return -1; + } + errno=0; + efs_lseek(fd, (long)off, L_SET); + if (errno){ + Dprintf(L_ERROR,"seek failed for %s (errno %d)",which,errno); + *status=nfs_errno(); + return -1; + } + return fd; +} + +/* + * max # of read+writes to issue. + * 1 would be the traditional NFS value. + * However, latency can be much better if a whole file copy be + * copied within a single request. + */ +#define MAX_WORK 8 + + +int nfsd_nfsproc_copy_2(copyargs *argp, struct svc_req *rqstp) +{ + int sfd=-1,dfd=-1; + nfsstat status=NFS_OK; + int limit; + int islcl; + fhcache *sfhc,*dfhc; + static char lclhost[NFS_MAXHOSTLEN+1]; + static int lclknown=0; + u_int nleft; + struct writeargs warg; + char *host=argp->hostname; + CLIENT *cp=NULL; + + copyokres *res = &result.copyres.copyres_u.reply; + + if (!lclknown){ + if (gethostname(lclhost,NFS_MAXHOSTLEN)) { + Dprintf(L_ERROR,"gethostname failed"); + return -1; + } + lclknown=1; + } + + islcl=(!strcmp(host,"localhost") || !strcmp(host,lclhost)); + if (islcl) + Dprintf(D_CALL,"copy to %s (local)",host); + else + Dprintf(D_CALL,"copy to %s (remote)",host); + + sfd=getfd(&argp->filesrc,rqstp,argp->offsetsrc,&status,O_RDONLY,&sfhc); + if (islcl) + dfd=getfd(&argp->filedest,rqstp,argp->offsetdest,&status,O_WRONLY, + &dfhc); + else { + warg.file= argp->filedest; + warg.offset=argp->offsetdest; + warg.beginoffset=argp->offsetdest; + warg.data.data_val=iobuf; + if(!(cp=clnt_create(host,NFS_PROGRAM,NFS_VERSION,"udp"))){ + Dprintf(L_ERROR,"unable to create client"); + clnt_pcreateerror(host); + status =-1; + goto failure; + } + + } + if (sfd<0 || (islcl && dfd<0)){ + Dprintf(L_ERROR,"unable to open either src or dst"); + goto failure; + } + + /* Ok, got descriptors and/or the client connection: do the job */ + + nleft=argp->count; + res->count=0; + if (argp->offsetsrc == 0 && log_transfers) + nfsd_xferlog(rqstp, "<", sfhc->path); + + for (limit=MAX_WORK ; limit>0 && nleft>0; limit--) { + u_int nbytes = nleft; + ssize_t rdres,wrres; + attrstat *rpcres; + + + errno=0; + if (nbytes > NFS_MAXDATA) + nbytes=NFS_MAXDATA; + rdres= read(sfd,iobuf,nbytes); + if (rdres <0) + Dprintf(L_ERROR,"read failed"); + else if (!rdres || errno){ + status = NFS_OK; + if (errno) + status=nfs_errno(); + break; + } else + res->count += rdres; + + if((status=fhc_getattr(sfhc, &res->attributessrc,NULL,rqstp))){ + Dprintf(L_ERROR,"src fh status is not ok"); + goto failure; + } + if (islcl) { + if ((wrres=write(dfd,iobuf,rdres))!=rdres) { + Dprintf(L_ERROR,"write failed (%d)",errno); + goto failure; + } + if((status=fhc_getattr(dfhc, + &res->attributesdest,NULL,rqstp))){ + Dprintf(L_ERROR,"dst fh status is not ok"); + goto failure; + } + } else { + warg.totalcount=warg.data.data_len=rdres; + if (!(rpcres=nfsproc_write_2(&warg,cp)) || + rpcres->status != NFS_OK){ + clnt_perror(cp, "write failed"); + goto failure; + } + memcpy(&res->attributesdest, + &rpcres->attrstat_u.attributes, + sizeof(res->attributesdest)); + warg.offset += rdres; + warg.beginoffset += rdres; + } + nleft -= rdres; + } + failure: + if (sfd>=0) + fd_inactive(sfd); + if (dfd>=0) + fd_inactive(dfd); + if (cp) + clnt_destroy(cp); + return status; +} + + +int nfsd_nfsproc_writecache_2(argp, rqstp) +void *argp; +struct svc_req *rqstp; { return (0); } @@ -630,7 +795,7 @@ CREATE_OMODE | O_TRUNC : CREATE_OMODE); if (!exists) flags |= O_CREAT; - tmpfd = path_open(pathbuf, flags, + tmpfd = path_open(pathbuf, flags, argp->attributes.mode & ~S_IFMT); if (tmpfd < 0) goto failure; @@ -722,7 +887,7 @@ } /* For now, we disallow hardlinks between different volumes for - * security reasons. If we tried harder, we might be able to + * security reasons. If we tried harder, we might be able to * support them, but I'm not sure if it's worth it... */ int @@ -1052,7 +1217,7 @@ if (optind == argc-1 && isdigit(argv[optind][0])) { ncopies = atoi(argv[optind++]); if (ncopies <= 0) { - fprintf(stderr, + fprintf(stderr, "nfsd: illegal number of servers requested: %s\n", argv[optind]); exit (1); diff -Nur nfs-server-2.2beta48/nfsd.h cp-new/nfsd.h --- nfs-server-2.2beta48/nfsd.h Fri Oct 30 11:23:22 1998 +++ cp-new/nfsd.h Thu Feb 24 11:26:03 2000 @@ -9,6 +9,9 @@ * This software maybe be used for any purpose provided * the above copyright notice is retained. It is supplied * as is, with no warranty expressed or implied. + * + * Thu Feb 24 11:25:31 CST 2000 {paurea,nemo}@gsyc.escet.urjc.es + * Added support for copy. */ #include "system.h" @@ -33,9 +36,11 @@ diropargs nfsproc_rmdir_2_arg; readdirargs nfsproc_readdir_2_arg; nfs_fh nfsproc_statfs_2_arg; + copyargs nfsproc_copy_2_arg; }; union result_types { + copyres copyres; attrstat attrstat; diropres diropres; readlinkres readlinkres; @@ -96,6 +101,8 @@ extern int nfsd_nfsproc_lookup_2(diropargs *, struct svc_req *); extern int nfsd_nfsproc_readlink_2(nfs_fh *, struct svc_req *); extern int nfsd_nfsproc_read_2(readargs *, struct svc_req *); +extern int nfsd_nfsproc_copy_2(copyargs *,struct svc_req *); + extern int nfsd_nfsproc_writecache_2(void *, struct svc_req *); extern int nfsd_nfsproc_write_2(writeargs *, struct svc_req *); extern int nfsd_nfsproc_create_2(createargs *, struct svc_req *);