Changeset View
Changeset View
Standalone View
Standalone View
sys/fs/nfsserver/nfs_nfsdsubs.c
Show First 20 Lines • Show All 1,265 Lines • ▼ Show 20 Lines | static short *nfsrv_v4errmap[] = { | ||||
nfsv4err_write, | nfsv4err_write, | ||||
nfsv4err_releaselockowner, | nfsv4err_releaselockowner, | ||||
}; | }; | ||||
/* | /* | ||||
* A fiddled version of m_adj() that ensures null fill to a long | * A fiddled version of m_adj() that ensures null fill to a long | ||||
* boundary and only trims off the back end | * boundary and only trims off the back end | ||||
*/ | */ | ||||
APPLESTATIC void | void | ||||
nfsrv_adj(struct mbuf *mp, int len, int nul) | nfsrv_adj(struct mbuf *mp, int len, int nul) | ||||
{ | { | ||||
struct mbuf *m; | struct mbuf *m; | ||||
int count, i; | int count, i; | ||||
char *cp; | char *cp; | ||||
/* | /* | ||||
* Trim from tail. Scan the mbuf chain, | * Trim from tail. Scan the mbuf chain, | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | nfsrv_adj(struct mbuf *mp, int len, int nul) | ||||
for (m = m->m_next; m; m = m->m_next) | for (m = m->m_next; m; m = m->m_next) | ||||
m->m_len = 0; | m->m_len = 0; | ||||
} | } | ||||
/* | /* | ||||
* Make these functions instead of macros, so that the kernel text size | * Make these functions instead of macros, so that the kernel text size | ||||
* doesn't get too big... | * doesn't get too big... | ||||
*/ | */ | ||||
APPLESTATIC void | void | ||||
nfsrv_wcc(struct nfsrv_descript *nd, int before_ret, | nfsrv_wcc(struct nfsrv_descript *nd, int before_ret, | ||||
struct nfsvattr *before_nvap, int after_ret, struct nfsvattr *after_nvap) | struct nfsvattr *before_nvap, int after_ret, struct nfsvattr *after_nvap) | ||||
{ | { | ||||
u_int32_t *tl; | u_int32_t *tl; | ||||
if (before_ret) { | if (before_ret) { | ||||
NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED); | NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED); | ||||
*tl = newnfs_false; | *tl = newnfs_false; | ||||
} else { | } else { | ||||
NFSM_BUILD(tl, u_int32_t *, 7 * NFSX_UNSIGNED); | NFSM_BUILD(tl, u_int32_t *, 7 * NFSX_UNSIGNED); | ||||
*tl++ = newnfs_true; | *tl++ = newnfs_true; | ||||
txdr_hyper(before_nvap->na_size, tl); | txdr_hyper(before_nvap->na_size, tl); | ||||
tl += 2; | tl += 2; | ||||
txdr_nfsv3time(&(before_nvap->na_mtime), tl); | txdr_nfsv3time(&(before_nvap->na_mtime), tl); | ||||
tl += 2; | tl += 2; | ||||
txdr_nfsv3time(&(before_nvap->na_ctime), tl); | txdr_nfsv3time(&(before_nvap->na_ctime), tl); | ||||
} | } | ||||
nfsrv_postopattr(nd, after_ret, after_nvap); | nfsrv_postopattr(nd, after_ret, after_nvap); | ||||
} | } | ||||
APPLESTATIC void | void | ||||
nfsrv_postopattr(struct nfsrv_descript *nd, int after_ret, | nfsrv_postopattr(struct nfsrv_descript *nd, int after_ret, | ||||
struct nfsvattr *after_nvap) | struct nfsvattr *after_nvap) | ||||
{ | { | ||||
u_int32_t *tl; | u_int32_t *tl; | ||||
NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED); | NFSM_BUILD(tl, u_int32_t *, NFSX_UNSIGNED); | ||||
if (after_ret) | if (after_ret) | ||||
*tl = newnfs_false; | *tl = newnfs_false; | ||||
else { | else { | ||||
*tl = newnfs_true; | *tl = newnfs_true; | ||||
nfsrv_fillattr(nd, after_nvap); | nfsrv_fillattr(nd, after_nvap); | ||||
} | } | ||||
} | } | ||||
/* | /* | ||||
* Fill in file attributes for V2 and 3. For V4, call a separate | * Fill in file attributes for V2 and 3. For V4, call a separate | ||||
* routine that sifts through all the attribute bits. | * routine that sifts through all the attribute bits. | ||||
*/ | */ | ||||
APPLESTATIC void | void | ||||
nfsrv_fillattr(struct nfsrv_descript *nd, struct nfsvattr *nvap) | nfsrv_fillattr(struct nfsrv_descript *nd, struct nfsvattr *nvap) | ||||
{ | { | ||||
struct nfs_fattr *fp; | struct nfs_fattr *fp; | ||||
int fattr_size; | int fattr_size; | ||||
/* | /* | ||||
* Build space for the attribute structure. | * Build space for the attribute structure. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* This function gets a file handle out of an mbuf list. | * This function gets a file handle out of an mbuf list. | ||||
* It returns 0 for success, EBADRPC otherwise. | * It returns 0 for success, EBADRPC otherwise. | ||||
* If sets the third flagp argument to 1 if the file handle is | * If sets the third flagp argument to 1 if the file handle is | ||||
* the public file handle. | * the public file handle. | ||||
* For NFSv4, if the length is incorrect, set nd_repstat == NFSERR_BADHANDLE | * For NFSv4, if the length is incorrect, set nd_repstat == NFSERR_BADHANDLE | ||||
*/ | */ | ||||
APPLESTATIC int | int | ||||
nfsrv_mtofh(struct nfsrv_descript *nd, struct nfsrvfh *fhp) | nfsrv_mtofh(struct nfsrv_descript *nd, struct nfsrvfh *fhp) | ||||
{ | { | ||||
u_int32_t *tl; | u_int32_t *tl; | ||||
int error = 0, len, copylen; | int error = 0, len, copylen; | ||||
if (nd->nd_flag & (ND_NFSV3 | ND_NFSV4)) { | if (nd->nd_flag & (ND_NFSV3 | ND_NFSV4)) { | ||||
NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); | NFSM_DISSECT(tl, u_int32_t *, NFSX_UNSIGNED); | ||||
len = fxdr_unsigned(int, *tl); | len = fxdr_unsigned(int, *tl); | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | |||||
/* | /* | ||||
* Map errnos to NFS error numbers. For Version 3 and 4 also filter out error | * Map errnos to NFS error numbers. For Version 3 and 4 also filter out error | ||||
* numbers not specified for the associated procedure. | * numbers not specified for the associated procedure. | ||||
* NFSPROC_NOOP is a special case, where the high order bits of nd_repstat | * NFSPROC_NOOP is a special case, where the high order bits of nd_repstat | ||||
* should be cleared. NFSPROC_NOOP is used to return errors when a valid | * should be cleared. NFSPROC_NOOP is used to return errors when a valid | ||||
* RPC procedure is not involved. | * RPC procedure is not involved. | ||||
* Returns the error number in XDR. | * Returns the error number in XDR. | ||||
*/ | */ | ||||
APPLESTATIC int | int | ||||
nfsd_errmap(struct nfsrv_descript *nd) | nfsd_errmap(struct nfsrv_descript *nd) | ||||
{ | { | ||||
short *defaulterrp, *errp; | short *defaulterrp, *errp; | ||||
if (!nd->nd_repstat) | if (!nd->nd_repstat) | ||||
return (0); | return (0); | ||||
if (nd->nd_flag & (ND_NFSV3 | ND_NFSV4)) { | if (nd->nd_flag & (ND_NFSV3 | ND_NFSV4)) { | ||||
if (nd->nd_procnum == NFSPROC_NOOP) | if (nd->nd_procnum == NFSPROC_NOOP) | ||||
Show All 39 Lines | nfsrv_isannfserr(u_int32_t errval) | ||||
return (NFSERR_IO); | return (NFSERR_IO); | ||||
} | } | ||||
/* | /* | ||||
* Check to see if setting a uid/gid is permitted when creating a new | * Check to see if setting a uid/gid is permitted when creating a new | ||||
* file object. (Called when uid and/or gid is specified in the | * file object. (Called when uid and/or gid is specified in the | ||||
* settable attributes for V4. | * settable attributes for V4. | ||||
*/ | */ | ||||
APPLESTATIC int | int | ||||
nfsrv_checkuidgid(struct nfsrv_descript *nd, struct nfsvattr *nvap) | nfsrv_checkuidgid(struct nfsrv_descript *nd, struct nfsvattr *nvap) | ||||
{ | { | ||||
int error = 0; | int error = 0; | ||||
/* | /* | ||||
* If not setting either uid nor gid, it's OK. | * If not setting either uid nor gid, it's OK. | ||||
*/ | */ | ||||
if (NFSVNO_NOTSETUID(nvap) && NFSVNO_NOTSETGID(nvap)) | if (NFSVNO_NOTSETUID(nvap) && NFSVNO_NOTSETGID(nvap)) | ||||
Show All 16 Lines | out: | ||||
NFSEXITCODE2(error, nd); | NFSEXITCODE2(error, nd); | ||||
return (error); | return (error); | ||||
} | } | ||||
/* | /* | ||||
* and this routine fixes up the settable attributes for V4 if allowed | * and this routine fixes up the settable attributes for V4 if allowed | ||||
* by nfsrv_checkuidgid(). | * by nfsrv_checkuidgid(). | ||||
*/ | */ | ||||
APPLESTATIC void | void | ||||
nfsrv_fixattr(struct nfsrv_descript *nd, vnode_t vp, | nfsrv_fixattr(struct nfsrv_descript *nd, vnode_t vp, | ||||
struct nfsvattr *nvap, NFSACL_T *aclp, NFSPROC_T *p, nfsattrbit_t *attrbitp, | struct nfsvattr *nvap, NFSACL_T *aclp, NFSPROC_T *p, nfsattrbit_t *attrbitp, | ||||
struct nfsexstuff *exp) | struct nfsexstuff *exp) | ||||
{ | { | ||||
int change = 0; | int change = 0; | ||||
struct nfsvattr nva; | struct nfsvattr nva; | ||||
uid_t tuid; | uid_t tuid; | ||||
int error; | int error; | ||||
▲ Show 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | nfsrv_hexdigit(char c, int *err) | ||||
*err = 1; | *err = 1; | ||||
return (1); /* BOGUS */ | return (1); /* BOGUS */ | ||||
} | } | ||||
/* | /* | ||||
* Check to see if NFSERR_MOVED can be returned for this op. Return 1 iff | * Check to see if NFSERR_MOVED can be returned for this op. Return 1 iff | ||||
* it can be. | * it can be. | ||||
*/ | */ | ||||
APPLESTATIC int | int | ||||
nfsrv_errmoved(int op) | nfsrv_errmoved(int op) | ||||
{ | { | ||||
short *errp; | short *errp; | ||||
errp = nfsrv_v4errmap[op]; | errp = nfsrv_v4errmap[op]; | ||||
while (*errp != 0) { | while (*errp != 0) { | ||||
if (*errp == NFSERR_MOVED) | if (*errp == NFSERR_MOVED) | ||||
return (1); | return (1); | ||||
errp++; | errp++; | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
/* | /* | ||||
* Fill in attributes for a Referral. | * Fill in attributes for a Referral. | ||||
* (Return the number of bytes of XDR created.) | * (Return the number of bytes of XDR created.) | ||||
*/ | */ | ||||
APPLESTATIC int | int | ||||
nfsrv_putreferralattr(struct nfsrv_descript *nd, nfsattrbit_t *retbitp, | nfsrv_putreferralattr(struct nfsrv_descript *nd, nfsattrbit_t *retbitp, | ||||
struct nfsreferral *refp, int getattr, int *reterrp) | struct nfsreferral *refp, int getattr, int *reterrp) | ||||
{ | { | ||||
u_int32_t *tl, *retnump; | u_int32_t *tl, *retnump; | ||||
u_char *cp, *cp2; | u_char *cp, *cp2; | ||||
int prefixnum, retnum = 0, i, len, bitpos, rderrbit = 0, nonrefbit = 0; | int prefixnum, retnum = 0, i, len, bitpos, rderrbit = 0, nonrefbit = 0; | ||||
int fslocationsbit = 0; | int fslocationsbit = 0; | ||||
nfsattrbit_t tmpbits, refbits; | nfsattrbit_t tmpbits, refbits; | ||||
▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | nfsrv_putreferralattr(struct nfsrv_descript *nd, nfsattrbit_t *retbitp, | ||||
} | } | ||||
*retnump = txdr_unsigned(retnum); | *retnump = txdr_unsigned(retnum); | ||||
return (retnum + prefixnum); | return (retnum + prefixnum); | ||||
} | } | ||||
/* | /* | ||||
* Parse a file name out of a request. | * Parse a file name out of a request. | ||||
*/ | */ | ||||
APPLESTATIC int | int | ||||
nfsrv_parsename(struct nfsrv_descript *nd, char *bufp, u_long *hashp, | nfsrv_parsename(struct nfsrv_descript *nd, char *bufp, u_long *hashp, | ||||
NFSPATHLEN_T *outlenp) | NFSPATHLEN_T *outlenp) | ||||
{ | { | ||||
char *fromcp, *tocp, val = '\0'; | char *fromcp, *tocp, val = '\0'; | ||||
struct mbuf *md; | struct mbuf *md; | ||||
int i; | int i; | ||||
int rem, len, error = 0, pubtype = 0, outlen = 0, percent = 0; | int rem, len, error = 0, pubtype = 0, outlen = 0, percent = 0; | ||||
char digit; | char digit; | ||||
▲ Show 20 Lines • Show All 290 Lines • Show Last 20 Lines |