* directory or online at http://www.openafs.org/dl/license10.html
*/
-#include "../afs/param.h" /* Should be always first */
-#include "../afs/sysincludes.h" /* Standard vendor system headers */
-#include "../afs/afsincludes.h" /* Afs-based standard headers */
-#include "../afs/afs_stats.h" /* afs statistics */
-#include "../afs/vice.h"
-#include "../rx/rx_globals.h"
-
-extern void afs_ComputePAGStats();
-extern struct vcache *afs_LookupVCache();
+#include <afsconfig.h>
+#include "afs/param.h"
+
+RCSID("$Header$");
+
+#include "afs/sysincludes.h" /* Standard vendor system headers */
+#ifdef AFS_OBSD_ENV
+#include "h/syscallargs.h"
+#endif
+#include "afsincludes.h" /* Afs-based standard headers */
+#include "afs/afs_stats.h" /* afs statistics */
+#include "afs/vice.h"
+#include "rx/rx_globals.h"
+
struct VenusFid afs_rootFid;
afs_int32 afs_waitForever=0;
short afs_waitForeverCount = 0;
afs_int32 afs_showflags = GAGUSER | GAGCONSOLE; /* show all messages */
-extern afs_int32 PROBE_INTERVAL;
-
-extern int cacheDiskType;
-extern afs_int32 afs_cacheBlocks;
-extern struct afs_q CellLRU;
-extern char *afs_indexFlags; /* only one: is there data there? */
-extern afs_int32 afs_blocksUsed;
-extern struct unixuser *afs_users[NUSERS];
-extern struct server *afs_servers[NSERVERS];
-extern struct interfaceAddr afs_cb_interface; /* client interface addresses */
-extern afs_rwlock_t afs_xserver;
-extern afs_rwlock_t afs_xinterface;
-extern afs_rwlock_t afs_xcell;
-extern afs_rwlock_t afs_xuser;
-#ifndef AFS_FINEG_SUNLOCK
-extern afs_rwlock_t afs_xconn;
-#endif
-extern afs_rwlock_t afs_xvolume;
-extern afs_lock_t afs_xdcache; /* lock: alloc new disk cache entries */
-extern afs_rwlock_t afs_xvcache;
-extern afs_rwlock_t afs_xcbhash;
-extern afs_int32 afs_mariner, afs_marinerHost;
-extern struct srvAddr *afs_srvAddrs[NSERVERS];
-extern int afs_resourceinit_flag;
-
-static int PBogus(), PSetAcl(), PGetAcl(), PSetTokens(), PGetVolumeStatus();
-static int PSetVolumeStatus(), PFlush(), PNewStatMount(), PGetTokens(), PUnlog();
-static int PCheckServers(), PCheckVolNames(), PCheckAuth(), PFindVolume();
-static int PViceAccess(), PSetCacheSize(), Prefetch();
-static int PRemoveCallBack(), PNewCell(), PListCells(), PRemoveMount();
-static int PMariner(), PGetUserCell(), PGetWSCell(), PGetFileCell();
-static int PVenusLogging(), PNoop(), PSetCellStatus(), PGetCellStatus();
-static int PFlushVolumeData(), PGetCacheSize();
-static int PSetSysName(),PGetFID();
-static int PGetVnodeXStatus();
-static int PSetSPrefs(), PGetSPrefs(), PGag(), PTwiddleRx();
-static int PSetSPrefs33(), PStoreBehind(), PGCPAGs();
-static int PGetCPrefs(), PSetCPrefs(); /* client network addresses */
-static int PGetInitParams(), PFlushMount(), PRxStatProc(), PRxStatPeer();
-int PExportAfs();
-
-static int HandleClientContext(struct afs_ioctl *ablob, int *com, struct AFS_UCRED **acred, struct AFS_UCRED *credp);
-
-extern struct cm_initparams cm_initParams;
-
-static int (*(pioctlSw[]))() = {
+
+#define DECL_PIOCTL(x) static int x(struct vcache *avc, int afun, struct vrequest *areq, \
+ char *ain, char *aout, afs_int32 ainSize, afs_int32 *aoutSize, \
+ struct AFS_UCRED **acred)
+
+/* Prototypes for pioctl routines */
+DECL_PIOCTL(PGetFID);
+DECL_PIOCTL(PSetAcl);
+DECL_PIOCTL(PStoreBehind);
+DECL_PIOCTL(PGCPAGs);
+DECL_PIOCTL(PGetAcl);
+DECL_PIOCTL(PNoop);
+DECL_PIOCTL(PBogus);
+DECL_PIOCTL(PGetFileCell);
+DECL_PIOCTL(PGetWSCell);
+DECL_PIOCTL(PGetUserCell);
+DECL_PIOCTL(PSetTokens);
+DECL_PIOCTL(PGetVolumeStatus);
+DECL_PIOCTL(PSetVolumeStatus);
+DECL_PIOCTL(PFlush);
+DECL_PIOCTL(PNewStatMount);
+DECL_PIOCTL(PGetTokens);
+DECL_PIOCTL(PUnlog);
+DECL_PIOCTL(PMariner);
+DECL_PIOCTL(PCheckServers);
+DECL_PIOCTL(PCheckVolNames);
+DECL_PIOCTL(PCheckAuth);
+DECL_PIOCTL(PFindVolume);
+DECL_PIOCTL(PViceAccess);
+DECL_PIOCTL(PSetCacheSize);
+DECL_PIOCTL(PGetCacheSize);
+DECL_PIOCTL(PRemoveCallBack);
+DECL_PIOCTL(PNewCell);
+DECL_PIOCTL(PNewAlias);
+DECL_PIOCTL(PListCells);
+DECL_PIOCTL(PListAliases);
+DECL_PIOCTL(PRemoveMount);
+DECL_PIOCTL(PVenusLogging);
+DECL_PIOCTL(PGetCellStatus);
+DECL_PIOCTL(PSetCellStatus);
+DECL_PIOCTL(PFlushVolumeData);
+DECL_PIOCTL(PGetVnodeXStatus);
+DECL_PIOCTL(PSetSysName);
+DECL_PIOCTL(PSetSPrefs);
+DECL_PIOCTL(PSetSPrefs33);
+DECL_PIOCTL(PGetSPrefs);
+DECL_PIOCTL(PExportAfs);
+DECL_PIOCTL(PGag);
+DECL_PIOCTL(PTwiddleRx);
+DECL_PIOCTL(PGetInitParams);
+DECL_PIOCTL(PGetRxkcrypt);
+DECL_PIOCTL(PSetRxkcrypt);
+DECL_PIOCTL(PGetCPrefs);
+DECL_PIOCTL(PSetCPrefs);
+DECL_PIOCTL(PFlushMount);
+DECL_PIOCTL(PRxStatProc);
+DECL_PIOCTL(PRxStatPeer);
+DECL_PIOCTL(PPrefetchFromTape);
+DECL_PIOCTL(PResidencyCmd);
+
+/* Prototypes for private routines */
+static int HandleClientContext(struct afs_ioctl *ablob, int *com,
+ struct AFS_UCRED **acred, struct AFS_UCRED *credp);
+int HandleIoctl(register struct vcache *avc, register afs_int32 acom, struct afs_ioctl *adata);
+int afs_HandlePioctl(struct vcache *avc, afs_int32 acom,
+ register struct afs_ioctl *ablob, int afollow, struct AFS_UCRED **acred);
+static int Prefetch(char *apath, struct afs_ioctl *adata, int afollow, struct AFS_UCRED *acred);
+
+
+static int (*(VpioctlSw[]))() = {
PBogus, /* 0 */
PSetAcl, /* 1 */
PGetAcl, /* 2 */
PFlushMount, /* 52 - flush mount symlink data */
PRxStatProc, /* 53 - control process RX statistics */
PRxStatPeer, /* 54 - control peer RX statistics */
+ PGetRxkcrypt, /* 55 -- Get rxkad encryption flag */
+ PSetRxkcrypt, /* 56 -- Set rxkad encryption flag */
+ PBogus, /* 57 -- arla: set file prio */
+ PBogus, /* 58 -- arla: fallback getfh */
+ PBogus, /* 59 -- arla: fallback fhopen */
+ PBogus, /* 60 -- arla: controls xfsdebug */
+ PBogus, /* 61 -- arla: controls arla debug */
+ PBogus, /* 62 -- arla: debug interface */
+ PBogus, /* 63 -- arla: print xfs status */
+ PBogus, /* 64 -- arla: force cache check */
+ PBogus, /* 65 -- arla: break callback */
+ PPrefetchFromTape, /* 66 -- MR-AFS: prefetch file from tape */
+ PResidencyCmd, /* 67 -- MR-AFS: generic commnd interface */
+ PBogus, /* 68 -- arla: fetch stats */
+};
+
+static int (*(CpioctlSw[]))() = {
+ PBogus, /* 0 */
+ PNewAlias, /* 1 -- create new cell alias */
+ PListAliases, /* 2 -- list cell aliases */
};
#define PSetClientContext 99 /* Special pioctl to setup caller's creds */
}
#endif /* defined(AFS_SGI_ENV) && (_MIPS_SZLONG==64) */
+#if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV)
+ struct afs_ioctl32 dst32;
+
+#ifdef AFS_SPARC64_LINUX24_ENV
+ if (current->thread.flags & SPARC_FLAG_32BIT)
+#elif AFS_SPARC64_LINUX20_ENV
+ if (current->tss.flags & SPARC_FLAG_32BIT)
+#else
+#error Not done for this linux type
+#endif /* AFS_SPARC64_LINUX20_ENV */
+ {
+ AFS_COPYIN(cmarg, (caddr_t) &dst32, sizeof dst32, code);
+ if (!code)
+ afs_ioctl32_to_afs_ioctl(&dst32, dst);
+ return code;
+ }
+#endif /* defined(AFS_LINUX_64BIT_KERNEL) */
+
AFS_COPYIN(cmarg, (caddr_t) dst, sizeof *dst, code);
return code;
}
-HandleIoctl(avc, acom, adata)
- register struct vcache *avc;
- register afs_int32 acom;
- struct afs_ioctl *adata; {
+int HandleIoctl(register struct vcache *avc, register afs_int32 acom, struct afs_ioctl *adata)
+{
register afs_int32 code;
code = 0;
default:
code = EINVAL;
+#ifdef AFS_AIX51_ENV
+ code = ENOSYS;
+#endif
break;
}
return code; /* so far, none implemented */
* thing directly in the vnode layer call, VNOP_IOCTL; thus afs_ioctl
* is now called from afs_gn_ioctl.
*/
-afs_ioctl(tvc, cmd, arg)
- struct vcache *tvc;
- int cmd;
- int arg;
+int afs_ioctl(struct vcache *tvc, int cmd, int arg)
{
struct afs_ioctl data;
int error = 0;
#ifndef AFS_HPUX102_ENV
#if !defined(AFS_SGI_ENV)
#ifdef AFS_AIX32_ENV
+#ifdef AFS_AIX51_ENV
+kioctl(fdes, com, arg, ext, arg2, arg3)
+ caddr_t arg2, arg3;
+#else
kioctl(fdes, com, arg, ext)
+#endif
int fdes, com;
caddr_t arg, ext;
{
struct a {
int fd, com;
caddr_t arg, ext;
+#ifdef AFS_AIX51_ENV
+ caddr_t arg2, arg3;
+#endif
} u_uap, *uap = &u_uap;
#else
-#ifdef AFS_SUN5_ENV
+#if defined(AFS_SUN5_ENV)
struct afs_ioctl_sys {
int fd;
struct afs_ioctl_sys *uap;
rval_t *rvp;
{
-#else
-#ifdef AFS_OSF_ENV
+#elif defined(AFS_OSF_ENV)
afs_xioctl (p, args, retval)
struct proc *p;
void *args;
u_long com;
caddr_t arg;
} *uap = (struct a *)args;
-#else /* AFS_OSF_ENV */
-#ifdef AFS_LINUX22_ENV
+#elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+struct ioctl_args {
+ int fd;
+ u_long com;
+ caddr_t arg;
+};
+
+int
+afs_xioctl(p, uap, retval)
+ struct proc *p;
+ register struct ioctl_args *uap;
+ register_t *retval;
+{
+#elif defined(AFS_LINUX22_ENV)
struct afs_ioctl_sys {
unsigned int com;
unsigned long arg;
{
struct afs_ioctl_sys ua, *uap = &ua;
#else
-afs_xioctl ()
- {
- register struct a {
+int afs_xioctl (void)
+{
+ register struct a {
int fd;
int com;
caddr_t arg;
- } *uap = (struct a *)u.u_ap;
-#endif /* AFS_LINUX22_ENV */
-#endif /* AFS_OSF_ENV */
+ } *uap = (struct a *)u.u_ap;
#endif /* AFS_SUN5_ENV */
#endif
-#ifndef AFS_LINUX22_ENV
-#if defined(AFS_AIX32_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV)
- struct file *fd;
-#else
- register struct file *fd;
+#if defined(AFS_AIX32_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
+ struct file *fd;
+#elif !defined(AFS_LINUX22_ENV)
+ register struct file *fd;
#endif
+#if defined(AFS_XBSD_ENV)
+ register struct filedesc *fdp;
#endif
- register struct vcache *tvc;
- register int ioctlDone = 0, code = 0;
+ register struct vcache *tvc;
+ register int ioctlDone = 0, code = 0;
- AFS_STATCNT(afs_xioctl);
+ AFS_STATCNT(afs_xioctl);
+#if defined(AFS_XBSD_ENV)
+ fdp=p->p_fd;
+ if ((u_int)uap->fd >= fdp->fd_nfiles ||
+ (fd = fdp->fd_ofiles[uap->fd]) == NULL)
+ return EBADF;
+ if ((fd->f_flag & (FREAD | FWRITE)) == 0)
+ return EBADF;
+#else
+#if defined(AFS_DARWIN_ENV)
+ if ((code=fdgetf(p, uap->fd, &fd)))
+ return code;
+#else
#ifdef AFS_LINUX22_ENV
ua.com = com;
ua.arg = arg;
#else
#ifdef AFS_AIX32_ENV
- uap->fd = fdes;
- uap->com = com;
- uap->arg = arg;
- if (setuerror(getf(uap->fd, &fd))) {
+ uap->fd = fdes;
+ uap->com = com;
+ uap->arg = arg;
+#ifdef AFS_AIX51_ENV
+ uap->arg2 = arg2;
+ uap->arg3 = arg3;
+#endif
+
+ if (setuerror(getf(uap->fd, &fd))) {
return -1;
}
#else
#else /* AFS_OSF_ENV */
#ifdef AFS_SUN5_ENV
#if defined(AFS_SUN57_ENV)
- fd = getf(uap->fd);
- if (!fd) return(EBADF);
+ fd = getf(uap->fd);
+ if (!fd) return(EBADF);
#elif defined(AFS_SUN54_ENV)
- fd = GETF(uap->fd);
- if (!fd) return(EBADF);
+ fd = GETF(uap->fd);
+ if (!fd) return(EBADF);
#else
- if (code = getf(uap->fd, &fd)) {
- return (code);
- }
+ if (code = getf(uap->fd, &fd)) {
+ return (code);
+ }
#endif
#else
- fd = getf(uap->fd);
- if (!fd) return;
+ fd = getf(uap->fd);
+ if (!fd) return(EBADF);
#endif
#endif
#endif
#endif
-
- /* first determine whether this is any sort of vnode */
-#ifdef AFS_LINUX22_ENV
- tvc = (struct vcache *)ip;
- {
+#endif
+#endif
+ /* first determine whether this is any sort of vnode */
+#if defined(AFS_LINUX22_ENV)
+ tvc = VTOAFS(ip);
+ {
#else
-#ifdef AFS_SUN5_ENV
- if (fd->f_vnode->v_type == VREG || fd->f_vnode->v_type == VDIR) {
+#ifdef AFS_SUN5_ENV
+ if (fd->f_vnode->v_type == VREG || fd->f_vnode->v_type == VDIR) {
#else
- if (fd->f_type == DTYPE_VNODE) {
+ if (fd->f_type == DTYPE_VNODE) {
#endif
/* good, this is a vnode; next see if it is an AFS vnode */
#if defined(AFS_AIX32_ENV) || defined(AFS_SUN5_ENV)
- tvc = (struct vcache *) fd->f_vnode; /* valid, given a vnode */
+ tvc = VTOAFS(fd->f_vnode); /* valid, given a vnode */
+#elif defined(AFS_OBSD_ENV)
+ tvc = IsAfsVnode((struct vnode *) fd->f_data) ?
+ VTOAFS((struct vnode *) fd->f_data) : NULL;
#else
- tvc = (struct vcache *) fd->f_data; /* valid, given a vnode */
+ tvc = VTOAFS((struct vnode*)fd->f_data); /* valid, given a vnode */
#endif
#endif /* AFS_LINUX22_ENV */
- if (tvc && IsAfsVnode((struct vnode *)tvc)) {
+ if (tvc && IsAfsVnode(AFSTOV(tvc))) {
#ifdef AFS_DEC_ENV
- tvc = (struct vcache *) afs_gntovn((struct gnode *) tvc);
- if (!tvc) { /* shouldn't happen with held gnodes */
- u.u_error = ENOENT;
- return;
- }
-#endif
- /* This is an AFS vnode */
- if (((uap->com >> 8) & 0xff) == 'V') {
- register struct afs_ioctl *datap;
- AFS_GLOCK();
- datap = (struct afs_ioctl *) osi_AllocSmallSpace(AFS_SMALLOCSIZ);
- AFS_COPYIN((char *)uap->arg, (caddr_t) datap, sizeof (struct afs_ioctl), code);
- if (code) {
- osi_FreeSmallSpace(datap);
- AFS_GUNLOCK();
+ tvc = VTOAFS(afs_gntovn((struct gnode *) tvc));
+ if (!tvc) { /* shouldn't happen with held gnodes */
+ u.u_error = ENOENT;
+ return;
+ }
+#endif
+ /* This is an AFS vnode */
+ if (((uap->com >> 8) & 0xff) == 'V') {
+ register struct afs_ioctl *datap;
+ AFS_GLOCK();
+ datap = (struct afs_ioctl *) osi_AllocSmallSpace(AFS_SMALLOCSIZ);
+ AFS_COPYIN((char *)uap->arg, (caddr_t) datap, sizeof (struct afs_ioctl), code);
+ if (code) {
+ osi_FreeSmallSpace(datap);
+ AFS_GUNLOCK();
+#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+ return code;
+#else
#if defined(AFS_SUN5_ENV)
#ifdef AFS_SUN54_ENV
- releasef(uap->fd);
+ releasef(uap->fd);
#else
- releasef(fd);
+ releasef(fd);
#endif
- return (EFAULT);
+ return (EFAULT);
#else
#ifdef AFS_OSF_ENV
#ifdef AFS_OSF30_ENV
- FP_UNREF_ALWAYS(fd);
+ FP_UNREF_ALWAYS(fd);
#else
- FP_UNREF(fd);
+ FP_UNREF(fd);
#endif
- return code;
+ return code;
#else /* AFS_OSF_ENV */
#ifdef AFS_AIX41_ENV
- ufdrele(uap->fd);
+ ufdrele(uap->fd);
#endif
#ifdef AFS_LINUX22_ENV
- return -code;
+ return -code;
#else
- setuerror(code);
- return;
+ setuerror(code);
+ return;
#endif
#endif
#endif
- }
- code = HandleIoctl(tvc, uap->com, datap);
- osi_FreeSmallSpace(datap);
- AFS_GUNLOCK();
- ioctlDone = 1;
+#endif
+ }
+ code = HandleIoctl(tvc, uap->com, datap);
+ osi_FreeSmallSpace(datap);
+ AFS_GUNLOCK();
+ ioctlDone = 1;
#ifdef AFS_AIX41_ENV
- ufdrele(uap->fd);
+ ufdrele(uap->fd);
#endif
#ifdef AFS_OSF_ENV
#ifdef AFS_OSF30_ENV
- FP_UNREF_ALWAYS(fd);
+ FP_UNREF_ALWAYS(fd);
#else
- FP_UNREF(fd);
+ FP_UNREF(fd);
#endif
#endif
- }
+ }
#if defined(AFS_LINUX22_ENV)
- else
- code = EINVAL;
+ else
+ code = EINVAL;
#endif
}
- }
+ }
- if (!ioctlDone) {
+ if (!ioctlDone) {
#ifdef AFS_AIX41_ENV
- ufdrele(uap->fd);
- code = okioctl(fdes, com, arg, ext);
- return code;
+ ufdrele(uap->fd);
+#ifdef AFS_AIX51_ENV
+ code = okioctl(fdes, com, arg, ext, arg2, arg3);
#else
-#ifdef AFS_AIX32_ENV
- okioctl(fdes, com, arg, ext);
+ code = okioctl(fdes, com, arg, ext);
+#endif
+ return code;
#else
-#if defined(AFS_SUN5_ENV)
+#ifdef AFS_AIX32_ENV
+ okioctl(fdes, com, arg, ext);
+#elif defined(AFS_SUN5_ENV)
#if defined(AFS_SUN57_ENV)
releasef(uap->fd);
#elif defined(AFS_SUN54_ENV)
- RELEASEF(uap->fd);
-#else
- releasef(fd);
-#endif
- code = ioctl(uap, rvp);
-#else
-#ifdef AFS_OSF_ENV
- code = ioctl(p, args, retval);
+ RELEASEF(uap->fd);
+#else
+ releasef(fd);
+#endif
+ code = ioctl(uap, rvp);
+#elif defined(AFS_FBSD_ENV)
+ return ioctl(p, uap);
+#elif defined(AFS_OBSD_ENV)
+ code = sys_ioctl(p, uap, retval);
+#elif defined(AFS_DARWIN_ENV)
+ return ioctl(p, uap, retval);
+#elif defined(AFS_OSF_ENV)
+ code = ioctl(p, args, retval);
#ifdef AFS_OSF30_ENV
- FP_UNREF_ALWAYS(fd);
+ FP_UNREF_ALWAYS(fd);
#else
- FP_UNREF(fd);
-#endif
- return code;
-#else /* AFS_OSF_ENV */
-#ifndef AFS_LINUX22_ENV
- ioctl();
-#endif
-#endif
+ FP_UNREF(fd);
#endif
+ return code;
+#elif !defined(AFS_LINUX22_ENV)
+ ioctl();
#endif
#endif
- }
+ }
#ifdef AFS_SUN5_ENV
- if (ioctlDone)
+ if (ioctlDone)
#ifdef AFS_SUN54_ENV
- releasef(uap->fd);
+ releasef(uap->fd);
#else
- releasef(fd);
+ releasef(fd);
#endif
- return (code);
+ return (code);
#else
#ifdef AFS_LINUX22_ENV
- return -code;
+ return -code;
#else
-#if !defined(AFS_OSF_ENV)
- if (!getuerror())
- setuerror(code);
+#if defined(KERNEL_HAVE_UERROR)
+ if (!getuerror())
+ setuerror(code);
#if defined(AFS_AIX32_ENV) && !defined(AFS_AIX41_ENV)
- return (getuerror() ? -1 : u.u_ioctlrv);
+ return (getuerror() ? -1 : u.u_ioctlrv);
#else
- return getuerror() ? -1 : 0;
+ return getuerror() ? -1 : 0;
#endif
#endif
#endif /* AFS_LINUX22_ENV */
#endif /* AFS_SUN5_ENV */
-#ifdef AFS_OSF_ENV
- return (code);
+#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+ return (code);
#endif
- }
+}
#endif /* AFS_SGI_ENV */
#endif /* AFS_HPUX102_ENV */
return (afs_syscall_pioctl(uap->path, uap->cmd, uap->cmarg, uap->follow));
}
-extern struct mount *afs_globalVFS;
#else /* AFS_OSF_ENV */
-extern struct vfs *afs_globalVFS;
+#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+int
+afs_pioctl(p, args, retval)
+ struct proc *p;
+ void *args;
+ int *retval;
+{
+ struct a {
+ char *path;
+ int cmd;
+ caddr_t cmarg;
+ int follow;
+ } *uap = (struct a *) args;
+
+ AFS_STATCNT(afs_pioctl);
+ return (afs_syscall_pioctl(uap->path, uap->cmd, uap->cmarg, uap->follow, p->p_cred->pc_ucred));
+}
+
+#else /* AFS_OSF_ENV */
+#endif
#endif
/* macro to avoid adding any more #ifdef's to pioctl code. */
#define PIOCTL_FREE_CRED()
#endif
+int
#ifdef AFS_SUN5_ENV
afs_syscall_pioctl(path, com, cmarg, follow, rvp, credp)
rval_t *rvp;
struct AFS_UCRED *credp;
#else
+#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+afs_syscall_pioctl(path, com, cmarg, follow, credp)
+ struct AFS_UCRED *credp;
+#else
afs_syscall_pioctl(path, com, cmarg, follow)
#endif
+#endif
char *path;
- int com;
+ unsigned int com;
caddr_t cmarg;
int follow;
{
struct ucred *credp = crref(); /* don't free until done! */
#endif
#ifdef AFS_LINUX22_ENV
- cred_t *credp = crref(); /* don't free until done! */
+ cred_t *credp = crref(); /* don't free until done! */
struct dentry *dp;
+
#endif
AFS_STATCNT(afs_syscall_pioctl);
if (follow) follow = 1; /* compat. with old venus */
-#ifndef AFS_SUN5_ENV
- if (! _VALIDVICEIOCTL(com)) {
- PIOCTL_FREE_CRED();
-#ifdef AFS_OSF_ENV
- return EINVAL;
-#else /* AFS_OSF_ENV */
-#if defined(AFS_SGI64_ENV) || defined(AFS_LINUX22_ENV)
- return EINVAL;
-#else
- setuerror(EINVAL);
- return EINVAL;
-#endif
-#endif
- }
-#endif
code = copyin_afs_ioctl(cmarg, &data);
if (code) {
PIOCTL_FREE_CRED();
-#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SGI64_ENV) || defined(AFS_LINUX22_ENV)
- return (code);
-#else
+#if defined(KERNEL_HAVE_UERROR)
setuerror(code);
- return code;
#endif
- }
+ return (code);
+ }
if ((com & 0xff) == PSetClientContext) {
-#ifdef AFS_LINUX22_ENV
- return EINVAL; /* Not handling these yet. */
-#endif
-#if defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_LINUX22_ENV)
+#if defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
+ return EINVAL; /* Not handling these yet. */
+#elif defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_LINUX22_ENV)
code = HandleClientContext(&data, &com, &foreigncreds, credp);
#else
-#if defined(AFS_HPUX101_ENV)
- code=HandleClientContext(&data, &com, &foreigncreds, p_cred(u.u_procp));
-#else
-#ifdef AFS_SGI_ENV
- code = HandleClientContext(&data, &com, &foreigncreds, OSI_GET_CURRENT_CRED());
-#else
- code = HandleClientContext(&data, &com, &foreigncreds, u.u_cred);
-#endif /* AFS_SGI_ENV */
-#endif
+ code = HandleClientContext(&data, &com, &foreigncreds, osi_curcred());
#endif
- if (code) {
- if (foreigncreds) {
- crfree(foreigncreds);
- }
- PIOCTL_FREE_CRED();
-#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SGI64_ENV) || defined(AFS_LINUX22_ENV)
- return (code);
+ if (code) {
+ if (foreigncreds) {
+ crfree(foreigncreds);
+ }
+ PIOCTL_FREE_CRED();
+#if defined(KERNEL_HAVE_UERROR)
+ return (setuerror(code), code);
#else
- return (setuerror(code), code);
+ return (code);
#endif
- }
+ }
}
-#ifndef AFS_LINUX22_ENV
+#if !defined(AFS_LINUX22_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_FBSD_ENV)
if (foreigncreds) {
- /*
- * We could have done without temporary setting the u.u_cred below
- * (foreigncreds could be passed as param the pioctl modules)
- * but calls such as afs_osi_suser() doesn't allow that since it
- * references u.u_cred directly. We could, of course, do something
- * like afs_osi_suser(cred) which, I think, is better since it
- * generalizes and supports multi cred environments...
- */
+ /*
+ * We could have done without temporary setting the u.u_cred below
+ * (foreigncreds could be passed as param the pioctl modules)
+ * but calls such as afs_osi_suser() doesn't allow that since it
+ * references u.u_cred directly. We could, of course, do something
+ * like afs_osi_suser(cred) which, I think, is better since it
+ * generalizes and supports multi cred environments...
+ */
#ifdef AFS_SUN5_ENV
tmpcred = credp;
credp = foreigncreds;
tmpcred = OSI_GET_CURRENT_CRED();
OSI_SET_CURRENT_CRED(foreigncreds);
#else
+#ifdef AFS_OBSD_ENV
+ tmpcred = osi_curcred();
+ osi_curcred() = foreigncreds;
+#else
tmpcred = u.u_cred;
u.u_cred = foreigncreds;
#endif /* AFS_SGI64_ENV */
#endif /* AFS_HPUX101_ENV */
#endif
#endif
+#endif
}
#endif
if ((com & 0xff) == 15) {
- /* special case prefetch so entire pathname eval occurs in helper process.
- otherwise, the pioctl call is essentially useless */
-#if defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_LINUX22_ENV)
+ /* special case prefetch so entire pathname eval occurs in helper process.
+ otherwise, the pioctl call is essentially useless */
+#if defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
code = Prefetch(path, &data, follow,
foreigncreds ? foreigncreds : credp);
#else
-#if defined(AFS_HPUX101_ENV)
- code = Prefetch(path, &data, follow, p_cred(u.u_procp));
-#else
-#ifdef AFS_SGI_ENV
- code = Prefetch(path, &data, follow, OSI_GET_CURRENT_CRED());
-#else
- code = Prefetch(path, &data, follow, u.u_cred);
-#endif /* AFS_SGI64_ENV */
-#endif /* AFS_HPUX101_ENV */
+ code = Prefetch(path, &data, follow, osi_curcred());
#endif
-#ifndef AFS_LINUX22_ENV
- if (foreigncreds) {
-#ifdef AFS_AIX41_ENV
- crset(tmpcred); /* restore original credentials */
-#else
-#if defined(AFS_HPUX101_ENV)
- set_p_cred(u.u_procp, tmpcred); /* restore original credentials */
-#else
-#ifndef AFS_SUN5_ENV
-#ifdef AFS_SGI_ENV
- OSI_SET_CURRENT_CRED(tmpcred); /* restore original credentials */
-#else
- u.u_cred = tmpcred; /* restore original credentials */
-#endif
-#endif
-#endif /* AFS_HPUX101_ENV */
- crfree(foreigncreds);
-#endif
- }
-#endif /* AFS_LINUX22_ENV */
- PIOCTL_FREE_CRED();
-#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SGI64_ENV) || defined(AFS_LINUX22_ENV)
- return (code);
-#else
- return (setuerror(code), code);
+ vp = NULL;
+#if defined(KERNEL_HAVE_UERROR)
+ setuerror(code);
#endif
+ goto rescred;
}
if (path) {
AFS_GUNLOCK();
#ifdef AFS_AIX41_ENV
code = lookupname(path, USR, follow, NULL, &vp,
- foreigncreds ? foreigncreds : credp);
+ foreigncreds ? foreigncreds : credp);
#else
#ifdef AFS_LINUX22_ENV
- code = gop_lookupname(path, AFS_UIOUSER, follow, (struct vnode **) 0, &dp);
+ code = gop_lookupname(path, AFS_UIOUSER, follow, NULL, &dp);
if (!code)
- vp = (struct vcache *)dp->d_inode;
+ vp = (struct vnode *)dp->d_inode;
#else
- code = gop_lookupname(path, AFS_UIOUSER, follow, (struct vnode **) 0, &vp);
+ code = gop_lookupname(path, AFS_UIOUSER, follow, NULL, &vp);
#endif /* AFS_LINUX22_ENV */
#endif /* AFS_AIX41_ENV */
AFS_GLOCK();
if (code) {
-#ifndef AFS_LINUX22_ENV
- if (foreigncreds) {
-#ifdef AFS_AIX41_ENV
- crset(tmpcred); /* restore original credentials */
-#else
-#if defined(AFS_HPUX101_ENV)
- set_p_cred(u.u_procp, tmpcred); /* restore original credentials */
-#else
-#if !defined(AFS_SUN5_ENV)
-#ifdef AFS_SGI_ENV
- OSI_SET_CURRENT_CRED(tmpcred); /* restore original credentials */
-#else
- u.u_cred = tmpcred; /* restore original credentials */
-#endif /* AFS_SGI64_ENV */
-#endif
-#endif /* AFS_HPUX101_ENV */
- crfree(foreigncreds);
-#endif
- }
-#endif /* AFS_LINUX22_ENV */
- PIOCTL_FREE_CRED();
-#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SGI64_ENV) || defined(AFS_LINUX22_ENV)
- return (code);
-#else
- return(setuerror(code), code);
+ vp = NULL;
+#if defined(KERNEL_HAVE_UERROR)
+ setuerror(code);
#endif
+ goto rescred;
}
}
- else vp = (struct vnode *) 0;
-
+ else vp = NULL;
+
/* now make the call if we were passed no file, or were passed an AFS file */
if (!vp || IsAfsVnode(vp)) {
#ifdef AFS_DEC_ENV
- /* Ultrix 4.0: can't get vcache entry unless we've got an AFS gnode.
- * So, we must test in this part of the code. Also, must arrange to
- * GRELE the original gnode pointer when we're done, since in Ultrix 4.0,
- * we hold gnodes, whose references hold our vcache entries.
- */
- if (vp) {
- gp = vp; /* remember for "put" */
- vp = (struct vnode *) afs_gntovn(vp); /* get vcache from gp */
- }
- else gp = (struct vnode *) 0;
+ /* Ultrix 4.0: can't get vcache entry unless we've got an AFS gnode.
+ * So, we must test in this part of the code. Also, must arrange to
+ * GRELE the original gnode pointer when we're done, since in Ultrix 4.0,
+ * we hold gnodes, whose references hold our vcache entries.
+ */
+ if (vp) {
+ gp = vp; /* remember for "put" */
+ vp = (struct vnode *) afs_gntovn(vp); /* get vcache from gp */
+ }
+ else gp = NULL;
#endif
#ifdef AFS_SUN5_ENV
- code = afs_HandlePioctl(vp, com, &data, follow, &credp);
+ code = afs_HandlePioctl(vp, com, &data, follow, &credp);
#else
#ifdef AFS_AIX41_ENV
- {
- struct ucred *cred1, *cred2;
+ {
+ struct ucred *cred1, *cred2;
- if (foreigncreds) {
- cred1 = cred2 = foreigncreds;
- } else {
- cred1 = cred2 = credp;
- }
- code = afs_HandlePioctl(vp, com, &data, follow, &cred1);
- if (cred1 != cred2) {
- /* something changed the creds */
- crset(cred1);
- }
- }
+ if (foreigncreds) {
+ cred1 = cred2 = foreigncreds;
+ } else {
+ cred1 = cred2 = credp;
+ }
+ code = afs_HandlePioctl(vp, com, &data, follow, &cred1);
+ if (cred1 != cred2) {
+ /* something changed the creds */
+ crset(cred1);
+ }
+ }
#else
#if defined(AFS_HPUX101_ENV)
- {
- struct ucred *cred = p_cred(u.u_procp);
- code = afs_HandlePioctl(vp, com, &data, follow, &cred);
- }
+ {
+ struct ucred *cred = p_cred(u.u_procp);
+ code = afs_HandlePioctl(vp, com, &data, follow, &cred);
+ }
#else
#ifdef AFS_SGI_ENV
- {
- struct cred *credp;
- credp = OSI_GET_CURRENT_CRED();
- code = afs_HandlePioctl(vp, com, &data, follow, &credp);
- }
+ {
+ struct cred *credp;
+ credp = OSI_GET_CURRENT_CRED();
+ code = afs_HandlePioctl(vp, com, &data, follow, &credp);
+ }
#else
-#ifdef AFS_LINUX22_ENV
- code = afs_HandlePioctl(vp, com, &data, follow, &credp);
+#if defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+ code = afs_HandlePioctl(vp, com, &data, follow, &credp);
#else
- code = afs_HandlePioctl(vp, com, &data, follow, &u.u_cred);
+ code = afs_HandlePioctl(vp, com, &data, follow, &u.u_cred);
#endif
#endif /* AFS_SGI_ENV */
#endif /* AFS_HPUX101_ENV */
#endif /* AFS_AIX41_ENV */
#endif /* AFS_SUN5_ENV */
} else {
-#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SGI64_ENV) || defined(AFS_LINUX22_ENV)
- code = EINVAL; /* not in /afs */
-#else
+#if defined(KERNEL_HAVE_UERROR)
setuerror(EINVAL);
+#else
+ code = EINVAL; /* not in /afs */
#endif
#ifdef AFS_DEC_ENV
if (vp) {
GRELE(vp);
- vp = (struct vnode *) 0;
+ vp = NULL;
}
#endif
}
-#ifndef AFS_LINUX22_ENV
+ rescred:
+#if !defined(AFS_LINUX22_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_FBSD_ENV)
if (foreigncreds) {
#ifdef AFS_AIX41_ENV
- crset(tmpcred);
+ crset(tmpcred); /* restore original credentials */
#else
#if defined(AFS_HPUX101_ENV)
set_p_cred(u.u_procp, tmpcred); /* restore original credentials */
-#else
-#ifndef AFS_SUN5_ENV
-#ifdef AFS_SGI_ENV
- OSI_SET_CURRENT_CRED(tmpcred); /* restore original credentials */
-#else
- u.u_cred = tmpcred; /* restore original credentials */
-#endif /* ASF_SGI64_ENV */
-#endif
+#elif defined(AFS_SGI_ENV)
+ OSI_SET_CURRENT_CRED(tmpcred); /* restore original credentials */
+#elif !defined(AFS_SUN5_ENV)
+ osi_curcred() = tmpcred; /* restore original credentials */
#endif /* AFS_HPUX101_ENV */
crfree(foreigncreds);
-#endif
+#endif /* AIX41 */
}
-#endif /* AFS_LINUX22_ENV */
+#endif /* LINUX, DARWIN, FBSD */
if (vp) {
#ifdef AFS_LINUX22_ENV
dput(dp);
#else
- AFS_RELE(vp); /* put vnode back */
+ AFS_RELE(vp); /* put vnode back */
#endif
}
PIOCTL_FREE_CRED();
-#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SGI64_ENV) || defined(AFS_LINUX22_ENV)
- return (code);
-#else
+#if defined(KERNEL_HAVE_UERROR)
if (!getuerror())
setuerror(code);
return (getuerror());
+#else
+ return (code);
#endif
}
-afs_HandlePioctl(avc, acom, ablob, afollow, acred)
- register struct vcache *avc;
- afs_int32 acom;
- struct AFS_UCRED **acred;
- register struct afs_ioctl *ablob;
- int afollow;
+int afs_HandlePioctl(struct vcache *avc, afs_int32 acom,
+ register struct afs_ioctl *ablob, int afollow, struct AFS_UCRED **acred)
{
struct vrequest treq;
register afs_int32 code;
- register afs_int32 function;
+ register afs_int32 function, device;
afs_int32 inSize, outSize;
char *inData, *outData;
+ int (*(*pioctlSw))();
+ int pioctlSwSize;
+ struct afs_fakestat_state fakestate;
afs_Trace3(afs_iclSetp, CM_TRACE_PIOCTL, ICL_TYPE_INT32, acom & 0xff,
ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, afollow);
AFS_STATCNT(HandlePioctl);
- if (code = afs_InitReq(&treq, *acred)) return code;
+ if ((code = afs_InitReq(&treq, *acred))) return code;
+ afs_InitFakeStat(&fakestate);
+ if (avc) {
+ code = afs_EvalFakeStat(&avc, &fakestate, &treq);
+ if (code) {
+ afs_PutFakeStat(&fakestate);
+ return code;
+ }
+ }
+ device = (acom & 0xff00) >> 8;
+ switch (device) {
+ case 'V': /* Original pioctl's */
+ pioctlSw = VpioctlSw;
+ pioctlSwSize = sizeof(VpioctlSw);
+ break;
+ case 'C': /* Coordinated/common pioctl's */
+ pioctlSw = CpioctlSw;
+ pioctlSwSize = sizeof(CpioctlSw);
+ break;
+ default:
+ afs_PutFakeStat(&fakestate);
+ return EINVAL;
+ }
function = acom & 0xff;
- if (function >= (sizeof(pioctlSw) / sizeof(char *))) {
- return EINVAL; /* out of range */
+ if (function >= (pioctlSwSize / sizeof(char *))) {
+ afs_PutFakeStat(&fakestate);
+ return EINVAL; /* out of range */
}
inSize = ablob->in_size;
if (inSize >= PIGGYSIZE) return E2BIG;
inData = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
if (inSize > 0) {
AFS_COPYIN(ablob->in, inData, inSize, code);
+ inData[inSize]='\0';
}
else code = 0;
if (code) {
- osi_FreeLargeSpace(inData);
- return code;
+ osi_FreeLargeSpace(inData);
+ afs_PutFakeStat(&fakestate);
+ return code;
}
outData = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
outSize = 0;
- if (function == 3) /* PSetTokens */
- code = (*pioctlSw[function])(avc, function, &treq, inData, outData, inSize, &outSize, acred);
- else
- code = (*pioctlSw[function])(avc, function, &treq, inData, outData, inSize, &outSize, *acred);
+ code = (*pioctlSw[function])(avc, function, &treq, inData, outData, inSize, &outSize, acred);
osi_FreeLargeSpace(inData);
if (code == 0 && ablob->out_size > 0) {
if (outSize > ablob->out_size) outSize = ablob->out_size;
if (outSize >= PIGGYSIZE) code = E2BIG;
- else if (outSize)
+ else if (outSize) {
+ outData[outSize]='\0';
AFS_COPYOUT(outData, ablob->out, outSize, code);
+ }
}
osi_FreeLargeSpace(outData);
+ afs_PutFakeStat(&fakestate);
return afs_CheckCode(code, &treq, 41);
}
- static PGetFID(avc, afun, areq, ain, aout, ainSize, aoutSize)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */ {
- register afs_int32 code;
-
+DECL_PIOCTL(PGetFID)
+{
AFS_STATCNT(PGetFID);
if (!avc) return EINVAL;
- bcopy((char *)&avc->fid, aout, sizeof(struct VenusFid));
+ memcpy(aout, (char *)&avc->fid, sizeof(struct VenusFid));
*aoutSize = sizeof(struct VenusFid);
return 0;
- }
+}
-static PSetAcl(avc, afun, areq, ain, aout, ainSize, aoutSize)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */ {
+DECL_PIOCTL(PSetAcl)
+{
register afs_int32 code;
struct conn *tconn;
struct AFSOpaque acl;
tconn = afs_Conn(&avc->fid, areq, SHARED_LOCK);
if (tconn) {
XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_STOREACL);
-#ifdef RX_ENABLE_LOCKS
- AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GUNLOCK();
code = RXAFS_StoreACL(tconn->id, (struct AFSFid *) &avc->fid.Fid,
&acl, &OutStatus, &tsync);
-#ifdef RX_ENABLE_LOCKS
- AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GLOCK();
XSTATS_END_TIME;
}
else code = -1;
} while
(afs_Analyze(tconn, code, &avc->fid, areq,
- AFS_STATS_FS_RPCIDX_STOREACL, SHARED_LOCK, (struct cell *)0));
+ AFS_STATS_FS_RPCIDX_STOREACL, SHARED_LOCK, NULL));
/* now we've forgotten all of the access info */
ObtainWriteLock(&afs_xcbhash, 455);
int afs_defaultAsynchrony = 0;
-static PStoreBehind(avc, afun, areq, ain, aout, ainSize, aoutSize, acred)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */
- struct AFS_UCRED *acred;
+DECL_PIOCTL(PStoreBehind)
{
afs_int32 code = 0;
struct sbstruct *sbr;
sbr = (struct sbstruct *)ain;
if (sbr->sb_default != -1) {
- if (afs_osi_suser(acred))
+ if (afs_osi_suser(*acred))
afs_defaultAsynchrony = sbr->sb_default;
else code = EPERM;
}
- if (avc && (sbr->sb_thisfile != -1))
+ if (avc && (sbr->sb_thisfile != -1)) {
if (afs_AccessOK(avc, PRSFS_WRITE | PRSFS_ADMINISTER,
areq, DONT_CHECK_MODE_BITS))
avc->asynchrony = sbr->sb_thisfile;
else code = EACCES;
+ }
*aoutSize = sizeof(struct sbstruct);
sbr = (struct sbstruct *)aout;
return code;
}
-static PGCPAGs(avc, afun, areq, ain, aout, ainSize, aoutSize, acred)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */
- struct AFS_UCRED *acred;
+DECL_PIOCTL(PGCPAGs)
{
- if (!afs_osi_suser(acred)) {
+ if (!afs_osi_suser(*acred)) {
return EACCES;
}
afs_gcpags = AFS_GCPAGS_USERDISABLED;
return 0;
}
- static PGetAcl(avc, afun, areq, ain, aout, ainSize, aoutSize)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */ {
+DECL_PIOCTL(PGetAcl)
+{
struct AFSOpaque acl;
struct AFSVolSync tsync;
struct AFSFetchStatus OutStatus;
if (tconn) {
*aout = 0;
XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_FETCHACL);
-#ifdef RX_ENABLE_LOCKS
- AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GUNLOCK();
code = RXAFS_FetchACL(tconn->id, &Fid,
&acl, &OutStatus, &tsync);
-#ifdef RX_ENABLE_LOCKS
- AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GLOCK();
XSTATS_END_TIME;
}
else code = -1;
} while
(afs_Analyze(tconn, code, &avc->fid, areq,
AFS_STATS_FS_RPCIDX_FETCHACL,
- SHARED_LOCK, (struct cell *)0));
+ SHARED_LOCK, NULL));
if (code == 0) {
*aoutSize = (acl.AFSOpaque_len == 0 ? 1 : acl.AFSOpaque_len);
}
return code;
- }
+}
- static PNoop() {
+DECL_PIOCTL(PNoop)
+{
AFS_STATCNT(PNoop);
return 0;
- }
+}
- static PBogus() {
+DECL_PIOCTL(PBogus)
+{
AFS_STATCNT(PBogus);
return EINVAL;
- }
+}
- static PGetFileCell(avc, afun, areq, ain, aout, ainSize, aoutSize)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- register char *ain;
- char *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */ {
+DECL_PIOCTL(PGetFileCell)
+{
register struct cell *tcell;
AFS_STATCNT(PGetFileCell);
return 0;
}
- static PGetWSCell(avc, afun, areq, ain, aout, ainSize, aoutSize)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- register char *ain;
- char *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */ {
- register struct cell *tcell=0, *cellOne=0;
- register struct afs_q *cq, *tq;
+DECL_PIOCTL(PGetWSCell)
+{
+ struct cell *tcell = NULL;
AFS_STATCNT(PGetWSCell);
if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
return EIO; /* Inappropriate ioctl for device */
- ObtainReadLock(&afs_xcell);
- cellOne = (struct cell *) 0;
-
- for (cq = CellLRU.next; cq != &CellLRU; cq = tq) {
- tcell = QTOC(cq); tq = QNext(cq);
- if (tcell->states & CPrimary) break;
- if (tcell->cell == 1) cellOne = tcell;
- tcell = 0;
- }
- ReleaseReadLock(&afs_xcell);
- if (!tcell) { /* no primary cell, use cell #1 */
- if (!cellOne) return ESRCH;
- tcell = cellOne;
- }
+ tcell = afs_GetPrimaryCell(READ_LOCK);
+ if (!tcell) /* no primary cell? */
+ return ESRCH;
strcpy(aout, tcell->cellName);
*aoutSize = strlen(aout) + 1;
+ afs_PutCell(tcell, READ_LOCK);
return 0;
}
- static PGetUserCell(avc, afun, areq, ain, aout, ainSize, aoutSize)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- register char *ain;
- char *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */ {
+DECL_PIOCTL(PGetUserCell)
+{
register afs_int32 i;
register struct unixuser *tu;
register struct cell *tcell;
return 0;
}
- static PSetTokens(avc, afun, areq, ain, aout, ainSize, aoutSize, acred)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- register char *ain;
- char *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */
- struct AFS_UCRED **acred;
+DECL_PIOCTL(PSetTokens)
{
afs_int32 i;
register struct unixuser *tu;
if (!afs_resourceinit_flag) {
return EIO;
}
- bcopy(ain, (char *)&i, sizeof(afs_int32));
+ memcpy((char *)&i, ain, sizeof(afs_int32));
ain += sizeof(afs_int32);
stp = ain; /* remember where the ticket is */
if (i < 0 || i > 2000) return EINVAL; /* malloc may fail */
+ if (i > MAXKTCTICKETLEN) return EINVAL;
stLen = i;
ain += i; /* skip over ticket */
- bcopy(ain, (char *)&i, sizeof(afs_int32));
+ memcpy((char *)&i, ain, sizeof(afs_int32));
ain += sizeof(afs_int32);
if (i != sizeof(struct ClearToken)) {
return EINVAL;
}
- bcopy(ain, (char *)&clear, sizeof(struct ClearToken));
+ memcpy((char *)&clear, ain, sizeof(struct ClearToken));
if (clear.AuthHandle == -1) clear.AuthHandle = 999; /* more rxvab compat stuff */
ain += sizeof(struct ClearToken);
if (ainSize != 2*sizeof(afs_int32) + stLen + sizeof(struct ClearToken)) {
/* still stuff left? we've got primary flag and cell name. Set these */
- bcopy(ain, (char *)&flag, sizeof(afs_int32)); /* primary id flag */
+ memcpy((char *)&flag, ain, sizeof(afs_int32)); /* primary id flag */
ain += sizeof(afs_int32); /* skip id field */
/* rest is cell name, look it up */
- if (flag & 0x8000) { /* XXX Use Constant XXX */
+ /* some versions of gcc appear to need != 0 in order to get this right */
+ if ((flag & 0x8000) != 0) { /* XXX Use Constant XXX */
flag &= ~0x8000;
set_parent_pag = 1;
}
tcell = afs_GetCellByName(ain, READ_LOCK);
- if (tcell) {
- i = tcell->cell;
- }
- else {
- goto nocell;
- }
+ if (!tcell) goto nocell;
}
else {
- /* default to cell 1, primary id */
+ /* default to primary cell, primary id */
flag = 1; /* primary id */
- i = 1; /* cell number */
- tcell = afs_GetCell(1, READ_LOCK);
+ tcell = afs_GetPrimaryCell(READ_LOCK);
if (!tcell) goto nocell;
}
+ i = tcell->cellNum;
afs_PutCell(tcell, READ_LOCK);
if (set_parent_pag) {
- int pag;
+ afs_int32 pag;
+#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+#if defined(AFS_DARWIN_ENV)
+ struct proc *p = current_proc(); /* XXX */
+#else
+ struct proc *p = curproc; /* XXX */
+#endif
+ uprintf("Process %d (%s) tried to change pags in PSetTokens\n",
+ p->p_pid, p->p_comm);
+ if (!setpag(p, acred, -1, &pag, 1)) {
+#else
#ifdef AFS_OSF_ENV
if (!setpag(u.u_procp, acred, -1, &pag, 1)) { /* XXX u.u_procp is a no-op XXX */
#else
if (!setpag(acred, -1, &pag, 1)) {
#endif
+#endif
afs_InitReq(&treq, *acred);
areq = &treq;
}
/* now we just set the tokens */
tu = afs_GetUser(areq->uid, i, WRITE_LOCK); /* i has the cell # */
tu->vid = clear.ViceId;
- if (tu->stp != (char *) 0) {
+ if (tu->stp != NULL) {
afs_osi_Free(tu->stp, tu->stLen);
}
tu->stp = (char *) afs_osi_Alloc(stLen);
tu->stLen = stLen;
- bcopy(stp, tu->stp, stLen);
+ memcpy(tu->stp, stp, stLen);
tu->ct = clear;
#ifndef AFS_NOSTATS
afs_stats_cmfullperf.authent.TicketUpdates++;
}
}
-static PGetVolumeStatus(avc, afun, areq, ain, aout, ainSize, aoutSize)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */ {
+DECL_PIOCTL(PGetVolumeStatus)
+{
char volName[32];
char offLineMsg[256];
char motd[256];
tc = afs_Conn(&avc->fid, areq, SHARED_LOCK);
if (tc) {
XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_GETVOLUMESTATUS);
-#ifdef RX_ENABLE_LOCKS
- AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GUNLOCK();
code = RXAFS_GetVolumeStatus(tc->id, avc->fid.Fid.Volume, &volstat,
&Name, &OfflineMsg, &MOTD);
-#ifdef RX_ENABLE_LOCKS
- AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GLOCK();
XSTATS_END_TIME;
}
else code = -1;
} while
(afs_Analyze(tc, code, &avc->fid, areq,
AFS_STATS_FS_RPCIDX_GETVOLUMESTATUS,
- SHARED_LOCK, (struct cell *)0));
+ SHARED_LOCK, NULL));
if (code) return code;
/* Copy all this junk into msg->im_data, keeping track of the lengths. */
cp = aout;
- bcopy((char *)&volstat, cp, sizeof(VolumeStatus));
+ memcpy(cp, (char *)&volstat, sizeof(VolumeStatus));
cp += sizeof(VolumeStatus);
strcpy(cp, volName);
cp += strlen(volName)+1;
return 0;
}
-static PSetVolumeStatus(avc, afun, areq, ain, aout, ainSize, aoutSize)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */ {
+DECL_PIOCTL(PSetVolumeStatus)
+{
char volName[32];
char offLineMsg[256];
char motd[256];
return ENODEV;
/* Copy the junk out, using cp as a roving pointer. */
cp = ain;
- bcopy(cp, (char *)&volstat, sizeof(AFSFetchVolumeStatus));
+ memcpy((char *)&volstat, cp, sizeof(AFSFetchVolumeStatus));
cp += sizeof(AFSFetchVolumeStatus);
+ if (strlen(cp) >= sizeof(volName))
+ return E2BIG;
strcpy(volName, cp);
cp += strlen(volName)+1;
+ if (strlen(cp) >= sizeof(offLineMsg))
+ return E2BIG;
strcpy(offLineMsg, cp);
cp += strlen(offLineMsg)+1;
+ if (strlen(cp) >= sizeof(motd))
+ return E2BIG;
strcpy(motd, cp);
storeStat.Mask = 0;
if (volstat.MinQuota != -1) {
tc = afs_Conn(&avc->fid, areq, SHARED_LOCK);
if (tc) {
XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_SETVOLUMESTATUS);
-#ifdef RX_ENABLE_LOCKS
- AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GUNLOCK();
code = RXAFS_SetVolumeStatus(tc->id, avc->fid.Fid.Volume,
&storeStat, volName, offLineMsg, motd);
-#ifdef RX_ENABLE_LOCKS
- AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GLOCK();
XSTATS_END_TIME;
}
else code = -1;
} while
(afs_Analyze(tc, code, &avc->fid, areq,
AFS_STATS_FS_RPCIDX_SETVOLUMESTATUS,
- SHARED_LOCK, (struct cell *)0));
+ SHARED_LOCK, NULL));
if (code) return code;
/* we are sending parms back to make compat. with prev system. should
change interface later to not ask for current status, just set new status */
cp = aout;
- bcopy((char *)&volstat, cp, sizeof(VolumeStatus));
+ memcpy(cp, (char *)&volstat, sizeof(VolumeStatus));
cp += sizeof(VolumeStatus);
strcpy(cp, volName);
cp += strlen(volName)+1;
return 0;
}
-static PFlush(avc, afun, areq, ain, aout, ainSize, aoutSize, acred)
- register struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */
- struct AFS_UCRED *acred;
+DECL_PIOCTL(PFlush)
{
-
AFS_STATCNT(PFlush);
if (!avc) return EINVAL;
#if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV)
avc->states &= ~(CStatd | CDirty); /* next reference will re-stat cache entry */
ReleaseWriteLock(&afs_xcbhash);
/* now find the disk cache entries */
- afs_TryToSmush(avc, acred, 1);
+ afs_TryToSmush(avc, *acred, 1);
osi_dnlc_purgedp(avc);
afs_symhint_inval(avc);
if (avc->linkData && !(avc->states & CCore)) {
afs_osi_Free(avc->linkData, strlen(avc->linkData)+1);
- avc->linkData = (char *) 0;
+ avc->linkData = NULL;
}
ReleaseWriteLock(&avc->lock);
#if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV)
return 0;
}
-static PNewStatMount(avc, afun, areq, ain, aout, ainSize, aoutSize)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */ {
+DECL_PIOCTL(PNewStatMount)
+{
register afs_int32 code;
register struct vcache *tvc;
register struct dcache *tdc;
struct VenusFid tfid;
- char *bufp = 0;
- afs_int32 offset, len, hasatsys=0;
+ char *bufp;
+ struct sysname_info sysState;
+ afs_size_t offset, len;
AFS_STATCNT(PNewStatMount);
if (!avc) return EINVAL;
if (vType(avc) != VDIR) {
return ENOTDIR;
}
- tdc = afs_GetDCache(avc, 0, areq, &offset, &len, 1);
+ tdc = afs_GetDCache(avc, (afs_size_t) 0, areq, &offset, &len, 1);
if (!tdc) return ENOENT;
- hasatsys = Check_AtSys(avc, ain, &bufp, areq);
- code = afs_dir_Lookup(&tdc->f.inode, bufp, &tfid.Fid);
+ Check_AtSys(avc, ain, &sysState, areq);
+ ObtainReadLock(&tdc->lock);
+ do {
+ code = afs_dir_Lookup(&tdc->f.inode, sysState.name, &tfid.Fid);
+ } while (code == ENOENT && Next_AtSys(avc, areq, &sysState));
+ ReleaseReadLock(&tdc->lock);
+ afs_PutDCache(tdc); /* we're done with the data */
+ bufp = sysState.name;
if (code) {
- afs_PutDCache(tdc);
goto out;
}
tfid.Cell = avc->fid.Cell;
tfid.Fid.Volume = avc->fid.Fid.Volume;
- afs_PutDCache(tdc); /* we're done with the data */
if (!tfid.Fid.Unique && (avc->states & CForeign)) {
- tvc = afs_LookupVCache(&tfid, areq, (afs_int32 *)0, WRITE_LOCK, avc, bufp);
+ tvc = afs_LookupVCache(&tfid, areq, NULL, avc, bufp);
} else {
- tvc = afs_GetVCache(&tfid, areq, (afs_int32 *)0, (struct vcache*)0,
- WRITE_LOCK);
+ tvc = afs_GetVCache(&tfid, areq, NULL, NULL);
}
if (!tvc) {
code = ENOENT;
goto out;
}
- if (vType(tvc) != VLNK) {
- afs_PutVCache(tvc, WRITE_LOCK);
+ if (tvc->mvstat != 1) {
+ afs_PutVCache(tvc);
code = EINVAL;
goto out;
}
code = EIO;
}
ReleaseWriteLock(&tvc->lock);
- afs_PutVCache(tvc, WRITE_LOCK);
+ afs_PutVCache(tvc);
out:
- if (hasatsys) osi_FreeLargeSpace(bufp);
+ if (sysState.allocked) osi_FreeLargeSpace(bufp);
return code;
}
-static PGetTokens(avc, afun, areq, ain, aout, ainSize, aoutSize)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */ {
+DECL_PIOCTL(PGetTokens)
+{
register struct cell *tcell;
register afs_int32 i;
register struct unixuser *tu;
tokens, the primary cell indicator (an afs_int32 0) and the cell name
at the end, in that order.
*/
- if (newStyle = (ainSize > 0)) {
- bcopy(ain, (char *)&iterator, sizeof(afs_int32));
+ if ((newStyle = (ainSize > 0))) {
+ memcpy((char *)&iterator, ain, sizeof(afs_int32));
}
i = UHash(areq->uid);
ObtainReadLock(&afs_xuser);
}
}
else {
- if (tu->uid == areq->uid && tu->cell == 1) break;
+ if (tu->uid == areq->uid && afs_IsPrimaryCellNum(tu->cell)) break;
}
}
if (tu) {
cp = aout;
iterator = tu->stLen; /* for compat, we try to return 56 byte tix if they fit */
if (iterator < 56) iterator = 56; /* # of bytes we're returning */
- bcopy((char *)&iterator, cp, sizeof(afs_int32));
+ memcpy(cp, (char *)&iterator, sizeof(afs_int32));
cp += sizeof(afs_int32);
- bcopy(tu->stp, cp, tu->stLen); /* copy out st */
+ memcpy(cp, tu->stp, tu->stLen); /* copy out st */
cp += iterator;
iterator = sizeof(struct ClearToken);
- bcopy((char *)&iterator, cp, sizeof(afs_int32));
+ memcpy(cp, (char *)&iterator, sizeof(afs_int32));
cp += sizeof(afs_int32);
- bcopy((char *)&tu->ct, cp, sizeof(struct ClearToken));
+ memcpy(cp, (char *)&tu->ct, sizeof(struct ClearToken));
cp += sizeof(struct ClearToken);
if (newStyle) {
/* put out primary id and cell name, too */
iterator = (tu->states & UPrimary ? 1 : 0);
- bcopy((char *)&iterator, cp, sizeof(afs_int32));
+ memcpy(cp, (char *)&iterator, sizeof(afs_int32));
cp += sizeof(afs_int32);
tcell = afs_GetCell(tu->cell, READ_LOCK);
if (tcell) {
return 0;
}
-static PUnlog(avc, afun, areq, ain, aout, ainSize, aoutSize)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */ {
+DECL_PIOCTL(PUnlog)
+{
register afs_int32 i;
register struct unixuser *tu;
tu->vid = UNDEFVID;
tu->states &= ~UHasTokens;
/* security is not having to say you're sorry */
- bzero((char *)&tu->ct, sizeof(struct ClearToken));
+ memset((char *)&tu->ct, 0, sizeof(struct ClearToken));
tu->refCount++;
ReleaseWriteLock(&afs_xuser);
/* We have to drop the lock over the call to afs_ResetUserConns, since
afs_ResetUserConns(tu);
tu->refCount--;
ObtainWriteLock(&afs_xuser,228);
+#ifdef UKERNEL
+ /* set the expire times to 0, causes
+ * afs_GCUserData to remove this entry
+ */
+ tu->ct.EndTimestamp = 0;
+ tu->tokenTime = 0;
+#endif /* UKERNEL */
}
}
ReleaseWriteLock(&afs_xuser);
return 0;
}
-static PMariner(avc, afun, areq, ain, aout, ainSize, aoutSize)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */ {
+DECL_PIOCTL(PMariner)
+{
afs_int32 newHostAddr;
afs_int32 oldHostAddr;
AFS_STATCNT(PMariner);
if (afs_mariner)
- bcopy((char *)&afs_marinerHost, (char *)&oldHostAddr, sizeof(afs_int32));
+ memcpy((char *)&oldHostAddr, (char *)&afs_marinerHost, sizeof(afs_int32));
else
oldHostAddr = 0xffffffff; /* disabled */
- bcopy(ain, (char *)&newHostAddr, sizeof(afs_int32));
+ memcpy((char *)&newHostAddr, ain, sizeof(afs_int32));
if (newHostAddr == 0xffffffff) {
/* disable mariner operations */
afs_mariner = 0;
afs_mariner = 1;
afs_marinerHost = newHostAddr;
}
- bcopy((char *)&oldHostAddr, aout, sizeof(afs_int32));
+ memcpy(aout, (char *)&oldHostAddr, sizeof(afs_int32));
*aoutSize = sizeof(afs_int32);
return 0;
}
-static PCheckServers(avc, afun, areq, ain, aout, ainSize, aoutSize, acred)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */
- struct AFS_UCRED *acred;
+DECL_PIOCTL(PCheckServers)
{
register char *cp = 0;
register int i;
pcheck=(struct chservinfo *)ain;
if (pcheck->tinterval >= 0) {
cp = aout;
- bcopy((char *)&PROBE_INTERVAL, cp, sizeof(afs_int32));
+ memcpy(cp, (char *)&PROBE_INTERVAL, sizeof(afs_int32));
*aoutSize = sizeof(afs_int32);
if (pcheck->tinterval > 0) {
- if (!afs_osi_suser(acred))
+ if (!afs_osi_suser(*acred))
return EACCES;
PROBE_INTERVAL=pcheck->tinterval;
}
temp=pcheck->tflags;
cp = pcheck->tbuffer;
} else { /* For pre afs3.3 versions */
- bcopy(ain, (char *)&temp, sizeof(afs_int32));
+ memcpy((char *)&temp, ain, sizeof(afs_int32));
cp = ain+sizeof(afs_int32);
if (ainSize > sizeof(afs_int32))
havecell = 1;
cellp = afs_GetCellByName(cp, READ_LOCK);
if (!cellp) return ENOENT;
}
- else cellp = (struct cell *) 0;
+ else cellp = NULL;
if (!cellp && (temp & 2)) {
/* use local cell */
- cellp = afs_GetCell(1, READ_LOCK);
+ cellp = afs_GetPrimaryCell(READ_LOCK);
}
if (!(temp & 1)) { /* if not fast, call server checker routine */
afs_CheckServers(1, cellp); /* check down servers */
for(ts = afs_servers[i]; ts; ts=ts->next) {
if (cellp && ts->cell != cellp) continue; /* cell spec'd and wrong */
if ((ts->flags & SRVR_ISDOWN) && ts->addr->sa_portal != ts->cell->vlport) {
- bcopy((char *)&ts->addr->sa_ip, cp, sizeof(afs_int32));
+ memcpy(cp, (char *)&ts->addr->sa_ip, sizeof(afs_int32));
cp += sizeof(afs_int32);
}
}
return 0;
}
-static PCheckVolNames(avc, afun, areq, ain, aout, ainSize, aoutSize)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */ {
+DECL_PIOCTL(PCheckVolNames)
+{
AFS_STATCNT(PCheckVolNames);
if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
return EIO; /* Inappropriate ioctl for device */
return 0;
}
-static PCheckAuth(avc, afun, areq, ain, aout, ainSize, aoutSize)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */ {
+DECL_PIOCTL(PCheckAuth)
+{
int i;
struct srvAddr *sa;
struct conn *tc;
struct unixuser *tu;
afs_int32 retValue;
- extern afs_rwlock_t afs_xsrvAddr;
AFS_STATCNT(PCheckAuth);
if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
ReleaseReadLock(&afs_xconn);
afs_PutUser(tu, READ_LOCK);
}
- bcopy((char *)&retValue, aout, sizeof(afs_int32));
+ memcpy(aout, (char *)&retValue, sizeof(afs_int32));
*aoutSize = sizeof(afs_int32);
return 0;
}
-static Prefetch(apath, adata, afollow, acred)
-char *apath;
-struct afs_ioctl *adata;
-int afollow;
-struct AFS_UCRED *acred;
+static int Prefetch(char *apath, struct afs_ioctl *adata, int afollow, struct AFS_UCRED *acred)
{
register char *tp;
register afs_int32 code;
+#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+ size_t bufferSize;
+#else
u_int bufferSize;
+#endif
AFS_STATCNT(Prefetch);
if (!apath) return EINVAL;
osi_FreeLargeSpace(tp);
return EWOULDBLOCK; /* pretty close */
}
- afs_BQueue(BOP_PATH, (struct vcache*)0, 0, 0, acred, (long)tp, 0L, 0L, 0L);
+ afs_BQueue(BOP_PATH, (struct vcache*)0, 0, 0, acred,
+ (afs_size_t) 0, (afs_size_t) 0, tp);
return 0;
}
-static PFindVolume(avc, afun, areq, ain, aout, ainSize, aoutSize)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */ {
+DECL_PIOCTL(PFindVolume)
+{
register struct volume *tvp;
register struct server *ts;
register afs_int32 i;
for(i=0;i<MAXHOSTS;i++) {
ts = tvp->serverHost[i];
if (!ts) break;
- bcopy((char *)&ts->addr->sa_ip, cp, sizeof(afs_int32));
+ memcpy(cp, (char *)&ts->addr->sa_ip, sizeof(afs_int32));
cp += sizeof(afs_int32);
}
if (i<MAXHOSTS) {
/* still room for terminating NULL, add it on */
ainSize = 0; /* reuse vbl */
- bcopy((char *)&ainSize, cp, sizeof(afs_int32));
+ memcpy(cp, (char *)&ainSize, sizeof(afs_int32));
cp += sizeof(afs_int32);
}
*aoutSize = cp - aout;
return ENODEV;
}
-static PViceAccess(avc, afun, areq, ain, aout, ainSize, aoutSize)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */ {
+DECL_PIOCTL(PViceAccess)
+{
register afs_int32 code;
afs_int32 temp;
if (!avc) return EINVAL;
code = afs_VerifyVCache(avc, areq);
if (code) return code;
- bcopy(ain, (char *)&temp, sizeof(afs_int32));
+ memcpy((char *)&temp, ain, sizeof(afs_int32));
code = afs_AccessOK(avc,temp, areq, CHECK_MODE_BITS);
if (code) return 0;
else return EACCES;
}
-static PSetCacheSize(avc, afun, areq, ain, aout, ainSize, aoutSize, acred)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */
- struct AFS_UCRED *acred;
-{
+DECL_PIOCTL(PSetCacheSize)
+{
afs_int32 newValue;
int waitcnt = 0;
AFS_STATCNT(PSetCacheSize);
- if (!afs_osi_suser(acred))
+ if (!afs_osi_suser(*acred))
return EACCES;
/* too many things are setup initially in mem cache version */
if (cacheDiskType == AFS_FCACHE_TYPE_MEM) return EROFS;
- bcopy(ain, (char *)&newValue, sizeof(afs_int32));
+ memcpy((char *)&newValue, ain, sizeof(afs_int32));
if (newValue == 0) afs_cacheBlocks = afs_stats_cmperf.cacheBlocksOrig;
else {
- extern u_int afs_min_cache;
if (newValue < afs_min_cache)
afs_cacheBlocks = afs_min_cache;
else
}
#define MAXGCSTATS 16
-static PGetCacheSize(avc, afun, areq, ain, aout, ainSize, aoutSize)
-struct vcache *avc;
-int afun;
-struct vrequest *areq;
-char *ain, *aout;
-afs_int32 ainSize;
-afs_int32 *aoutSize; /* set this */ {
+DECL_PIOCTL(PGetCacheSize)
+{
afs_int32 results[MAXGCSTATS];
AFS_STATCNT(PGetCacheSize);
- bzero((char *)results, sizeof(results));
+ memset((char *)results, 0, sizeof(results));
results[0] = afs_cacheBlocks;
results[1] = afs_blocksUsed;
- bcopy((char *)results, aout, sizeof(results));
+ memcpy(aout, (char *)results, sizeof(results));
*aoutSize = sizeof(results);
return 0;
}
-static PRemoveCallBack(avc, afun, areq, ain, aout, ainSize, aoutSize)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */ {
+DECL_PIOCTL(PRemoveCallBack)
+{
register struct conn *tc;
- register afs_int32 code;
+ register afs_int32 code = 0;
struct AFSCallBack CallBacks_Array[1];
struct AFSCBFids theFids;
struct AFSCBs theCBs;
tc = afs_Conn(&avc->fid, areq, SHARED_LOCK);
if (tc) {
XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_GIVEUPCALLBACKS);
-#ifdef RX_ENABLE_LOCKS
- AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GUNLOCK();
code = RXAFS_GiveUpCallBacks(tc->id, &theFids, &theCBs);
-#ifdef RX_ENABLE_LOCKS
- AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GLOCK();
XSTATS_END_TIME;
}
/* don't set code on failure since we wouldn't use it */
} while
(afs_Analyze(tc, code, &avc->fid, areq,
AFS_STATS_FS_RPCIDX_GIVEUPCALLBACKS,
- SHARED_LOCK, (struct cell *)0));
+ SHARED_LOCK, NULL));
ObtainWriteLock(&afs_xcbhash, 457);
afs_DequeueCallback(avc);
return 0;
}
-static PNewCell(avc, afun, areq, ain, aout, ainSize, aoutSize, acred)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- register char *ain;
- char *aout;
- afs_int32 ainSize;
- struct AFS_UCRED *acred;
- afs_int32 *aoutSize; /* set this */ {
+DECL_PIOCTL(PNewCell)
+{
/* create a new cell */
afs_int32 cellHosts[MAXCELLHOSTS], *lp, magic=0;
- register struct cell *tcell;
char *newcell=0, *linkedcell=0, *tp= ain;
register afs_int32 code, linkedstate=0, ls;
u_short fsport = 0, vlport = 0;
if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
return EIO; /* Inappropriate ioctl for device */
- if (!afs_osi_suser(acred))
+ if (!afs_osi_suser(*acred))
return EACCES;
- bcopy(tp, (char *)&magic, sizeof(afs_int32));
+ memcpy((char *)&magic, tp, sizeof(afs_int32));
tp += sizeof(afs_int32);
if (magic != 0x12345678)
return EINVAL;
scount = ((newcell[0] != '\0') ? MAXCELLHOSTS : MAXHOSTS);
/* MAXCELLHOSTS (=8) is less than MAXHOSTS (=13) */
- bcopy(tp, (char *)cellHosts, MAXCELLHOSTS * sizeof(afs_int32));
+ memcpy((char *)cellHosts, tp, MAXCELLHOSTS * sizeof(afs_int32));
tp += (scount * sizeof(afs_int32));
lp = (afs_int32 *)tp;
}
linkedstate |= CNoSUID; /* setuid is disabled by default for fs newcell */
- code = afs_NewCell(newcell, cellHosts, linkedstate, linkedcell, fsport, vlport);
+ code = afs_NewCell(newcell, cellHosts, linkedstate, linkedcell, fsport,
+ vlport, (int)0);
+ return code;
+}
+
+DECL_PIOCTL(PNewAlias)
+{
+ /* create a new cell alias */
+ char *tp = ain;
+ register afs_int32 code;
+ char *realName, *aliasName;
+
+ if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ return EIO; /* Inappropriate ioctl for device */
+
+ if (!afs_osi_suser(*acred))
+ return EACCES;
+
+ aliasName = tp;
+ tp += strlen(aliasName) + 1;
+ realName = tp;
+
+ code = afs_NewCellAlias(aliasName, realName);
+ *aoutSize = 0;
return code;
}
-static PListCells(avc, afun, areq, ain, aout, ainSize, aoutSize)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */ {
+DECL_PIOCTL(PListCells)
+{
afs_int32 whichCell;
register struct cell *tcell=0;
register afs_int32 i;
register char *cp, *tp = ain;
- register struct afs_q *cq, *tq;
AFS_STATCNT(PListCells);
if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
return EIO; /* Inappropriate ioctl for device */
- bcopy(tp, (char *)&whichCell, sizeof(afs_int32));
+ memcpy((char *)&whichCell, tp, sizeof(afs_int32));
tp += sizeof(afs_int32);
- ObtainReadLock(&afs_xcell);
- for (cq = CellLRU.next; cq != &CellLRU; cq = tq) {
- tcell = QTOC(cq); tq = QNext(cq);
- if (whichCell == 0) break;
- if (tq == &CellLRU) tcell = 0;
- whichCell--;
- }
+ tcell = afs_GetCellByIndex(whichCell, READ_LOCK);
if (tcell) {
cp = aout;
- bzero(cp, MAXCELLHOSTS * sizeof(afs_int32));
+ memset(cp, 0, MAXCELLHOSTS * sizeof(afs_int32));
for(i=0;i<MAXCELLHOSTS;i++) {
if (tcell->cellHosts[i] == 0) break;
- bcopy((char *)&tcell->cellHosts[i]->addr->sa_ip, cp, sizeof(afs_int32));
+ memcpy(cp, (char *)&tcell->cellHosts[i]->addr->sa_ip, sizeof(afs_int32));
cp += sizeof(afs_int32);
}
cp = aout + MAXCELLHOSTS * sizeof(afs_int32);
strcpy(cp, tcell->cellName);
cp += strlen(tcell->cellName)+1;
*aoutSize = cp - aout;
+ afs_PutCell(tcell, READ_LOCK);
}
- ReleaseReadLock(&afs_xcell);
if (tcell) return 0;
else return EDOM;
}
-static PRemoveMount(avc, afun, areq, ain, aout, ainSize, aoutSize)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- register char *ain;
- char *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */ {
+DECL_PIOCTL(PListAliases)
+{
+ afs_int32 whichAlias;
+ register struct cell_alias *tcalias=0;
+ register char *cp, *tp = ain;
+
+ if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ return EIO; /* Inappropriate ioctl for device */
+ if (ainSize < sizeof(afs_int32))
+ return EINVAL;
+
+ memcpy((char *)&whichAlias, tp, sizeof(afs_int32));
+ tp += sizeof(afs_int32);
+
+ tcalias = afs_GetCellAlias(whichAlias);
+ if (tcalias) {
+ cp = aout;
+ strcpy(cp, tcalias->alias);
+ cp += strlen(tcalias->alias)+1;
+ strcpy(cp, tcalias->cell);
+ cp += strlen(tcalias->cell)+1;
+ *aoutSize = cp - aout;
+ afs_PutCellAlias(tcalias);
+ }
+ if (tcalias) return 0;
+ else return EDOM;
+}
+
+DECL_PIOCTL(PRemoveMount)
+{
register afs_int32 code;
- char *bufp = 0;
- afs_int32 offset, len, hasatsys = 0;
+ char *bufp;
+ struct sysname_info sysState;
+ afs_size_t offset, len;
register struct conn *tc;
register struct dcache *tdc;
register struct vcache *tvc;
if (code) return code;
if (vType(avc) != VDIR) return ENOTDIR;
- tdc = afs_GetDCache(avc, 0, areq, &offset, &len, 1); /* test for error below */
+ tdc = afs_GetDCache(avc, (afs_size_t) 0, areq, &offset, &len, 1); /* test for error below */
if (!tdc) return ENOENT;
- hasatsys = Check_AtSys(avc, ain, &bufp, areq);
- code = afs_dir_Lookup(&tdc->f.inode, bufp, &tfid.Fid);
+ Check_AtSys(avc, ain, &sysState, areq);
+ ObtainReadLock(&tdc->lock);
+ do {
+ code = afs_dir_Lookup(&tdc->f.inode, sysState.name, &tfid.Fid);
+ } while (code == ENOENT && Next_AtSys(avc, areq, &sysState));
+ ReleaseReadLock(&tdc->lock);
+ bufp = sysState.name;
if (code) {
afs_PutDCache(tdc);
goto out;
tfid.Cell = avc->fid.Cell;
tfid.Fid.Volume = avc->fid.Fid.Volume;
if (!tfid.Fid.Unique && (avc->states & CForeign)) {
- tvc = afs_LookupVCache(&tfid, areq, (afs_int32 *)0, WRITE_LOCK, avc, bufp);
+ tvc = afs_LookupVCache(&tfid, areq, NULL, avc, bufp);
} else {
- tvc = afs_GetVCache(&tfid, areq, (afs_int32 *)0,
- (struct vcache*)0/*xxx avc?*/, WRITE_LOCK);
+ tvc = afs_GetVCache(&tfid, areq, NULL, NULL);
}
if (!tvc) {
code = ENOENT;
afs_PutDCache(tdc);
goto out;
}
- if (vType(tvc) != VLNK) {
+ if (tvc->mvstat != 1) {
afs_PutDCache(tdc);
- afs_PutVCache(tvc, WRITE_LOCK);
+ afs_PutVCache(tvc);
code = EINVAL;
goto out;
}
}
ReleaseWriteLock(&tvc->lock);
osi_dnlc_purgedp(tvc);
- afs_PutVCache(tvc, WRITE_LOCK);
+ afs_PutVCache(tvc);
if (code) {
afs_PutDCache(tdc);
goto out;
tc = afs_Conn(&avc->fid, areq, SHARED_LOCK);
if (tc) {
XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_REMOVEFILE);
-#ifdef RX_ENABLE_LOCKS
- AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GUNLOCK();
code = RXAFS_RemoveFile(tc->id, (struct AFSFid *) &avc->fid.Fid,
bufp, &OutDirStatus, &tsync);
-#ifdef RX_ENABLE_LOCKS
- AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
+ RX_AFS_GLOCK();
XSTATS_END_TIME;
}
else code = -1;
} while
(afs_Analyze(tc, code, &avc->fid, areq,
AFS_STATS_FS_RPCIDX_REMOVEFILE,
- SHARED_LOCK, (struct cell *)0));
+ SHARED_LOCK, NULL));
if (code) {
if (tdc) afs_PutDCache(tdc);
}
if (tdc) {
/* we have the thing in the cache */
+ ObtainWriteLock(&tdc->lock, 661);
if (afs_LocalHero(avc, tdc, &OutDirStatus, 1)) {
/* we can do it locally */
code = afs_dir_Delete(&tdc->f.inode, bufp);
DZap(&tdc->f.inode);
}
}
+ ReleaseWriteLock(&tdc->lock);
afs_PutDCache(tdc); /* drop ref count */
}
avc->states &= ~CUnique; /* For the dfs xlator */
ReleaseWriteLock(&avc->lock);
code = 0;
out:
- if (hasatsys) osi_FreeLargeSpace(bufp);
+ if (sysState.allocked) osi_FreeLargeSpace(bufp);
return code;
}
-static PVenusLogging(avc, afun, areq, ain, aout, ainSize, aoutSize, acred)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- register char *ain;
- char *aout;
- afs_int32 ainSize;
- struct AFS_UCRED *acred;
- afs_int32 *aoutSize; /* set this */ {
+DECL_PIOCTL(PVenusLogging)
+{
return EINVAL; /* OBSOLETE */
}
-static PGetCellStatus(avc, afun, areq, ain, aout, ainSize, aoutSize)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */ {
+DECL_PIOCTL(PGetCellStatus)
+{
register struct cell *tcell;
afs_int32 temp;
if (!tcell) return ENOENT;
temp = tcell->states;
afs_PutCell(tcell, READ_LOCK);
- bcopy((char *)&temp, aout, sizeof(afs_int32));
+ memcpy(aout, (char *)&temp, sizeof(afs_int32));
*aoutSize = sizeof(afs_int32);
return 0;
}
-static PSetCellStatus(avc, afun, areq, ain, aout, ainSize, aoutSize, acred)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- struct AFS_UCRED *acred;
- afs_int32 *aoutSize; /* set this */ {
+DECL_PIOCTL(PSetCellStatus)
+{
register struct cell *tcell;
afs_int32 temp;
- if (!afs_osi_suser(acred))
+ if (!afs_osi_suser(*acred))
return EACCES;
if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
return EIO; /* Inappropriate ioctl for device */
tcell = afs_GetCellByName(ain+2*sizeof(afs_int32), WRITE_LOCK);
if (!tcell) return ENOENT;
- bcopy(ain, (char *)&temp, sizeof(afs_int32));
+ memcpy((char *)&temp, ain, sizeof(afs_int32));
if (temp & CNoSUID)
tcell->states |= CNoSUID;
else
return 0;
}
-static PFlushVolumeData(avc, afun, areq, ain, aout, ainSize, aoutSize, acred)
-struct vcache *avc;
-int afun;
-struct vrequest *areq;
-char *ain, *aout;
-afs_int32 ainSize;
-afs_int32 *aoutSize; /* set this */
-struct AFS_UCRED *acred;
+DECL_PIOCTL(PFlushVolumeData)
{
- extern struct volume *afs_volumes[NVOLS];
register afs_int32 i;
register struct dcache *tdc;
register struct vcache *tvc;
for(i = 0; i < VCSIZE; i++) {
for(tvc = afs_vhashT[i]; tvc; tvc=tvc->hnext) {
if (tvc->fid.Fid.Volume == volume && tvc->fid.Cell == cell) {
-#if defined(AFS_SGI_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV)
- VN_HOLD((struct vnode *)tvc);
+#if defined(AFS_SGI_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV)
+ VN_HOLD(AFSTOV(tvc));
#else
- tvc->vrefCount++;
+#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+ osi_vnhold(tvc, 0);
+#else
+ VREFCOUNT_INC(tvc);
+#endif
#endif
ReleaseReadLock(&afs_xvcache);
#if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV)
ReleaseWriteLock(&afs_xcbhash);
if (tvc->fid.Fid.Vnode & 1 || (vType(tvc) == VDIR))
osi_dnlc_purgedp(tvc);
- afs_TryToSmush(tvc, acred, 1);
+ afs_TryToSmush(tvc, *acred, 1);
ReleaseWriteLock(&tvc->lock);
#if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV)
afs_BozonUnlock(&tvc->pvnLock, tvc);
MObtainWriteLock(&afs_xdcache,328); /* needed if you're going to flush any stuff */
for(i=0;i<afs_cacheFiles;i++) {
if (!(afs_indexFlags[i] & IFEverUsed)) continue; /* never had any data */
- tdc = afs_GetDSlot(i, (struct dcache *) 0);
+ tdc = afs_GetDSlot(i, NULL);
if (tdc->refCount <= 1) { /* too high, in use by running sys call */
+ ReleaseReadLock(&tdc->tlock);
if (tdc->f.fid.Fid.Volume == volume && tdc->f.fid.Cell == cell) {
if (! (afs_indexFlags[i] & IFDataMod)) {
/* if the file is modified, but has a ref cnt of only 1, then
afs_FlushDCache(tdc);
}
}
+ } else {
+ ReleaseReadLock(&tdc->tlock);
}
- tdc->refCount--; /* bumped by getdslot */
+ afs_PutDCache(tdc); /* bumped by getdslot */
}
MReleaseWriteLock(&afs_xdcache);
-static PGetVnodeXStatus(avc, afun, areq, ain, aout, ainSize, aoutSize)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */ {
+DECL_PIOCTL(PGetVnodeXStatus)
+{
register afs_int32 code;
struct vcxstat stat;
afs_int32 mode, i;
stat.flockCount = avc->flockCount;
stat.mvstat = avc->mvstat;
stat.states = avc->states;
- bcopy((char *)&stat, aout, sizeof(struct vcxstat));
+ memcpy(aout, (char *)&stat, sizeof(struct vcxstat));
*aoutSize = sizeof(struct vcxstat);
return 0;
}
/* (since we don't really believe remote uids anyway) */
/* outname[] shouldn't really be needed- this is left as an excercise */
/* for the reader. */
-
-static PSetSysName(avc, afun, areq, ain, aout, ainSize, aoutSize, acred)
-struct vcache *avc;
-int afun;
-struct vrequest *areq;
-char *ain, *aout;
-afs_int32 ainSize;
-afs_int32 *aoutSize; /* set this */
-register struct AFS_UCRED *acred;
+DECL_PIOCTL(PSetSysName)
{
char *cp, inname[MAXSYSNAME], outname[MAXSYSNAME];
int setsysname, foundname=0;
register struct afs_exporter *exporter;
- extern struct unixuser *afs_FindUser();
- extern char *afs_sysname;
register struct unixuser *au;
register afs_int32 pag, error;
- int t;
+ int t, count;
AFS_STATCNT(PSetSysName);
if (!afs_globalVFS) {
/* Afsd is NOT running; disable it */
-#if defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SGI64_ENV) || defined(AFS_LINUX22_ENV)
- return (EINVAL);
-#else
+#if defined(KERNEL_HAVE_UERROR)
return (setuerror(EINVAL), EINVAL);
+#else
+ return (EINVAL);
#endif
}
- bzero(inname, MAXSYSNAME);
- bcopy(ain, (char *)&setsysname, sizeof(afs_int32));
+ memset(inname, 0, MAXSYSNAME);
+ memcpy((char *)&setsysname, ain, sizeof(afs_int32));
ain += sizeof(afs_int32);
if (setsysname) {
- t = strlen(ain);
- if (t > MAXSYSNAME)
+
+ /* Check my args */
+ if (setsysname < 0 || setsysname > MAXNUMSYSNAMES)
return EINVAL;
- bcopy(ain, inname, t+1); /* include terminating null */
+ for(cp = ain,count = 0;count < setsysname;count++) {
+ /* won't go past end of ain since maxsysname*num < ain length */
+ t = strlen(cp);
+ if (t >= MAXSYSNAME || t <= 0)
+ return EINVAL;
+ /* check for names that can shoot us in the foot */
+ if (*cp == '.' && (cp[1] == 0 || (cp[1] == '.' && cp[2] == 0)))
+ return EINVAL;
+ cp += t+1;
+ }
+ /* args ok */
+
+ /* inname gets first entry in case we're being a translater */
+ t = strlen(ain);
+ memcpy(inname, ain, t+1); /* include terminating null */
ain += t + 1;
}
- if (acred->cr_gid == RMTUSER_REQ) { /* Handles all exporters */
- pag = PagInCred(acred);
+ if ((*acred)->cr_gid == RMTUSER_REQ) { /* Handles all exporters */
+ pag = PagInCred(*acred);
if (pag == NOPAG) {
return EINVAL; /* Better than panicing */
}
afs_PutUser(au, READ_LOCK);
return EINVAL; /* Better than panicing */
}
- error = EXP_SYSNAME(exporter, (setsysname? inname : (char *)0), outname);
+ error = EXP_SYSNAME(exporter, (setsysname? inname : NULL), outname);
if (error) {
if (error == ENODEV) foundname = 0; /* sysname not set yet! */
else {
else foundname = 1;
afs_PutUser(au, READ_LOCK);
} else {
+
+ /* Not xlating, so local case */
if (!afs_sysname) osi_Panic("PSetSysName: !afs_sysname\n");
- if (!setsysname) {
+ if (!setsysname) { /* user just wants the info */
strcpy(outname, afs_sysname);
- foundname = 1;
- } else {
- if (!afs_osi_suser(acred)) /* Local guy; only root can change sysname */
+ foundname = afs_sysnamecount;
+ } else { /* Local guy; only root can change sysname */
+ if (!afs_osi_suser(*acred))
return EACCES;
+
+ /* clear @sys entries from the dnlc, once afs_lookup can
+ do lookups of @sys entries and thinks it can trust them */
+ /* privs ok, store the entry, ... */
strcpy(afs_sysname, inname);
+ if (setsysname > 1) { /* ... or list */
+ cp = ain;
+ for(count=1; count < setsysname;++count) {
+ if (!afs_sysnamelist[count])
+ osi_Panic("PSetSysName: no afs_sysnamelist entry to write\n");
+ t = strlen(cp);
+ memcpy(afs_sysnamelist[count], cp, t+1); /* include null */
+ cp += t+1;
+ }
+ }
+ afs_sysnamecount = setsysname;
}
}
if (!setsysname) {
- cp = aout;
- bcopy((char *)&foundname, cp, sizeof(afs_int32));
+ cp = aout; /* not changing so report back the count and ... */
+ memcpy(cp, (char *)&foundname, sizeof(afs_int32));
cp += sizeof(afs_int32);
if (foundname) {
- strcpy(cp, outname);
+ strcpy(cp, outname); /* ... the entry, ... */
cp += strlen(outname)+1;
+ for(count=1; count < foundname; ++count) { /* ... or list. */
+ /* Note: we don't support @sys lists for exporters */
+ if (!afs_sysnamelist[count])
+ osi_Panic("PSetSysName: no afs_sysnamelist entry to read\n");
+ t = strlen(afs_sysnamelist[count]);
+ if (t >= MAXSYSNAME)
+ osi_Panic("PSetSysName: sysname entry garbled\n");
+ strcpy(cp, afs_sysnamelist[count]);
+ cp += t + 1;
+ }
}
*aoutSize = cp - aout;
}
* long-term solution here. For small n, though, it should be just
* fine. Should consider special-casing the local cell for large n.
* Likewise for PSetSPrefs.
+ *
+ * s - number of ids in array l[] -- NOT index of last id
+ * l - array of cell ids which have volumes that need to be sorted
+ * vlonly - sort vl servers or file servers?
*/
-static void ReSortCells(s,l, vlonly)
- int s; /* number of ids in array l[] -- NOT index of last id */
- afs_int32 l[]; /* array of cell ids which have volumes that need to be sorted */
- int vlonly; /* sort vl servers or file servers?*/
-{
- extern struct volume *afs_volumes[NVOLS]; /* volume hash table */
-
- int i;
- struct volume *j;
- register int k;
-
- if (vlonly) {
- struct cell *tcell;
- for(k=0;k<s;k++) {
- tcell = afs_GetCell(l[k], WRITE_LOCK);
- if (!tcell) continue;
- afs_SortServers(tcell->cellHosts, MAXCELLHOSTS);
- afs_PutCell(tcell, WRITE_LOCK);
- }
- return;
- }
+static void *ReSortCells_cb(struct cell *cell, void *arg)
+{
+ afs_int32 *p = (afs_int32 *) arg;
+ afs_int32 *l = p + 1;
+ int i, s = p[0];
+
+ for (i=0; i<s; i++) {
+ if (l[i] == cell->cellNum) {
+ ObtainWriteLock(&cell->lock, 690);
+ afs_SortServers(cell->cellHosts, MAXCELLHOSTS);
+ ReleaseWriteLock(&cell->lock);
+ }
+ }
- ObtainReadLock(&afs_xvolume);
- for (i= 0; i< NVOLS; i++) {
- for (j=afs_volumes[i];j;j=j->next) {
- for (k=0;k<s;k++)
- if (j->cell == l[k]) {
- ObtainWriteLock(&j->lock,233);
- afs_SortServers(j->serverHost, MAXHOSTS);
- ReleaseWriteLock(&j->lock);
- break;
- }
- }
- }
- ReleaseReadLock(&afs_xvolume);
+ return NULL;
}
-int debugsetsp = 0;
+static void ReSortCells(int s, afs_int32 *l, int vlonly)
+{
+ int i;
+ struct volume *j;
+ register int k;
+
+ if (vlonly) {
+ afs_int32 *p;
+ p = (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * (s+1));
+ p[0] = s;
+ memcpy(p+1, l, s * sizeof(afs_int32));
+ afs_TraverseCells(&ReSortCells_cb, p);
+ afs_osi_Free(p, sizeof(afs_int32) * (s+1));
+ return;
+ }
+ ObtainReadLock(&afs_xvolume);
+ for (i= 0; i< NVOLS; i++) {
+ for (j=afs_volumes[i];j;j=j->next) {
+ for (k=0;k<s;k++)
+ if (j->cell == l[k]) {
+ ObtainWriteLock(&j->lock,233);
+ afs_SortServers(j->serverHost, MAXHOSTS);
+ ReleaseWriteLock(&j->lock);
+ break;
+ }
+ }
+ }
+ ReleaseReadLock(&afs_xvolume);
+}
+
+
+static int debugsetsp = 0;
static int afs_setsprefs(sp, num, vlonly)
struct spref *sp;
unsigned int num;
if (srvr->cell) {
/* if we don't know yet what cell it's in, this is moot */
- for (j=touchedSize-1; j>=0 && touched[j] != srvr->cell->cell; j--)
+ for (j=touchedSize-1; j>=0 && touched[j] != srvr->cell->cellNum; j--)
/* is it in our list of touched cells ? */ ;
if (j < 0) { /* no, it's not */
- touched[touchedSize++] = srvr->cell->cell;
+ touched[touchedSize++] = srvr->cell->cellNum;
if (touchedSize >= 32) { /* watch for ovrflow */
ReleaseReadLock(&afs_xserver);
ReSortCells(touchedSize, touched, vlonly);
/* Note that it doesn't have a cell yet... */
if (!matches) {
afs_uint32 temp = sp->host.s_addr;
- srvr = afs_GetServer(&temp, 1, NULL, (vlonly ? AFS_VLPORT : AFS_FSPORT),
+ srvr = afs_GetServer(&temp, 1, 0, (vlonly ? AFS_VLPORT : AFS_FSPORT),
WRITE_LOCK, (afsUUID *)0,0);
srvr->addr->sa_iprank = sp->rank + afs_randomMod15();
afs_PutServer(srvr, WRITE_LOCK);
/* Note that this may only be performed by the local root user.
*/
-static int
-PSetSPrefs(avc, afun, areq, ain, aout, ainSize, aoutSize, acred)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- struct AFS_UCRED *acred;
- afs_int32 *aoutSize;
+DECL_PIOCTL(PSetSPrefs)
{
struct setspref *ssp;
AFS_STATCNT(PSetSPrefs);
if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
return EIO; /* Inappropriate ioctl for device */
- if (!afs_osi_suser(acred))
+ if (!afs_osi_suser(*acred))
return EACCES;
if (ainSize < sizeof(struct setspref))
return 0;
}
-static int
-PSetSPrefs33(avc, afun, areq, ain, aout, ainSize, aoutSize, acred)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- struct AFS_UCRED *acred;
- afs_int32 *aoutSize;
+DECL_PIOCTL(PSetSPrefs33)
{
struct spref *sp;
AFS_STATCNT(PSetSPrefs);
return EIO; /* Inappropriate ioctl for device */
- if (!afs_osi_suser(acred))
+ if (!afs_osi_suser(*acred))
return EACCES;
sp = (struct spref *)ain;
* immediately previous slot in the hash table and some supporting information
* Only reports file servers now.
*/
-static int
- PGetSPrefs(avc, afun, areq, ain, aout, ainSize, aoutSize)
-struct vcache *avc;
-int afun;
-struct vrequest *areq;
-char *ain, *aout;
-afs_int32 ainSize;
-afs_int32 *aoutSize;
+DECL_PIOCTL(PGetSPrefs)
{
struct sprefrequest *spin; /* input */
struct sprefinfo *spout; /* output */
int i,j; /* counters for hash table traversal */
struct server *srvr; /* one of CM's server structs */
struct srvAddr *sa;
- afs_uint32 prevh;
int vlonly; /* just return vlservers ? */
int isfs;
/* Enable/Disable the specified exporter. Must be root to disable an exporter */
int afs_NFSRootOnly = 1;
-/*static*/ PExportAfs(avc, afun, areq, ain, aout, ainSize, aoutSize, acred)
-struct vcache *avc;
-int afun;
-struct vrequest *areq;
-char *ain, *aout;
-afs_int32 ainSize;
-afs_int32 *aoutSize; /* set this */
-struct AFS_UCRED *acred;
+DECL_PIOCTL(PExportAfs)
{
afs_int32 export, newint=0, type, changestate, handleValue, convmode, pwsync, smounts;
- extern struct afs_exporter *exporter_find();
register struct afs_exporter *exporter;
AFS_STATCNT(PExportAfs);
- bcopy(ain, (char *)&handleValue, sizeof(afs_int32));
+ memcpy((char *)&handleValue, ain, sizeof(afs_int32));
type = handleValue >> 24;
if (type == 0x71) {
newint = 1;
}
if (!changestate) {
handleValue = exporter->exp_states;
- bcopy((char *)&handleValue, aout, sizeof(afs_int32));
+ memcpy(aout, (char *)&handleValue, sizeof(afs_int32));
*aoutSize = sizeof(afs_int32);
} else {
- if (!afs_osi_suser(acred))
+ if (!afs_osi_suser(*acred))
return EACCES; /* Only superuser can do this */
if (newint) {
if (export & 2) {
}
}
handleValue = exporter->exp_states;
- bcopy((char *)&handleValue, aout, sizeof(afs_int32));
+ memcpy(aout, (char *)&handleValue, sizeof(afs_int32));
*aoutSize = sizeof(afs_int32);
} else {
if (export)
return 0;
}
-static int
-PGag(avc, afun, areq, ain, aout, ainSize, aoutSize, acred)
-struct vcache *avc;
-int afun;
-struct vrequest *areq;
-char *ain, *aout;
-afs_int32 ainSize;
-struct AFS_UCRED *acred;
-afs_int32 *aoutSize; /* set this */
+DECL_PIOCTL(PGag)
{
struct gaginfo *gagflags;
- if (!afs_osi_suser(acred))
+ if (!afs_osi_suser(*acred))
return EACCES;
gagflags = (struct gaginfo *) ain;
}
-static int
-PTwiddleRx(avc, afun, areq, ain, aout, ainSize, aoutSize, acred)
-struct vcache *avc;
-int afun;
-struct vrequest *areq;
-char *ain, *aout;
-afs_int32 ainSize;
-struct AFS_UCRED *acred;
-afs_int32 *aoutSize;
+DECL_PIOCTL(PTwiddleRx)
{
struct rxparams *rxp;
- if (!afs_osi_suser(acred))
+ if (!afs_osi_suser(*acred))
return EACCES;
rxp = (struct rxparams *) ain;
return 0;
}
-static int PGetInitParams(avc, afun, areq, ain, aout, ainSize, aoutSize)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- register char *ain;
- char *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize; /* set this */
+DECL_PIOCTL(PGetInitParams)
{
if (sizeof(struct cm_initparams) > PIGGYSIZE)
return E2BIG;
- bcopy((char*)&cm_initParams, aout, sizeof(struct cm_initparams));
+ memcpy(aout, (char*)&cm_initParams, sizeof(struct cm_initparams));
*aoutSize = sizeof(struct cm_initparams);
return 0;
}
{
cred_t *cr;
cr = crdup(get_current_cred());
- bzero((char*)cr, sizeof(cred_t));
+ memset((char*)cr, 0, sizeof(cred_t));
#if CELL || CELL_PREPARE
cr->cr_id = -1;
#endif
return cr;
}
#endif
+
+DECL_PIOCTL(PGetRxkcrypt)
+{
+ memcpy(aout, (char *)&cryptall, sizeof(afs_int32));
+ *aoutSize=sizeof(afs_int32);
+ return 0;
+}
+
+DECL_PIOCTL(PSetRxkcrypt)
+{
+ afs_int32 tmpval;
+
+ if (!afs_osi_suser(*acred))
+ return EPERM;
+ if (ainSize != sizeof(afs_int32) || ain == NULL)
+ return EINVAL;
+ memcpy((char *)&tmpval, ain, sizeof(afs_int32));
+ /* if new mappings added later this will need to be changed */
+ if (tmpval != 0 && tmpval != 1)
+ return EINVAL;
+ cryptall = tmpval;
+ return 0;
+}
+
/*
* Create new credentials to correspond to a remote user with given
* <hostaddr, uid, g0, g1>. This allows a server running as root to
#define PIOCTL_HEADER 6
static int HandleClientContext(struct afs_ioctl *ablob, int *com, struct AFS_UCRED **acred, struct AFS_UCRED *credp)
{
+#if defined(AFS_DEC_ENV) || (defined(AFS_NONFSTRANS) && !defined(AFS_AIX_IAUTH_ENV))
+ return EINVAL; /* NFS trans not supported for Ultrix */
+#else
char *ain, *inData;
afs_uint32 hostaddr;
afs_int32 uid, g0, g1, i, code, pag, exporter_type;
- extern struct afs_exporter *exporter_find();
struct afs_exporter *exporter, *outexporter;
struct AFS_UCRED *newcred;
struct unixuser *au;
-#if defined(AFS_DEC_ENV) || (defined(AFS_NONFSTRANS) && !defined(AFS_AIX_IAUTH_ENV))
- return EINVAL; /* NFS trans not supported for Ultrix */
-#else
#if defined(AFS_SGIMP_ENV)
osi_Assert(ISAFS_GLOCK());
#endif
setuerror(0);
#endif
newcred->cr_gid = RMTUSER_REQ;
+#ifdef AFS_AIX51_ENV
+ newcred->cr_groupset.gs_union.un_groups[0] = g0;
+ newcred->cr_groupset.gs_union.un_groups[1] = g1;
+#else
newcred->cr_groups[0] = g0;
newcred->cr_groups[1] = g1;
+#endif
#ifdef AFS_AIX_ENV
newcred->cr_ngrps = 2;
#else
/* get all interface addresses of this client */
-static int
-PGetCPrefs(avc, afun, areq, ain, aout, ainSize, aoutSize)
-struct vcache *avc;
-int afun;
-struct vrequest *areq;
-char *ain, *aout;
-afs_int32 ainSize;
-afs_int32 *aoutSize;
+DECL_PIOCTL(PGetCPrefs)
{
struct sprefrequest *spin; /* input */
struct sprefinfo *spout; /* output */
return 0;
}
-static int
-PSetCPrefs(avc, afun, areq, ain, aout, ainSize, aoutSize)
-struct vcache *avc;
-int afun;
-struct vrequest *areq;
-char *ain, *aout;
-afs_int32 ainSize;
-afs_int32 *aoutSize;
+DECL_PIOCTL(PSetCPrefs)
{
struct setspref *sin;
int i;
if ( ainSize < sizeof(struct setspref) )
return EINVAL;
+#if 0 /* num_servers is unsigned */
if ( sin->num_servers < 0 )
return EINVAL;
+#endif
if ( sin->num_servers > AFS_MAX_INTERFACE_ADDR)
return ENOMEM;
return 0;
}
-static PFlushMount(avc, afun, areq, ain, aout, ainSize, aoutSize, acred)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize;
- struct AFS_UCRED *acred; {
+DECL_PIOCTL(PFlushMount)
+{
register afs_int32 code;
register struct vcache *tvc;
register struct dcache *tdc;
struct VenusFid tfid;
- char *bufp = 0;
- afs_int32 offset, len, hasatsys=0;
+ char *bufp;
+ struct sysname_info sysState;
+ afs_size_t offset, len;
AFS_STATCNT(PFlushMount);
if (!avc) return EINVAL;
if (vType(avc) != VDIR) {
return ENOTDIR;
}
- tdc = afs_GetDCache(avc, 0, areq, &offset, &len, 1);
+ tdc = afs_GetDCache(avc, (afs_size_t) 0, areq, &offset, &len, 1);
if (!tdc) return ENOENT;
- hasatsys = Check_AtSys(avc, ain, &bufp, areq);
- code = afs_dir_Lookup(&tdc->f.inode, bufp, &tfid.Fid);
+ Check_AtSys(avc, ain, &sysState, areq);
+ ObtainReadLock(&tdc->lock);
+ do {
+ code = afs_dir_Lookup(&tdc->f.inode, sysState.name, &tfid.Fid);
+ } while (code == ENOENT && Next_AtSys(avc, areq, &sysState));
+ ReleaseReadLock(&tdc->lock);
+ afs_PutDCache(tdc); /* we're done with the data */
+ bufp = sysState.name;
if (code) {
- afs_PutDCache(tdc);
goto out;
}
tfid.Cell = avc->fid.Cell;
tfid.Fid.Volume = avc->fid.Fid.Volume;
- afs_PutDCache(tdc); /* we're done with the data */
if (!tfid.Fid.Unique && (avc->states & CForeign)) {
- tvc = afs_LookupVCache(&tfid, areq, (afs_int32 *)0, WRITE_LOCK, avc, bufp);
+ tvc = afs_LookupVCache(&tfid, areq, NULL, avc, bufp);
} else {
- tvc = afs_GetVCache(&tfid, areq, (afs_int32 *)0, (struct vcache*)0,
- WRITE_LOCK);
+ tvc = afs_GetVCache(&tfid, areq, NULL, NULL);
}
if (!tvc) {
code = ENOENT;
goto out;
}
- if (vType(tvc) != VLNK) {
- afs_PutVCache(tvc, WRITE_LOCK);
+ if (tvc->mvstat != 1) {
+ afs_PutVCache(tvc);
code = EINVAL;
goto out;
}
#if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV)
afs_BozonLock(&tvc->pvnLock, tvc); /* Since afs_TryToSmush will do a pvn_vptrunc */
#endif
- ObtainWriteLock(&tvc->lock,645);
- ObtainWriteLock(&afs_xcbhash, 646);
+ ObtainWriteLock(&tvc->lock,649);
+ ObtainWriteLock(&afs_xcbhash, 650);
afs_DequeueCallback(tvc);
tvc->states &= ~(CStatd | CDirty); /* next reference will re-stat cache entry */
ReleaseWriteLock(&afs_xcbhash);
/* now find the disk cache entries */
- afs_TryToSmush(tvc, acred, 1);
+ afs_TryToSmush(tvc, *acred, 1);
osi_dnlc_purgedp(tvc);
afs_symhint_inval(tvc);
if (tvc->linkData && !(tvc->states & CCore)) {
afs_osi_Free(tvc->linkData, strlen(tvc->linkData)+1);
- tvc->linkData = (char *) 0;
+ tvc->linkData = NULL;
}
ReleaseWriteLock(&tvc->lock);
#if defined(AFS_SUN_ENV) || defined(AFS_ALPHA_ENV) || defined(AFS_SUN5_ENV)
afs_BozonUnlock(&tvc->pvnLock, tvc);
#endif
- afs_PutVCache(tvc, WRITE_LOCK);
+ afs_PutVCache(tvc);
out:
- if (hasatsys) osi_FreeLargeSpace(bufp);
+ if (sysState.allocked) osi_FreeLargeSpace(bufp);
return code;
}
-static PRxStatProc(avc, afun, areq, ain, aout, ainSize, aoutSize, acred)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize;
- struct AFS_UCRED *acred;
+DECL_PIOCTL(PRxStatProc)
{
int code = 0;
afs_int32 flags;
- if (!afs_osi_suser(acred)) {
+ if (!afs_osi_suser(*acred)) {
code = EACCES;
goto out;
}
code = EINVAL;
goto out;
}
- bcopy(ain, (char *)&flags, sizeof(afs_int32));
+ memcpy((char *)&flags, ain, sizeof(afs_int32));
if (!(flags & AFSCALL_RXSTATS_MASK) || (flags & ~AFSCALL_RXSTATS_MASK)) {
code = EINVAL;
goto out;
}
-static PRxStatPeer(avc, afun, areq, ain, aout, ainSize, aoutSize, acred)
- struct vcache *avc;
- int afun;
- struct vrequest *areq;
- char *ain, *aout;
- afs_int32 ainSize;
- afs_int32 *aoutSize;
- struct AFS_UCRED *acred;
+DECL_PIOCTL(PRxStatPeer)
{
int code = 0;
afs_int32 flags;
- if (!afs_osi_suser(acred)) {
+ if (!afs_osi_suser(*acred)) {
code = EACCES;
goto out;
}
code = EINVAL;
goto out;
}
- bcopy(ain, (char *)&flags, sizeof(afs_int32));
+ memcpy((char *)&flags, ain, sizeof(afs_int32));
if (!(flags & AFSCALL_RXSTATS_MASK) || (flags & ~AFSCALL_RXSTATS_MASK)) {
code = EINVAL;
goto out;
return code;
}
+DECL_PIOCTL(PPrefetchFromTape)
+{
+ register afs_int32 code, code1;
+ afs_int32 bytes;
+ struct conn *tc;
+ struct rx_call *tcall;
+ struct AFSVolSync tsync;
+ struct AFSFetchStatus OutStatus;
+ struct AFSCallBack CallBack;
+ struct VenusFid tfid;
+ struct AFSFid *Fid;
+ struct vcache *tvc;
+
+ AFS_STATCNT(PSetAcl);
+ if (!avc)
+ return EINVAL;
+
+ if (ain && (ainSize == 3 * sizeof(afs_int32)))
+ Fid = (struct AFSFid *) ain;
+ else
+ Fid = &avc->fid.Fid;
+ tfid.Cell = avc->fid.Cell;
+ tfid.Fid.Volume = Fid->Volume;
+ tfid.Fid.Vnode = Fid->Vnode;
+ tfid.Fid.Unique = Fid->Unique;
+
+ tvc = afs_GetVCache(&tfid, areq, NULL, NULL);
+ if (!tvc) {
+ afs_Trace3(afs_iclSetp, CM_TRACE_PREFETCHCMD,
+ ICL_TYPE_POINTER, tvc,
+ ICL_TYPE_FID, &tfid,
+ ICL_TYPE_FID, &avc->fid);
+ return ENOENT;
+ }
+ afs_Trace3(afs_iclSetp, CM_TRACE_PREFETCHCMD,
+ ICL_TYPE_POINTER, tvc,
+ ICL_TYPE_FID, &tfid,
+ ICL_TYPE_FID, &tvc->fid);
+
+ do {
+ tc = afs_Conn(&tvc->fid, areq, SHARED_LOCK);
+ if (tc) {
+
+ RX_AFS_GUNLOCK();
+ tcall = rx_NewCall(tc->id);
+ code = StartRXAFS_FetchData(tcall,
+ (struct AFSFid *) &tvc->fid.Fid, 0, 0);
+ if (!code) {
+ bytes = rx_Read(tcall, (char *) aout, sizeof(afs_int32));
+ code = EndRXAFS_FetchData(tcall, &OutStatus, &CallBack, &tsync);
+ }
+ code1 = rx_EndCall(tcall, code);
+ RX_AFS_GLOCK();
+ } else
+ code = -1;
+ } while
+ (afs_Analyze(tc, code, &tvc->fid, areq,
+ AFS_STATS_FS_RPCIDX_RESIDENCYRPCS, SHARED_LOCK,
+ NULL));
+ /* This call is done only to have the callback things handled correctly */
+ afs_FetchStatus(tvc, &tfid, areq, &OutStatus);
+ afs_PutVCache(tvc);
+
+ if (!code) {
+ *aoutSize = sizeof(afs_int32);
+ }
+ return code;
+}
+
+DECL_PIOCTL(PResidencyCmd)
+{
+ register afs_int32 code;
+ struct conn *tc;
+ struct vcache *tvc;
+ struct ResidencyCmdInputs *Inputs;
+ struct ResidencyCmdOutputs *Outputs;
+ struct VenusFid tfid;
+ struct AFSFid *Fid;
+
+ Inputs = (struct ResidencyCmdInputs *) ain;
+ Outputs = (struct ResidencyCmdOutputs *) aout;
+ if (!avc) return EINVAL;
+ if (!ain || ainSize != sizeof(struct ResidencyCmdInputs)) return EINVAL;
+
+ Fid = &Inputs->fid;
+ if (!Fid->Volume)
+ Fid = &avc->fid.Fid;
+
+ tfid.Cell = avc->fid.Cell;
+ tfid.Fid.Volume = Fid->Volume;
+ tfid.Fid.Vnode = Fid->Vnode;
+ tfid.Fid.Unique = Fid->Unique;
+
+ tvc = afs_GetVCache(&tfid, areq, NULL, NULL);
+ afs_Trace3(afs_iclSetp, CM_TRACE_RESIDCMD,
+ ICL_TYPE_POINTER, tvc,
+ ICL_TYPE_INT32, Inputs->command,
+ ICL_TYPE_FID, &tfid);
+ if (!tvc)
+ return ENOENT;
+
+ if (Inputs->command) {
+ do {
+ tc = afs_Conn(&tvc->fid, areq, SHARED_LOCK);
+ if (tc) {
+ RX_AFS_GUNLOCK();
+ code = RXAFS_ResidencyCmd(tc->id, Fid,
+ Inputs,
+ (struct ResidencyCmdOutputs *) aout);
+ RX_AFS_GLOCK();
+ } else
+ code = -1;
+ } while
+ (afs_Analyze(tc, code, &tvc->fid, areq,
+ AFS_STATS_FS_RPCIDX_RESIDENCYRPCS, SHARED_LOCK,
+ NULL));
+ /* This call is done to have the callback things handled correctly */
+ afs_FetchStatus(tvc, &tfid, areq, &Outputs->status);
+ } else { /* just a status request, return also link data */
+ code = 0;
+ Outputs->code = afs_FetchStatus(tvc, &tfid, areq, &Outputs->status);
+ Outputs->chars[0] = 0;
+ if (vType(tvc) == VLNK) {
+ ObtainWriteLock(&tvc->lock,555);
+ if (afs_HandleLink(tvc, areq) == 0)
+ strncpy((char *) &Outputs->chars, tvc->linkData, MAXCMDCHARS);
+ ReleaseWriteLock(&tvc->lock);
+ }
+ }
+
+ afs_PutVCache(tvc);
+
+ if (!code) {
+ *aoutSize = sizeof(struct ResidencyCmdOutputs);
+ }
+ return code;
+}