Changeset View
Changeset View
Standalone View
Standalone View
sys/fs/nfsclient/nfs_clcomsubs.c
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
NFSCLSTATEMUTEX; | NFSCLSTATEMUTEX; | ||||
static nfsuint64 nfs_nullcookie = {{ 0, 0 }}; | static nfsuint64 nfs_nullcookie = {{ 0, 0 }}; | ||||
/* | /* | ||||
* copies a uio scatter/gather list to an mbuf chain. | * copies a uio scatter/gather list to an mbuf chain. | ||||
* NOTE: can ony handle iovcnt == 1 | * NOTE: can ony handle iovcnt == 1 | ||||
*/ | */ | ||||
APPLESTATIC void | void | ||||
nfsm_uiombuf(struct nfsrv_descript *nd, struct uio *uiop, int siz) | nfsm_uiombuf(struct nfsrv_descript *nd, struct uio *uiop, int siz) | ||||
{ | { | ||||
char *uiocp; | char *uiocp; | ||||
struct mbuf *mp, *mp2; | struct mbuf *mp, *mp2; | ||||
int xfer, left, mlen; | int xfer, left, mlen; | ||||
int uiosiz, clflg, rem; | int uiosiz, clflg, rem; | ||||
char *cp, *tcp; | char *cp, *tcp; | ||||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Lines | if (mbp != NULL) | ||||
*mbp = mp; | *mbp = mp; | ||||
return (firstmp); | return (firstmp); | ||||
} | } | ||||
/* | /* | ||||
* Load vnode attributes from the xdr file attributes. | * Load vnode attributes from the xdr file attributes. | ||||
* Returns EBADRPC if they can't be parsed, 0 otherwise. | * Returns EBADRPC if they can't be parsed, 0 otherwise. | ||||
*/ | */ | ||||
APPLESTATIC int | int | ||||
nfsm_loadattr(struct nfsrv_descript *nd, struct nfsvattr *nap) | nfsm_loadattr(struct nfsrv_descript *nd, struct nfsvattr *nap) | ||||
{ | { | ||||
struct nfs_fattr *fp; | struct nfs_fattr *fp; | ||||
int error = 0; | int error = 0; | ||||
if (nd->nd_flag & ND_NFSV4) { | if (nd->nd_flag & ND_NFSV4) { | ||||
error = nfsv4_loadattr(nd, NULL, nap, NULL, NULL, 0, NULL, | error = nfsv4_loadattr(nd, NULL, nap, NULL, NULL, 0, NULL, | ||||
NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL); | NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL); | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
nfsmout: | nfsmout: | ||||
return (error); | return (error); | ||||
} | } | ||||
/* | /* | ||||
* This function finds the directory cookie that corresponds to the | * This function finds the directory cookie that corresponds to the | ||||
* logical byte offset given. | * logical byte offset given. | ||||
*/ | */ | ||||
APPLESTATIC nfsuint64 * | nfsuint64 * | ||||
nfscl_getcookie(struct nfsnode *np, off_t off, int add) | nfscl_getcookie(struct nfsnode *np, off_t off, int add) | ||||
{ | { | ||||
struct nfsdmap *dp, *dp2; | struct nfsdmap *dp, *dp2; | ||||
int pos; | int pos; | ||||
pos = off / NFS_DIRBLKSIZ; | pos = off / NFS_DIRBLKSIZ; | ||||
if (pos == 0) { | if (pos == 0) { | ||||
KASSERT(!add, ("nfs getcookie add at 0")); | KASSERT(!add, ("nfs getcookie add at 0")); | ||||
Show All 35 Lines | nfscl_getcookie(struct nfsnode *np, off_t off, int add) | ||||
return (&dp->ndm_cookies[pos]); | return (&dp->ndm_cookies[pos]); | ||||
} | } | ||||
/* | /* | ||||
* Gets a file handle out of an nfs reply sent to the client and returns | * Gets a file handle out of an nfs reply sent to the client and returns | ||||
* the file handle and the file's attributes. | * the file handle and the file's attributes. | ||||
* For V4, it assumes that Getfh and Getattr Op's results are here. | * For V4, it assumes that Getfh and Getattr Op's results are here. | ||||
*/ | */ | ||||
APPLESTATIC int | int | ||||
nfscl_mtofh(struct nfsrv_descript *nd, struct nfsfh **nfhpp, | nfscl_mtofh(struct nfsrv_descript *nd, struct nfsfh **nfhpp, | ||||
struct nfsvattr *nap, int *attrflagp) | struct nfsvattr *nap, int *attrflagp) | ||||
{ | { | ||||
u_int32_t *tl; | u_int32_t *tl; | ||||
int error = 0, flag = 1; | int error = 0, flag = 1; | ||||
*nfhpp = NULL; | *nfhpp = NULL; | ||||
*attrflagp = 0; | *attrflagp = 0; | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | nfscl_mtofh(struct nfsrv_descript *nd, struct nfsfh **nfhpp, | ||||
} | } | ||||
nfsmout: | nfsmout: | ||||
return (error); | return (error); | ||||
} | } | ||||
/* | /* | ||||
* Initialize the owner/delegation sleep lock. | * Initialize the owner/delegation sleep lock. | ||||
*/ | */ | ||||
APPLESTATIC void | void | ||||
nfscl_lockinit(struct nfsv4lock *lckp) | nfscl_lockinit(struct nfsv4lock *lckp) | ||||
{ | { | ||||
lckp->nfslock_usecnt = 0; | lckp->nfslock_usecnt = 0; | ||||
lckp->nfslock_lock = 0; | lckp->nfslock_lock = 0; | ||||
} | } | ||||
/* | /* | ||||
* Get an exclusive lock. (Not needed for OpenBSD4, since there is only one | * Get an exclusive lock. (Not needed for OpenBSD4, since there is only one | ||||
* thread for each posix process in the kernel.) | * thread for each posix process in the kernel.) | ||||
*/ | */ | ||||
APPLESTATIC void | void | ||||
nfscl_lockexcl(struct nfsv4lock *lckp, void *mutex) | nfscl_lockexcl(struct nfsv4lock *lckp, void *mutex) | ||||
{ | { | ||||
int igotlock; | int igotlock; | ||||
do { | do { | ||||
igotlock = nfsv4_lock(lckp, 1, NULL, mutex, NULL); | igotlock = nfsv4_lock(lckp, 1, NULL, mutex, NULL); | ||||
} while (!igotlock); | } while (!igotlock); | ||||
} | } | ||||
/* | /* | ||||
* Release an exclusive lock. | * Release an exclusive lock. | ||||
*/ | */ | ||||
APPLESTATIC void | void | ||||
nfscl_lockunlock(struct nfsv4lock *lckp) | nfscl_lockunlock(struct nfsv4lock *lckp) | ||||
{ | { | ||||
nfsv4_unlock(lckp, 0); | nfsv4_unlock(lckp, 0); | ||||
} | } | ||||
/* | /* | ||||
* Called to derefernce a lock on a stateid (delegation or open owner). | * Called to derefernce a lock on a stateid (delegation or open owner). | ||||
*/ | */ | ||||
APPLESTATIC void | void | ||||
nfscl_lockderef(struct nfsv4lock *lckp) | nfscl_lockderef(struct nfsv4lock *lckp) | ||||
{ | { | ||||
NFSLOCKCLSTATE(); | NFSLOCKCLSTATE(); | ||||
lckp->nfslock_usecnt--; | lckp->nfslock_usecnt--; | ||||
if (lckp->nfslock_usecnt == 0 && (lckp->nfslock_lock & NFSV4LOCK_WANTED)) { | if (lckp->nfslock_usecnt == 0 && (lckp->nfslock_lock & NFSV4LOCK_WANTED)) { | ||||
lckp->nfslock_lock &= ~NFSV4LOCK_WANTED; | lckp->nfslock_lock &= ~NFSV4LOCK_WANTED; | ||||
wakeup((caddr_t)lckp); | wakeup((caddr_t)lckp); | ||||
} | } | ||||
NFSUNLOCKCLSTATE(); | NFSUNLOCKCLSTATE(); | ||||
} | } | ||||