int ioctlDone = 0, code = 0;
AFS_STATCNT(afs_xioctl);
-# if defined(AFS_SUN57_ENV)
fd = getf(uap->fd);
if (!fd)
return (EBADF);
-# elif defined(AFS_SUN54_ENV)
- fd = GETF(uap->fd);
- if (!fd)
- return (EBADF);
-# else
- if (code = getf(uap->fd, &fd)) {
- return (code);
- }
-# endif
if (fd->f_vnode->v_type == VREG || fd->f_vnode->v_type == VDIR) {
tvc = VTOAFS(fd->f_vnode); /* valid, given a vnode */
if (tvc && IsAfsVnode(AFSTOV(tvc))) {
if (code) {
osi_FreeSmallSpace(datap);
AFS_GUNLOCK();
-# if defined(AFS_SUN54_ENV)
releasef(uap->fd);
-# else
- releasef(fd);
-# endif
return (EFAULT);
}
code = HandleIoctl(tvc, uap->com, datap);
}
}
}
-# if defined(AFS_SUN57_ENV)
releasef(uap->fd);
-# elif defined(AFS_SUN54_ENV)
- RELEASEF(uap->fd);
-# else
- releasef(fd);
-# endif
if (!ioctlDone)
code = ioctl(uap, rvp);
register_t *retval)
{
afs_proc_t *p = td->td_proc;
+# elif defined(AFS_NBSD_ENV)
+int
+afs_xioctl(afs_proc_t *p, const struct sys_ioctl_args *uap, register_t *retval)
+{
# else
struct ioctl_args {
int fd;
};
int
-afs_xioctl(afs_proc_t *p, struct ioctl_args *uap, register_t *retval)
+afs_xioctl(afs_proc_t *p, const struct ioctl_args *uap, register_t *retval)
{
# endif
struct filedesc *fdp;
struct file *fd;
AFS_STATCNT(afs_xioctl);
-# if defined(AFS_NBSD40_ENV)
- fdp = p->l_proc->p_fd;
-# else
+#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)
+#if defined(AFS_NBSD50_ENV)
+ if ((fd = fd_getfile(SCARG(uap, fd))) == NULL)
+ return (EBADF);
+#else
+ if ((uap->fd >= fdp->fd_nfiles)
+ || ((fd = fdp->fd_ofiles[uap->fd]) == NULL))
return EBADF;
+#endif
if ((fd->f_flag & (FREAD | FWRITE)) == 0)
return EBADF;
/* first determine whether this is any sort of vnode */
# else
tvc = VTOAFS((struct vnode *)fd->f_data); /* valid, given a vnode */
# endif
- if (tvc && IsAfsVnode(AFSTOV(tvc))) {
+ if (tvc && IsAfsVnode((struct vnode *)fd->f_data)) {
/* This is an AFS vnode */
- if (((uap->com >> 8) & 0xff) == 'V') {
+#if defined(AFS_NBSD50_ENV)
+ if (((SCARG(uap, com) >> 8) & 0xff) == 'V') {
+#else
+ if (((uap->com >> 8) & 0xff) == 'V') {
+#endif
struct afs_ioctl *datap;
AFS_GLOCK();
datap = osi_AllocSmallSpace(AFS_SMALLOCSIZ);
+#if defined(AFS_NBSD50_ENV)
+ code = copyin_afs_ioctl(SCARG(uap, data), datap);
+#else
code = copyin_afs_ioctl((char *)uap->arg, datap);
+#endif
if (code) {
osi_FreeSmallSpace(datap);
AFS_GUNLOCK();
return code;
}
+#if defined(AFS_NBSD50_ENV)
+ code = HandleIoctl(tvc, SCARG(uap, com), datap);
+#else
code = HandleIoctl(tvc, uap->com, datap);
+#endif
osi_FreeSmallSpace(datap);
AFS_GUNLOCK();
ioctlDone = 1;
}
}
+#if defined(AFS_NBSD50_ENV)
+ fd_putfile(SCARG(uap, fd));
+#endif
+
if (!ioctlDone) {
# if defined(AFS_FBSD_ENV)
return ioctl(td, 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);
+ code = sys_ioctl(p, uap, retval);
# endif
}
if (tu->uid == areq->uid && (tu->states & UPrimary)) {
tu->refCount++;
ReleaseWriteLock(&afs_xuser);
+ afs_LockUser(tu, READ_LOCK, 0);
break;
}
}
if (tu) {
tcell = afs_GetCell(tu->cell, READ_LOCK);
- afs_PutUser(tu, WRITE_LOCK);
+ afs_PutUser(tu, READ_LOCK);
if (!tcell)
return ESRCH;
else {
tu->refCount++;
}
ReleaseReadLock(&afs_xuser);
+ if (tu) {
+ afs_LockUser(tu, READ_LOCK, 0);
+ }
+
return tu;
}
ObtainWriteLock(&afs_xuser, 227);
for (tu = afs_users[i]; tu; tu = tu->next) {
if (tu->uid == areq->uid) {
- tu->states &= ~UHasTokens;
- afs_FreeTokens(&tu->tokens);
tu->refCount++;
ReleaseWriteLock(&afs_xuser);
+
+ afs_LockUser(tu, WRITE_LOCK, 366);
+
+ tu->states &= ~UHasTokens;
+ afs_FreeTokens(&tu->tokens);
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
* every user conn that existed when we began this call.
*/
afs_ResetUserConns(tu);
- tu->refCount--;
+ afs_PutUser(tu, WRITE_LOCK);
ObtainWriteLock(&afs_xuser, 228);
#ifdef UKERNEL
/* set the expire times to 0, causes
{
char *tp;
afs_int32 code;
-#if defined(AFS_SGI61_ENV) || defined(AFS_SUN57_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+#if defined(AFS_SGI61_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
size_t bufferSize;
#else
u_int bufferSize;
}
#ifdef AFS_DARWIN80_ENV
if (tvc->f.states & CDeadVnode) {
- if (!(tvc->f.states & CBulkFetching)) {
- ReleaseReadLock(&afs_xvcache);
- afs_osi_Sleep(&tvc->f.states);
- goto loop;
- }
+ ReleaseReadLock(&afs_xvcache);
+ afs_osi_Sleep(&tvc->f.states);
+ goto loop;
}
vp = AFSTOV(tvc);
if (vnode_get(vp))
AFS_GLOCK();
continue;
}
- if (tvc->f.states & (CBulkFetching|CDeadVnode)) {
- AFS_GUNLOCK();
- vnode_recycle(AFSTOV(tvc));
- AFS_GLOCK();
- }
#else
AFS_FAST_HOLD(tvc);
#endif
DECL_PIOCTL(PPrefetchFromTape)
{
- afs_int32 code, code1;
- afs_int32 bytes, outval;
+ afs_int32 code;
+ afs_int32 outval;
struct afs_conn *tc;
struct rx_call *tcall;
struct AFSVolSync tsync;
struct vcache *tvc;
struct rx_connection *rxconn;
- AFS_STATCNT(PSetAcl);
+ AFS_STATCNT(PPrefetchFromTape);
if (!avc)
return EINVAL;
StartRXAFS_FetchData(tcall, (struct AFSFid *)&tvc->f.fid.Fid, 0,
0);
if (!code) {
- bytes = rx_Read(tcall, (char *)&outval, sizeof(afs_int32));
+ rx_Read(tcall, (char *)&outval, sizeof(afs_int32));
code =
EndRXAFS_FetchData(tcall, &OutStatus, &CallBack, &tsync);
}
- code1 = rx_EndCall(tcall, code);
+ code = rx_EndCall(tcall, code);
RX_AFS_GLOCK();
} else
code = -1;
DECL_PIOCTL(PGetTokens2)
{
- struct cell *cell;
+ struct cell *cell = NULL;
struct unixuser *tu = NULL;
afs_int32 iterator;
char *cellName = NULL;
for (i = 0; i < NUSERS; i++) {
for (tu = afs_users[i]; tu; tu = tu->next) {
if (tu->exporter && EXP_CHECKHOST(tu->exporter, addr)) {
- tu->states &= ~UHasTokens;
- afs_FreeTokens(&tu->tokens);
tu->refCount++;
ReleaseWriteLock(&afs_xuser);
+
+ afs_LockUser(tu, WRITE_LOCK, 367);
+
+ tu->states &= ~UHasTokens;
+ afs_FreeTokens(&tu->tokens);
afs_ResetUserConns(tu);
- tu->refCount--;
+ afs_PutUser(tu, WRITE_LOCK);
ObtainWriteLock(&afs_xuser, 228);
#ifdef UKERNEL
/* set the expire times to 0, causes