/* ARGSUSED */ static int xmem_space(struct vnode *vp, int cmd, struct flock64 *bfp, int flag, offset_t offset, struct cred *cred, caller_context_t *ct) { int error; if (cmd != F_FREESP) return (EINVAL); if ((error = convoff(vp, bfp, 0, (offset_t)offset)) == 0) { if ((bfp->l_start > MAXOFF_T) || (bfp->l_len > MAXOFF_T)) return (EFBIG); error = xmem_freesp(vp, bfp, flag); } return (error); }
int afs_frlock(OSI_VN_DECL(vp), int cmd, struct flock *lfp, int flag, off_t offset, #ifdef AFS_SGI65_ENV vrwlock_t vrwlock, #endif cred_t * cr) { int error; OSI_VN_CONVERT(vp); #ifdef AFS_SGI65_ENV struct flid flid; int pid; get_current_flid(&flid); pid = flid.fl_pid; #endif /* * Since AFS doesn't support byte-wise locks (and simply * says yes! we handle byte locking locally only. * This makes lots of things work much better * XXX This doesn't properly handle moving from a * byte-wise lock up to a full file lock (we should * remove the byte locks ..) Of course neither did the * regular AFS way ... * * For GETLK we do a bit more - we first check any byte-wise * locks - if none then check for full AFS file locks */ if (cmd == F_GETLK || lfp->l_whence != 0 || lfp->l_start != 0 || (lfp->l_len != MAXEND && lfp->l_len != 0)) { AFS_RWLOCK(vp, VRWLOCK_WRITE); AFS_GUNLOCK(); #ifdef AFS_SGI65_ENV error = fs_frlock(OSI_VN_ARG(vp), cmd, lfp, flag, offset, vrwlock, cr); #else error = fs_frlock(vp, cmd, lfp, flag, offset, cr); #endif AFS_GLOCK(); AFS_RWUNLOCK(vp, VRWLOCK_WRITE); if (error || cmd != F_GETLK) return error; if (lfp->l_type != F_UNLCK) /* found some blocking lock */ return 0; /* fall through to check for full AFS file locks */ } /* map BSD style to plain - we don't call reclock() * and its only there that the difference is important */ switch (cmd) { case F_GETLK: case F_RGETLK: break; case F_SETLK: case F_RSETLK: break; case F_SETBSDLK: cmd = F_SETLK; break; case F_SETLKW: case F_RSETLKW: break; case F_SETBSDLKW: cmd = F_SETLKW; break; default: return EINVAL; } AFS_GUNLOCK(); error = convoff(vp, lfp, 0, offset, SEEKLIMIT #ifdef AFS_SGI64_ENV , OSI_GET_CURRENT_CRED() #endif /* AFS_SGI64_ENV */ ); AFS_GLOCK(); if (!error) { #ifdef AFS_SGI65_ENV error = afs_lockctl(vp, lfp, cmd, cr, pid); #else error = afs_lockctl(vp, lfp, cmd, cr, OSI_GET_CURRENT_PID()); #endif } return error; }