/*
* Copyright 2000, International Business Machines Corporation and others.
* All Rights Reserved.
- *
+ *
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
*/
#include <afsconfig.h>
-#include "../afs/param.h"
+#include "afs/param.h"
RCSID("$Header$");
-#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"
+#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;
DECL_PIOCTL(PResidencyCmd);
/* Prototypes for private routines */
-static int HandleClientContext(struct afs_ioctl *ablob, int *com,
+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,
+int afs_HandlePioctl(struct vnode *avp, 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);
#ifdef AFS_SPARC64_LINUX24_ENV
if (current->thread.flags & SPARC_FLAG_32BIT)
-#elif AFS_SPARC64_LINUX20_ENV
- if (current->tss.flags & SPARC_FLAG_32BIT)
+#elif defined(AFS_SPARC64_LINUX20_ENV)
+ if (current->tss.flags & SPARC_FLAG_32BIT)
+#elif defined(AFS_AMD64_LINUX20_ENV)
+ if (current->thread.flags & THREAD_IA32)
#else
#error Not done for this linux type
-#endif /* AFS_SPARC64_LINUX20_ENV */
+#endif
{
AFS_COPYIN(cmarg, (caddr_t) &dst32, sizeof dst32, code);
if (!code)
int HandleIoctl(register struct vcache *avc, register afs_int32 acom, struct afs_ioctl *adata)
{
register afs_int32 code;
-
+
code = 0;
AFS_STATCNT(HandleIoctl);
-
+
switch(acom & 0xff) {
case 1:
avc->states |= CSafeStore;
avc->asynchrony = 0;
break;
-
+
/* case 2 used to be abort store, but this is no longer provided,
since it is impossible to implement under normal Unix.
*/
-
+
case 3: {
/* return the name of the cell this file is open on */
register struct cell *tcell;
register afs_int32 i;
-
+
tcell = afs_GetCell(avc->fid.Cell, READ_LOCK);
if (tcell) {
i = strlen(tcell->cellName) + 1; /* bytes to copy out */
else code = ENOTTY;
}
break;
-
+
case 49: /* VIOC_GETINITPARAMS */
if (adata->out_size < sizeof(struct cm_initparams)) {
code = EFAULT;
sizeof(struct cm_initparams), code);
}
break;
-
+
default:
code = EINVAL;
+#ifdef AFS_AIX51_ENV
+ code = ENOSYS;
+#endif
break;
}
return code; /* so far, none implemented */
}
-
-
+
+
#ifdef AFS_AIX_ENV
/* For aix we don't temporarily bypass ioctl(2) but rather do our
* thing directly in the vnode layer call, VNOP_IOCTL; thus afs_ioctl
{
struct afs_ioctl data;
int error = 0;
-
+
AFS_STATCNT(afs_ioctl);
if (((cmd >> 8) & 0xff) == 'V') {
/* This is a VICEIOCTL call */
int locked;
OSI_VN_CONVERT(tvc);
-
+
AFS_STATCNT(afs_ioctl);
if (((cmd >> 8) & 0xff) == 'V') {
/* This is a VICEIOCTL call */
}
#endif /* AFS_SGI_ENV */
-
/* unlike most calls here, this one uses u.u_error to return error conditions,
since this is really an intercepted chapter 2 call, rather than a vnode
interface call.
#ifndef AFS_HPUX102_ENV
#if !defined(AFS_SGI_ENV)
#ifdef AFS_AIX32_ENV
+#ifdef AFS_AIX51_ENV
+#ifdef __64BIT__
+kioctl(fdes, com, arg, ext, arg2, arg3)
+#else /* __64BIT__ */
+kioctl32(fdes, com, arg, ext, arg2, arg3)
+#endif /* __64BIT__ */
+ 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;
int arg;
};
-afs_xioctl (uap, rvp)
+afs_xioctl (uap, rvp)
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 */
-#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
+#elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
struct ioctl_args {
- int fd;
- u_long com;
- caddr_t arg;
+ int fd;
+ u_long com;
+ caddr_t arg;
};
-afs_xioctl(p, uap, retval)
- struct proc *p;
+
+int
+afs_xioctl(p, uap, retval)
+ struct proc *p;
register struct ioctl_args *uap;
register_t *retval;
{
-#else
-#ifdef AFS_LINUX22_ENV
+#elif defined(AFS_LINUX22_ENV)
struct afs_ioctl_sys {
unsigned int com;
unsigned long arg;
{
struct afs_ioctl_sys ua, *uap = &ua;
#else
-int afs_xioctl (void)
- {
- 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_DARWIN_ENV || AFS_FBSD_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) || defined(AFS_DARWIN_ENV)
- struct file *fd;
-#else
- register struct file *fd;
-#endif
-#endif
-#if defined(AFS_FBSD_ENV)
- register struct filedesc *fdp;
-#endif
- register struct vcache *tvc;
- register int ioctlDone = 0, code = 0;
-
- AFS_STATCNT(afs_xioctl);
-#if defined(AFS_FBSD_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;
+#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;
+
+ 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;
+ 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
#endif
#endif
- /* first determine whether this is any sort of vnode */
-#ifdef AFS_LINUX22_ENV
- tvc = VTOAFS(ip);
- {
+ /* 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 = 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 = VTOAFS((struct vnode*)fd->f_data); /* valid, given a vnode */
#endif
#endif /* AFS_LINUX22_ENV */
if (tvc && IsAfsVnode(AFSTOV(tvc))) {
#ifdef AFS_DEC_ENV
- 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_FBSD_ENV)
- return code;
-#else
+ 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
#endif
- }
- code = HandleIoctl(tvc, uap->com, datap);
- osi_FreeSmallSpace(datap);
- AFS_GUNLOCK();
- ioctlDone = 1;
+ }
+ 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;
-#else
+ ufdrele(uap->fd);
+#ifdef AFS_AIX51_ENV
+#ifdef __64BIT__
+ code = okioctl(fdes, com, arg, ext, arg2, arg3);
+#else /* __64BIT__ */
+ code = okioctl32(fdes, com, arg, ext, arg2, arg3);
+#endif /* __64BIT__ */
+#else /* !AFS_AIX51_ENV */
+ code = okioctl(fdes, com, arg, ext);
+#endif /* AFS_AIX51_ENV */
+ return code;
+#else /* !AFS_AIX41_ENV */
#ifdef AFS_AIX32_ENV
- okioctl(fdes, com, arg, ext);
-#else
-#if defined(AFS_SUN5_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);
+ RELEASEF(uap->fd);
#else
- releasef(fd);
+ releasef(fd);
#endif
- code = ioctl(uap, rvp);
-#else
-#if defined(AFS_FBSD_ENV)
+ code = ioctl(uap, rvp);
+#elif defined(AFS_FBSD_ENV)
return ioctl(p, uap);
-#else
-#if defined(AFS_DARWIN_ENV)
+#elif defined(AFS_OBSD_ENV)
+ code = sys_ioctl(p, uap, retval);
+#elif defined(AFS_DARWIN_ENV)
return ioctl(p, uap, retval);
-#else
-#ifdef AFS_OSF_ENV
- code = ioctl(p, args, 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
-#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) && !defined(AFS_DARWIN_ENV) && !defined(AFS_FBSD_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 */
-#if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_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 */
-
+
#if defined(AFS_SGI_ENV)
/* "pioctl" system call entry point; just pass argument to the parameterized
call below */
return u.u_error;
#endif
}
-#endif /* AFS_SGI_ENV */
-#ifdef AFS_OSF_ENV
+#elif defined(AFS_OSF_ENV)
afs_pioctl(p, args, retval)
struct proc *p;
void *args;
return (afs_syscall_pioctl(uap->path, uap->cmd, uap->cmarg, uap->follow));
}
-#else /* AFS_OSF_ENV */
-#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
+#elif defined(AFS_FBSD50_ENV)
+int
+afs_pioctl(td, args, retval)
+ struct thread *td;
+ 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, td->td_ucred));
+}
+
+#elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+int
afs_pioctl(p, args, retval)
struct proc *p;
void *args;
char *path;
int cmd;
caddr_t cmarg;
- int follow;
+ 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_FBSD_ENV)
+#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
afs_syscall_pioctl(path, com, cmarg, follow, credp)
struct AFS_UCRED *credp;
#else
#endif
#endif
char *path;
- unsigned 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
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) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
- return (code);
-#else
+#if defined(KERNEL_HAVE_UERROR)
setuerror(code);
- return code;
#endif
- }
+ return (code);
+ }
if ((com & 0xff) == PSetClientContext) {
#if defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
- return EINVAL; /* Not handling these yet. */
-#else
-#if defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_LINUX22_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
-#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) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_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
- }
- }
+ }
+ }
#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 */
+ /* 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 */
-#endif
-#if !defined(AFS_LINUX22_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_FBSD_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);
+ code = Prefetch(path, &data, follow, osi_curcred());
#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) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_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, NULL, &dp);
#endif /* AFS_AIX41_ENV */
AFS_GLOCK();
if (code) {
-#if !defined(AFS_LINUX22_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_FBSD_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) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
- return (code);
-#else
- return(setuerror(code), code);
+ vp = NULL;
+#if defined(KERNEL_HAVE_UERROR)
+ setuerror(code);
#endif
+ goto rescred;
}
}
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 = NULL;
-#endif
+ /* 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;
-
- 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);
- }
- }
+ {
+ 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);
+ }
+ }
#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
-#if defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_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) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_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) {
#endif
}
+ 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) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
- return (code);
-#else
- if (!getuerror())
+#if defined(KERNEL_HAVE_UERROR)
+ if (!getuerror())
setuerror(code);
return (getuerror());
+#else
+ return (code);
#endif
}
-
-
-int afs_HandlePioctl(struct vcache *avc, afs_int32 acom,
+
+
+int afs_HandlePioctl(struct vnode *avp, afs_int32 acom,
register struct afs_ioctl *ablob, int afollow, struct AFS_UCRED **acred)
{
+ struct vcache *avc;
struct vrequest treq;
register afs_int32 code;
register afs_int32 function, device;
int pioctlSwSize;
struct afs_fakestat_state fakestate;
+ avc = avp ? VTOAFS(avp) : NULL;
afs_Trace3(afs_iclSetp, CM_TRACE_PIOCTL, ICL_TYPE_INT32, acom & 0xff,
ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, afollow);
AFS_STATCNT(HandlePioctl);
}
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;
+ case 'V': /* Original pioctls */
+ pioctlSw = VpioctlSw;
+ pioctlSwSize = sizeof(VpioctlSw);
+ break;
+ case 'C': /* Coordinated/common pioctls */
+ pioctlSw = CpioctlSw;
+ pioctlSwSize = sizeof(CpioctlSw);
+ break;
+ default:
+ afs_PutFakeStat(&fakestate);
+ return EINVAL;
}
function = acom & 0xff;
if (function >= (pioctlSwSize / sizeof(char *))) {
afs_PutFakeStat(&fakestate);
- return EINVAL; /* out of range */
+ return EINVAL; /* out of range */
}
inSize = ablob->in_size;
- if (inSize >= PIGGYSIZE) return E2BIG;
+
+ /* Do all range checking before continuing */
+ if (inSize >= PIGGYSIZE || inSize < 0 || ablob->out_size < 0)
+ return E2BIG;
+
inData = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
if (inSize > 0) {
- AFS_COPYIN(ablob->in, inData, inSize, code);
- inData[inSize]='\0';
+ AFS_COPYIN(ablob->in, inData, inSize, code);
+ inData[inSize]='\0';
}
else code = 0;
if (code) {
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) {
- outData[outSize]='\0';
- AFS_COPYOUT(outData, ablob->out, outSize, code);
- }
+ if (outSize > ablob->out_size) outSize = ablob->out_size;
+ if (outSize >= PIGGYSIZE) code = E2BIG;
+ 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);
- }
-
+}
+
DECL_PIOCTL(PGetFID)
{
- register afs_int32 code;
-
AFS_STATCNT(PGetFID);
if (!avc) return EINVAL;
memcpy(aout, (char *)&avc->fid, sizeof(struct VenusFid));
*aoutSize = sizeof(struct VenusFid);
return 0;
- }
-
+}
+
DECL_PIOCTL(PSetAcl)
{
register afs_int32 code;
struct AFSVolSync tsync;
struct AFSFetchStatus OutStatus;
XSTATS_DECLS;
-
+
AFS_STATCNT(PSetAcl);
if (!avc)
return EINVAL;
}
if (avc && (sbr->sb_thisfile != -1)) {
- if (afs_AccessOK(avc, PRSFS_WRITE | PRSFS_ADMINISTER,
+ if (afs_AccessOK(avc, PRSFS_WRITE | PRSFS_ADMINISTER,
areq, DONT_CHECK_MODE_BITS))
avc->asynchrony = sbr->sb_thisfile;
else code = EACCES;
afs_gcpags = AFS_GCPAGS_USERDISABLED;
return 0;
}
-
+
DECL_PIOCTL(PGetAcl)
{
struct AFSOpaque acl;
}
return code;
}
-
+
DECL_PIOCTL(PNoop)
{
AFS_STATCNT(PNoop);
return 0;
}
-
+
DECL_PIOCTL(PBogus)
{
AFS_STATCNT(PBogus);
return EINVAL;
}
-
+
DECL_PIOCTL(PGetFileCell)
{
register struct cell *tcell;
-
+
AFS_STATCNT(PGetFileCell);
if (!avc) return EINVAL;
tcell = afs_GetCell(avc->fid.Cell, READ_LOCK);
*aoutSize = strlen(aout) + 1;
return 0;
}
-
+
DECL_PIOCTL(PGetWSCell)
{
- register struct cell *tcell=0, *cellOne=0;
- register struct afs_q *cq, *tq;
-
+ struct cell *tcell = NULL;
+
AFS_STATCNT(PGetWSCell);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
- ObtainReadLock(&afs_xcell);
- cellOne = NULL;
-
- 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;
}
-
+
DECL_PIOCTL(PGetUserCell)
{
register afs_int32 i;
register struct unixuser *tu;
register struct cell *tcell;
-
+
AFS_STATCNT(PGetUserCell);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
/* return the cell name of the primary cell for this user */
}
return 0;
}
-
+
DECL_PIOCTL(PSetTokens)
{
afs_int32 i;
int stLen;
struct vrequest treq;
afs_int32 flag, set_parent_pag = 0;
-
+
AFS_STATCNT(PSetTokens);
if (!afs_resourceinit_flag) {
return EIO;
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 */
memcpy((char *)&i, ain, sizeof(afs_int32));
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;
-#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
+ afs_int32 pag;
+#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
#if defined(AFS_DARWIN_ENV)
- struct proc *p=current_proc(); /* XXX */
+ struct proc *p = current_proc(); /* XXX */
#else
- struct proc *p=curproc; /* XXX */
+ 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
+#else
#ifdef AFS_OSF_ENV
if (!setpag(u.u_procp, acred, -1, &pag, 1)) { /* XXX u.u_procp is a no-op XXX */
#else
else
return ESRCH;
}
-}
+}
DECL_PIOCTL(PGetVolumeStatus)
{
AFS_STATCNT(PSetVolumeStatus);
if (!avc) return EINVAL;
- tvp = afs_GetVolume(&avc->fid, areq, READ_LOCK);
+ tvp = afs_GetVolume(&avc->fid, areq, READ_LOCK);
if (tvp) {
if (tvp->states & (VRO | VBackup)) {
afs_PutVolume(tvp, READ_LOCK);
strcpy(aout, tvc->linkData);
*aoutSize = strlen(tvc->linkData)+1;
}
- } else
+ } else
code = EIO;
}
ReleaseWriteLock(&tvc->lock);
int newStyle;
AFS_STATCNT(PGetTokens);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
/* weird interface. If input parameter is present, it is an integer and
}
}
else {
- if (tu->uid == areq->uid && tu->cell == 1) break;
+ if (tu->uid == areq->uid && afs_IsPrimaryCellNum(tu->cell)) break;
}
}
if (tu) {
/*
- * No need to hold a read lock on each user entry
+ * No need to hold a read lock on each user entry
*/
tu->refCount++;
}
register struct unixuser *tu;
AFS_STATCNT(PUnlog);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
i = UHash(areq->uid);
{
afs_int32 newHostAddr;
afs_int32 oldHostAddr;
-
+
AFS_STATCNT(PMariner);
if (afs_mariner)
memcpy((char *)&oldHostAddr, (char *)&afs_marinerHost, sizeof(afs_int32));
else
oldHostAddr = 0xffffffff; /* disabled */
-
+
memcpy((char *)&newHostAddr, ain, sizeof(afs_int32));
if (newHostAddr == 0xffffffff) {
/* disable mariner operations */
AFS_STATCNT(PCheckServers);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
if (*lp == 0x12345678) { /* For afs3.3 version */
pcheck=(struct chservinfo *)ain;
if (pcheck->tinterval >= 0) {
- cp = aout;
+ cp = aout;
memcpy(cp, (char *)&PROBE_INTERVAL, sizeof(afs_int32));
*aoutSize = sizeof(afs_int32);
if (pcheck->tinterval > 0) {
} else { /* For pre afs3.3 versions */
memcpy((char *)&temp, ain, sizeof(afs_int32));
cp = ain+sizeof(afs_int32);
- if (ainSize > sizeof(afs_int32))
+ if (ainSize > sizeof(afs_int32))
havecell = 1;
}
- /*
+ /*
* 1: fast check, don't contact servers.
* 2: local cell only.
*/
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 */
DECL_PIOCTL(PCheckVolNames)
{
AFS_STATCNT(PCheckVolNames);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
afs_CheckRootVolume();
afs_int32 retValue;
AFS_STATCNT(PCheckAuth);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
retValue = 0;
if (!tu) retValue = EACCES;
else {
/* we have a user */
- ObtainReadLock(&afs_xsrvAddr);
+ ObtainReadLock(&afs_xsrvAddr);
ObtainReadLock(&afs_xconn);
/* any tokens set? */
{
register char *tp;
register afs_int32 code;
-#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
+#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
size_t bufferSize;
#else
u_int bufferSize;
register struct server *ts;
register afs_int32 i;
register char *cp;
-
+
AFS_STATCNT(PFindVolume);
if (!avc) return EINVAL;
tvp = afs_GetVolume(&avc->fid, areq, READ_LOCK);
{
register afs_int32 code;
afs_int32 temp;
-
+
AFS_STATCNT(PViceAccess);
if (!avc) return EINVAL;
code = afs_VerifyVCache(avc, areq);
}
DECL_PIOCTL(PSetCacheSize)
-{
+{
afs_int32 newValue;
int waitcnt = 0;
-
+
AFS_STATCNT(PSetCacheSize);
if (!afs_osi_suser(*acred))
return EACCES;
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;
{
/* 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;
afs_int32 scount;
-
+
AFS_STATCNT(PNewCell);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
if (!afs_osi_suser(*acred))
}
linkedstate |= CNoSUID; /* setuid is disabled by default for fs newcell */
- code = afs_NewCell(newcell, cellHosts, linkedstate, linkedcell, fsport, vlport, (int)0, NULL);
+ code = afs_NewCell(newcell, cellHosts, linkedstate, linkedcell, fsport,
+ vlport, (int)0);
return code;
}
DECL_PIOCTL(PNewAlias)
{
/* create a new cell alias */
- register struct cell *tcell;
char *tp = ain;
register afs_int32 code;
char *realName, *aliasName;
- register struct afs_q *cq, *tq;
-
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
if (!afs_osi_suser(*acred))
tp += strlen(aliasName) + 1;
realName = tp;
- /*
- * Prevent user from shooting themselves in the foot -- don't allow
- * creation of aliases when a real cell already exists with that name.
- */
- ObtainReadLock(&afs_xcell);
- for (cq = CellLRU.next; cq != &CellLRU; cq = tq) {
- tcell = QTOC(cq); tq = QNext(cq);
- if ((afs_strcasecmp(tcell->cellName, aliasName) == 0) &&
- !(tcell->states & CAlias)) {
- ReleaseReadLock(&afs_xcell);
- return EEXIST;
- }
- }
- ReleaseReadLock(&afs_xcell);
-
- code = afs_NewCell(aliasName, 0, CAlias, 0, 0, 0, 0, realName);
+ code = afs_NewCellAlias(aliasName, realName);
*aoutSize = 0;
return code;
}
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 */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
memcpy((char *)&whichCell, tp, sizeof(afs_int32));
tp += sizeof(afs_int32);
- tcell = afs_GetRealCellByIndex(whichCell, READ_LOCK, 0);
+ tcell = afs_GetCellByIndex(whichCell, READ_LOCK);
if (tcell) {
cp = aout;
memset(cp, 0, MAXCELLHOSTS * sizeof(afs_int32));
strcpy(cp, tcell->cellName);
cp += strlen(tcell->cellName)+1;
*aoutSize = cp - aout;
+ afs_PutCell(tcell, READ_LOCK);
}
if (tcell) return 0;
else return EDOM;
DECL_PIOCTL(PListAliases)
{
afs_int32 whichAlias;
- register struct cell *tcell=0;
+ register struct cell_alias *tcalias=0;
register char *cp, *tp = ain;
- register struct afs_q *cq, *tq;
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven'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);
- ObtainReadLock(&afs_xcell);
- for (cq = CellLRU.next; cq != &CellLRU; cq = tq) {
- tcell = QTOC(cq); tq = QNext(cq);
- if (!(tcell->states & CAlias)) {
- tcell = 0;
- continue;
- }
- if (whichAlias == 0) break;
- tcell = 0;
- whichAlias--;
- }
- if (tcell) {
+ tcalias = afs_GetCellAlias(whichAlias);
+ if (tcalias) {
cp = aout;
- strcpy(cp, tcell->cellName);
- cp += strlen(tcell->cellName)+1;
- strcpy(cp, tcell->realName);
- cp += strlen(tcell->realName)+1;
+ strcpy(cp, tcalias->alias);
+ cp += strlen(tcalias->alias)+1;
+ strcpy(cp, tcalias->cell);
+ cp += strlen(tcalias->cell)+1;
*aoutSize = cp - aout;
+ afs_PutCellAlias(tcalias);
}
- ReleaseReadLock(&afs_xcell);
- if (tcell) return 0;
+ if (tcalias) return 0;
else return EDOM;
}
if (tvc->linkData) {
if ((tvc->linkData[0] != '#') && (tvc->linkData[0] != '%'))
code = EINVAL;
- } else
+ } else
code = EIO;
}
ReleaseWriteLock(&tvc->lock);
code = 0;
out:
if (sysState.allocked) osi_FreeLargeSpace(bufp);
- return code;
+ return code;
}
DECL_PIOCTL(PVenusLogging)
afs_int32 temp;
AFS_STATCNT(PGetCellStatus);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
tcell = afs_GetCellByName(ain, READ_LOCK);
{
register struct cell *tcell;
afs_int32 temp;
-
+
if (!afs_osi_suser(*acred))
return EACCES;
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
tcell = afs_GetCellByName(ain+2*sizeof(afs_int32), WRITE_LOCK);
AFS_STATCNT(PFlushVolumeData);
if (!avc)
return EINVAL;
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
volume = avc->fid.Fid.Volume; /* who to zap */
cell = avc->fid.Cell;
- /*
+ /*
* Clear stat'd flag from all vnodes from this volume; this will invalidate all
* the vcaches associated with the volume.
*/
#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
-#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
+#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
osi_vnhold(tvc, 0);
#else
VREFCOUNT_INC(tvc);
}
ReleaseReadLock(&afs_xvolume);
- /* probably, a user is doing this, probably, because things are screwed up.
+ /* probably, a user is doing this, probably, because things are screwed up.
* maybe it's the dnlc's fault? */
- osi_dnlc_purge();
+ osi_dnlc_purge();
return 0;
}
register afs_int32 code;
struct vcxstat stat;
afs_int32 mode, i;
-
+
/* AFS_STATCNT(PGetVnodeXStatus); */
if (!avc) return EINVAL;
code = afs_VerifyVCache(avc, areq);
else
mode = PRSFS_READ;
if (!afs_AccessOK(avc, mode, areq, CHECK_MODE_BITS))
- return EACCES;
+ return EACCES;
stat.fid = avc->fid;
hset32(stat.DataVersion, hgetlo(avc->m.DataVersion));
stat.lock = avc->lock;
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) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
- return (EINVAL);
-#else
+#if defined(KERNEL_HAVE_UERROR)
return (setuerror(EINVAL), EINVAL);
+#else
+ return (EINVAL);
#endif
}
memset(inname, 0, MAXSYSNAME);
} 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, ... */
* l - array of cell ids which have volumes that need to be sorted
* vlonly - sort vl servers or file servers?
*/
-static void ReSortCells(int s, afs_int32 l[], int vlonly)
-{
- int i;
- struct volume *j;
- register int k;
-
- if (vlonly) {
- struct cell *tcell;
- ObtainWriteLock(&afs_xcell,300);
- for(k=0;k<s;k++) {
- tcell = afs_GetCellNoLock(l[k], WRITE_LOCK);
- if (!tcell) continue;
- afs_SortServers(tcell->cellHosts, MAXCELLHOSTS);
- afs_PutCell(tcell, WRITE_LOCK);
- }
- ReleaseWriteLock(&afs_xcell);
- 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];
- 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);
+ for (i=0; i<s; i++) {
+ if (l[i] == cell->cellNum) {
+ ObtainWriteLock(&cell->lock, 690);
+ afs_SortServers(cell->cellHosts, MAXCELLHOSTS);
+ ReleaseWriteLock(&cell->lock);
+ }
+ }
+
+ return NULL;
+}
+
+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);
}
struct server *srvr = NULL;
afs_int32 touched[34];
int isfs;
-
+
touchedSize=0;
- for (k=0; k < num; sp++, k++) {
+ for (k=0; k < num; sp++, k++) {
if (debugsetsp) {
printf ("sp host=%x, rank=%d\n",sp->host.s_addr, sp->rank);
}
matches=0;
ObtainReadLock(&afs_xserver);
-
+
i = SHash(sp->host.s_addr);
for (sa = afs_srvAddrs[i]; sa; sa = sa->next_bkt) {
if (sa->sa_ip == sp->host.s_addr) {
srvr = sa->server;
- isfs = (srvr->cell && (sa->sa_portal == srvr->cell->fsport))
- || (sa->sa_portal == AFS_FSPORT);
+ isfs = (srvr->cell && (sa->sa_portal == srvr->cell->fsport))
+ || (sa->sa_portal == AFS_FSPORT);
if ((!vlonly && isfs) || (vlonly && !isfs)) {
matches++;
break;
}
}
}
-
+
if (sa && matches) { /* found one! */
if (debugsetsp) {
printf ("sa ip=%x, ip_rank=%d\n",sa->sa_ip, sa->sa_iprank);
}
sa->sa_iprank = sp->rank + afs_randomMod15();
afs_SortOneServer(sa->server);
-
+
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);
}
}
}
-
+
ReleaseReadLock(&afs_xserver);
/* if we didn't find one, start to create one. */
/* Note that it doesn't have a cell yet... */
if (!matches) {
afs_uint32 temp = sp->host.s_addr;
- srvr = afs_GetServer(&temp, 1, 0, (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);
}
} /* for all cited preferences */
-
+
ReSortCells(touchedSize, touched, vlonly);
return 0;
}
struct setspref *ssp;
AFS_STATCNT(PSetSPrefs);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
if (!afs_osi_suser(*acred))
return EACCES;
- if (ainSize < sizeof(struct setspref))
+ if (ainSize < sizeof(struct setspref))
return EINVAL;
ssp = (struct setspref *)ain;
- if (ainSize < sizeof(struct spref)*ssp->num_servers)
+ if (ainSize < sizeof(struct spref)*ssp->num_servers)
return EINVAL;
- afs_setsprefs(&(ssp->servers[0]), ssp->num_servers,
+ afs_setsprefs(&(ssp->servers[0]), ssp->num_servers,
(ssp->flags & DBservers));
return 0;
}
{
struct spref *sp;
AFS_STATCNT(PSetSPrefs);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
/* some notes on the following code...
* in the hash table of server structs, all servers with the same IP address
- * will be on the same overflow chain.
- * This could be sped slightly in some circumstances by having it cache the
+ * will be on the same overflow chain.
+ * This could be sped slightly in some circumstances by having it cache the
* immediately previous slot in the hash table and some supporting information
* Only reports file servers now.
*/
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;
-
+
AFS_STATCNT(PGetSPrefs);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
-
+
if (ainSize < sizeof (struct sprefrequest_33)) {
return ENOENT;
}
else {
spin = ((struct sprefrequest *) ain);
}
-
+
if (ainSize > sizeof (struct sprefrequest_33)) {
vlonly = (spin->flags & DBservers);
}
else vlonly = 0;
-
+
/* struct sprefinfo includes 1 server struct... that size gets added
* in during the loop that follows.
*/
spout->next_offset = spin->offset;
spout->num_servers = 0;
srvout = spout->servers;
-
+
ObtainReadLock(&afs_xserver);
for (i=0, j=0; j < NSERVERS; j++) { /* sift through hash table */
for (sa = afs_srvAddrs[j]; sa; sa = sa->next_bkt, i++) {
continue; /* catch up to where we left off */
}
spout->next_offset++;
-
+
srvr = sa->server;
- isfs = (srvr->cell && (sa->sa_portal == srvr->cell->fsport))
- || (sa->sa_portal == AFS_FSPORT);
-
+ isfs = (srvr->cell && (sa->sa_portal == srvr->cell->fsport))
+ || (sa->sa_portal == AFS_FSPORT);
+
if ((vlonly && isfs) || (!vlonly && !isfs)) {
/* only report ranks for vl servers */
continue;
}
-
+
srvout->host.s_addr = sa->sa_ip;
srvout->rank = sa->sa_iprank;
*aoutSize += sizeof(struct spref);
}
}
ReleaseReadLock(&afs_xserver);
-
+
spout->next_offset = 0; /* start over from the beginning next time */
return 0;
}
}
if (rxp->rx_MyMaxSendSize)
rx_MyMaxSendSize = rxp->rx_MyMaxSendSize;
-
+
return 0;
}
osi_Assert(ISAFS_GLOCK());
#endif
AFS_STATCNT(HandleClientContext);
- if (ablob->in_size < PIOCTL_HEADER*sizeof(afs_int32)) {
+ if (ablob->in_size < PIOCTL_HEADER*sizeof(afs_int32)) {
/* Must at least include the PIOCTL_HEADER header words required by the protocol */
return EINVAL; /* Too small to be good */
}
*/
i = (*com) & 0xff;
if (!afs_osi_suser(credp)) {
-#ifdef AFS_SGI_ENV
+#ifdef AFS_SGI_ENV
#ifndef AFS_SGI64_ENV
/* Since SGI's suser() returns explicit failure after the call.. */
- u.u_error = 0;
-#endif
+ u.u_error = 0;
+#endif
#endif
/* check for acceptable opcodes for normal folks, which are, so far,
* set tokens and unlog.
}
newcred = crget();
#ifdef AFS_AIX41_ENV
- setuerror(0);
+ 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
int i,j;
AFS_STATCNT(PGetCPrefs);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
if ( ainSize < sizeof (struct sprefrequest ))
return EINVAL;
-
+
spin = (struct sprefrequest *) ain;
spout = (struct sprefinfo *) aout;
for ( i=spin->offset, j=0; (i < afs_cb_interface.numberOfInterfaces)
&& ( j< maxNumber) ; i++, j++, srvout++)
srvout->host.s_addr = afs_cb_interface.addr_in[i];
-
+
spout->num_servers = j;
*aoutSize = sizeof(struct sprefinfo) +(j-1)* sizeof (struct spref);
spout->next_offset = 0; /* start from beginning again */
else
spout->next_offset = spin->offset + j;
-
+
ReleaseReadLock(&afs_xinterface);
return 0;
}
int i;
AFS_STATCNT(PSetCPrefs);
- if ( !afs_resourceinit_flag ) /* afs deamons havn't started yet */
+ if ( !afs_resourceinit_flag ) /* afs daemons haven't started yet */
return EIO; /* Inappropriate ioctl for device */
sin = (struct setspref *)ain;
struct VenusFid tfid;
struct AFSFid *Fid;
struct vcache *tvc;
- XSTATS_DECLS;
AFS_STATCNT(PSetAcl);
if (!avc)
} else
code = -1;
} while
- (afs_Analyze(tc, code, &tvc->fid, areq,
- AFS_STATS_FS_RPCIDX_RESIDENCYRPCS, SHARED_LOCK,
+ (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);
} else
code = -1;
} while
- (afs_Analyze(tc, code, &tvc->fid, areq,
+ (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 */
*aoutSize = sizeof(struct ResidencyCmdOutputs);
}
return code;
-}
+}