#ifdef AFS_OBSD_ENV
#include "h/syscallargs.h"
#endif
-#ifdef AFS_FBSD50_ENV
+#ifdef AFS_FBSD_ENV
#include "h/sysproto.h"
#endif
+#ifdef AFS_NBSD40_ENV
+#include <sys/ioctl.h>
+#include <sys/ioccom.h>
+#endif
#include "afsincludes.h" /* Afs-based standard headers */
#include "afs/afs_stats.h" /* afs statistics */
#include "afs/vice.h"
short afs_waitForeverCount = 0;
afs_int32 afs_showflags = GAGUSER | GAGCONSOLE; /* show all messages */
-#ifdef AFS_DISCON_ENV
afs_int32 afs_is_disconnected;
afs_int32 afs_is_discon_rw;
/* On reconnection, turn this knob on until it finishes,
* then turn it off.
*/
afs_int32 afs_in_sync = 0;
-#endif
struct afs_pdata {
char *ptr;
*/
static_inline int
-afs_pd_alloc(struct afs_pdata *apd, size_t size) {
+afs_pd_alloc(struct afs_pdata *apd, size_t size)
+{
if (size > AFS_LRALLOCSIZ)
apd->ptr = osi_Alloc(size + 1);
}
static_inline void
-afs_pd_free(struct afs_pdata *apd) {
+afs_pd_free(struct afs_pdata *apd)
+{
if (apd->ptr == NULL)
return;
}
static_inline char *
-afs_pd_where(struct afs_pdata *apd) {
+afs_pd_where(struct afs_pdata *apd)
+{
return apd ? apd->ptr : NULL;
}
static_inline size_t
-afs_pd_remaining(struct afs_pdata *apd) {
+afs_pd_remaining(struct afs_pdata *apd)
+{
return apd ? apd->remaining : 0;
}
static_inline int
-afs_pd_skip(struct afs_pdata *apd, size_t skip) {
+afs_pd_skip(struct afs_pdata *apd, size_t skip)
+{
if (apd == NULL || apd->remaining < skip)
return EINVAL;
apd->remaining -= skip;
}
static_inline int
-afs_pd_getInt(struct afs_pdata *apd, afs_int32 *val) {
+afs_pd_getInt(struct afs_pdata *apd, afs_int32 *val)
+{
if (apd == NULL || apd->remaining < sizeof(afs_int32))
return EINVAL;
apd->remaining -= sizeof(afs_int32);
}
static_inline int
-afs_pd_getUint(struct afs_pdata *apd, afs_uint32 *val) {
+afs_pd_getUint(struct afs_pdata *apd, afs_uint32 *val)
+{
return afs_pd_getInt(apd, (afs_int32 *)val);
}
static_inline int
-afs_pd_getBytes(struct afs_pdata *apd, void *dest, size_t bytes) {
+afs_pd_getBytes(struct afs_pdata *apd, void *dest, size_t bytes)
+{
if (apd == NULL || apd->remaining < bytes)
return EINVAL;
apd->remaining -= bytes;
}
static_inline void *
-afs_pd_inline(struct afs_pdata *apd, size_t bytes) {
+afs_pd_inline(struct afs_pdata *apd, size_t bytes)
+{
void *ret;
if (apd == NULL || apd->remaining < bytes)
}
static_inline int
-afs_pd_getString(struct afs_pdata *apd, char *str, size_t maxLen) {
+afs_pd_getString(struct afs_pdata *apd, char *str, size_t maxLen)
+{
size_t len;
if (apd == NULL || apd->remaining <= 0)
}
static_inline int
-afs_pd_getStringPtr(struct afs_pdata *apd, char **str) {
+afs_pd_getStringPtr(struct afs_pdata *apd, char **str)
+{
size_t len;
if (apd == NULL || apd->remaining <= 0)
}
static_inline int
-afs_pd_putInt(struct afs_pdata *apd, afs_int32 val) {
+afs_pd_putInt(struct afs_pdata *apd, afs_int32 val)
+{
if (apd == NULL || apd->remaining < sizeof(afs_int32))
return E2BIG;
*(afs_int32 *)apd->ptr = val;
}
static_inline int
-afs_pd_putBytes(struct afs_pdata *apd, const void *bytes, size_t len) {
+afs_pd_putBytes(struct afs_pdata *apd, const void *bytes, size_t len)
+{
if (apd == NULL || apd->remaining < len)
return E2BIG;
memcpy(apd->ptr, bytes, len);
DECL_PIOCTL(PListCells);
DECL_PIOCTL(PListAliases);
DECL_PIOCTL(PRemoveMount);
-DECL_PIOCTL(PVenusLogging);
DECL_PIOCTL(PGetCellStatus);
DECL_PIOCTL(PSetCellStatus);
DECL_PIOCTL(PFlushVolumeData);
DECL_PIOCTL(PGetPAG);
#if defined(AFS_CACHE_BYPASS)
DECL_PIOCTL(PSetCachingThreshold);
-DECL_PIOCTL(PSetCachingBlkSize);
#endif
/*
PGetWSCell, /* 31 -- get cell name for workstation */
PMariner, /* 32 - set/get mariner host */
PGetUserCell, /* 33 -- get cell name for user */
- PVenusLogging, /* 34 -- Enable/Disable logging */
+ PBogus, /* 34 -- Enable/Disable logging */
PGetCellStatus, /* 35 */
PSetCellStatus, /* 36 */
PFlushVolumeData, /* 37 -- flush all data from a volume */
return (code);
}
#elif defined(AFS_XBSD_ENV)
-# if !defined(AFS_FBSD50_ENV)
+# if defined(AFS_FBSD_ENV)
# define arg data
int
afs_xioctl(struct thread *td, register struct ioctl_args *uap,
register struct filedesc *fdp;
register struct vcache *tvc;
register int ioctlDone = 0, code = 0;
+ struct file *fd;
AFS_STATCNT(afs_xioctl);
+# if defined(AFS_NBSD40_ENV)
+ fdp = p->l_proc->p_fd;
+# else
fdp = p->p_fd;
+#endif
if ((u_int) uap->fd >= fdp->fd_nfiles
|| (fd = fdp->fd_ofiles[uap->fd]) == NULL)
return EBADF;
}
if (!ioctlDone) {
-# if defined(AFS_FBSD50_ENV)
+# if defined(AFS_FBSD_ENV)
return ioctl(td, uap);
-# elif defined(AFS_FBSD_ENV)
- return ioctl(p, uap);
# elif defined(AFS_OBSD_ENV)
code = sys_ioctl(p, uap, retval);
+# elif defined(AFS_NBSD_ENV)
+ struct lwp *l = osi_curproc();
+ code = sys_ioctl(l, uap, retval);
# endif
}
# endif
}
-#elif defined(AFS_FBSD50_ENV)
+#elif defined(AFS_FBSD_ENV)
int
afs_pioctl(struct thread *td, void *args, int *retval)
{
} *uap = (struct a *)args;
AFS_STATCNT(afs_pioctl);
-# ifdef AFS_DARWIN80_ENV
+# if defined(AFS_DARWIN80_ENV) || defined(AFS_NBSD40_ENV)
return (afs_syscall_pioctl
(uap->path, uap->cmd, uap->cmarg, uap->follow,
kauth_cred_get()));
# else
return (afs_syscall_pioctl
(uap->path, uap->cmd, uap->cmarg, uap->follow,
+# if defined(AFS_FBSD_ENV)
+ td->td_ucred));
+# else
p->p_cred->pc_ucred));
+# endif
# endif
}
#else
code = gop_lookupname_user(path, AFS_UIOUSER, follow, &vp);
#if defined(AFS_FBSD80_ENV) /* XXX check on 7x */
- VN_HOLD(vp);
+ if (vp != NULL)
+ VN_HOLD(vp);
#endif /* AFS_FBSD80_ENV */
#endif /* AFS_LINUX22_ENV */
#endif /* AFS_AIX41_ENV */
*
* \post Changed ACL, via direct writing to the wire
*/
-int dummy_PSetAcl(char *ain, char *aout)
+int
+dummy_PSetAcl(char *ain, char *aout)
{
return 0;
}
if (set_parent_pag) {
afs_uint32 pag;
#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
-# if defined(AFS_DARWIN_ENV)
- afs_proc_t *p = current_proc(); /* XXX */
-# else
- afs_proc_t *p = curproc; /* XXX */
-# endif
-# ifndef AFS_DARWIN80_ENV
- uprintf("Process %d (%s) tried to change pags in PSetTokens\n",
- p->p_pid, p->p_comm);
-# endif
- if (!setpag(p, acred, -1, &pag, 1)) {
+ char procname[256];
+ osi_procname(procname, 256);
+ afs_warnuser("Process %d (%s) tried to change pags in PSetTokens\n",
+ MyPidxx2Pid(MyPidxx), procname);
+ if (!setpag(osi_curproc(), acred, -1, &pag, 1)) {
#else
if (!setpag(acred, -1, &pag, 1)) {
#endif
afs_SetPrimary(tu, flag);
tu->tokenTime = osi_Time();
afs_ResetUserConns(tu);
+ afs_NotifyUser(tu, UTokensObtained);
afs_PutUser(tu, WRITE_LOCK);
return 0;
if (((tu->states & UHasTokens) == 0)
|| (tu->ct.EndTimestamp < osi_Time())) {
tu->states |= (UTokensBad | UNeedsReset);
+ afs_NotifyUser(tu, UTokensDropped);
afs_PutUser(tu, READ_LOCK);
return ENOTCONN;
}
memset(&tu->ct, 0, sizeof(struct ClearToken));
tu->refCount++;
ReleaseWriteLock(&afs_xuser);
+ afs_NotifyUser(tu, UTokensDropped);
/* We have to drop the lock over the call to afs_ResetUserConns,
* since it obtains the afs_xvcache lock. We could also keep
* the lock, and modify ResetUserConns to take parm saying we
return EWOULDBLOCK; /* pretty close */
}
afs_BQueue(BOP_PATH, (struct vcache *)0, 0, 0, acred, (afs_size_t) 0,
- (afs_size_t) 0, tp);
+ (afs_size_t) 0, tp, (void *)0, (void *)0);
return 0;
}
}
/*!
- * VIOC_VENUSLOG (34) - Enable/Disable venus logging
- *
- * \ingroup pioctl
- *
- * \retval EINVAL Error if some of the standard args aren't set
- *
- * \notes Obsoleted, perhaps should be PBogus
- */
-DECL_PIOCTL(PVenusLogging)
-{
- return EINVAL; /* OBSOLETE */
-}
-
-/*!
* VIOC_GETCELLSTATUS (35) - Get cell status info
*
* \ingroup pioctl
}
#ifdef AFS_DARWIN80_ENV
if (tvc->f.states & CDeadVnode) {
- ReleaseReadLock(&afs_xvcache);
- afs_osi_Sleep(&tvc->f.states);
- goto loop;
+ if (!(tvc->f.states & CBulkFetching)) {
+ ReleaseReadLock(&afs_xvcache);
+ afs_osi_Sleep(&tvc->f.states);
+ goto loop;
+ }
}
-#endif
-#if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV)
- VN_HOLD(AFSTOV(tvc));
-#elif defined(AFS_DARWIN80_ENV)
vp = AFSTOV(tvc);
if (vnode_get(vp))
continue;
AFS_GLOCK();
continue;
}
-#elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
- osi_vnhold(tvc, 0);
+ if (tvc->f.states & (CBulkFetching|CDeadVnode)) {
+ AFS_GUNLOCK();
+ vnode_recycle(AFSTOV(tvc));
+ AFS_GLOCK();
+ }
#else
- VREFCOUNT_INC(tvc); /* AIX, apparently */
+ AFS_FAST_HOLD(tvc);
#endif
ReleaseReadLock(&afs_xvcache);
#ifdef AFS_BOZONLOCK_ENV
touchedSize = 0;
for (k = 0; k < num; sp++, k++) {
if (debugsetsp) {
- printf("sp host=%x, rank=%d\n", sp->host.s_addr, sp->rank);
+ afs_warn("sp host=%x, rank=%d\n", sp->host.s_addr, sp->rank);
}
matches = 0;
ObtainReadLock(&afs_xserver);
if (sa && matches) { /* found one! */
if (debugsetsp) {
- printf("sa ip=%x, ip_rank=%d\n", sa->sa_ip, sa->sa_iprank);
+ afs_warn("sa ip=%x, ip_rank=%d\n", sa->sa_ip, sa->sa_iprank);
}
sa->sa_iprank = sp->rank + afs_randomMod15();
afs_SortOneServer(sa->server);
newcred->cr_groupset.gs_union.un_groups[1] = g1;
#elif defined(AFS_LINUX26_ENV)
# ifdef AFS_LINUX26_ONEGROUP_ENV
- set_cr_group_info(newcred, groups_alloc(1)); /* nothing sets this */
+ afs_set_cr_group_info(newcred, groups_alloc(1)); /* nothing sets this */
l = (((g0-0x3f00) & 0x3fff) << 14) | ((g1-0x3f00) & 0x3fff);
h = ((g0-0x3f00) >> 14);
h = ((g1-0x3f00) >> 14) + h + h + h;
- GROUP_AT(cr_group_info(newcred), 0) = ((h << 28) | l);
+ GROUP_AT(afs_cr_group_info(newcred), 0) = ((h << 28) | l);
# else
- set_cr_group_info(newcred, groups_alloc(2));
- GROUP_AT(cr_group_info(newcred), 0) = g0;
- GROUP_AT(cr_group_info(newcred), 1) = g1;
+ afs_set_cr_group_info(newcred, groups_alloc(2));
+ GROUP_AT(afs_cr_group_info(newcred), 0) = g0;
+ GROUP_AT(afs_cr_group_info(newcred), 1) = g1;
# endif
#elif defined(AFS_SUN510_ENV)
gids[0] = g0;
#ifdef AFS_AIX_ENV
newcred->cr_ngrps = 2;
#elif !defined(AFS_LINUX26_ENV) && !defined(AFS_SUN510_ENV)
-# if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_LINUX22_ENV)
+# if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_LINUX22_ENV) || defined(AFS_FBSD80_ENV)
newcred->cr_ngroups = 2;
# else
for (i = 2; i < NGROUPS; i++)
{
afs_int32 getting = 1;
afs_int32 setting = 1;
- afs_int32 threshold;
+ afs_int32 threshold = AFS_CACHE_BYPASS_DISABLED;
if (afs_pd_getInt(ain, &threshold) != 0)
setting = 0;
}
/* Return the current size threshold */
- if (getting) {
- return afs_pd_putInt32(aout, cache_bypass_threshold);
+ if (getting)
+ return afs_pd_putInt(aout, cache_bypass_threshold);
return(0);
}
DECL_PIOCTL(PDiscon)
{
-#ifdef AFS_DISCON_ENV
static afs_int32 mode = 1; /* Start up in 'off' */
afs_int32 force = 0;
int code = 0;
- char flags[3];
+ char flags[4];
+ struct vrequest lreq;
- if (afs_pd_getBytes(ain, &flags, 3) == 0) {
+ if (afs_pd_getBytes(ain, &flags, 4) == 0) {
if (!afs_osi_suser(*acred))
return EPERM;
afs_ConflictPolicy = flags[1] - 1;
if (flags[2])
force = 1;
+ if (flags[3]) {
+ /* Fake InitReq support for UID override */
+ memset(&lreq, 0, sizeof(lreq));
+ lreq.uid = flags[3];
+ areq = &lreq; /* override areq we got */
+ }
/*
* All of these numbers are hard coded in fs.c. If they
afs_in_sync = 0;
if (code && !force) {
- printf("Files not synchronized properly, still in discon state. \n"
+ afs_warnuser("Files not synchronized properly, still in discon state. \n"
"Please retry or use \"force\".\n");
mode = 0;
} else {
afs_ClearAllStatdFlag();
afs_is_disconnected = 0;
afs_is_discon_rw = 0;
- printf("\nSync succeeded. You are back online.\n");
+ afs_warnuser("\nSync succeeded. You are back online.\n");
}
ReleaseWriteLock(&afs_discon_lock);
return code;
return afs_pd_putInt(aout, mode);
-#else
- return EINVAL;
-#endif
}
DECL_PIOCTL(PNFSNukeCreds)