Changeset View
Changeset View
Standalone View
Standalone View
head/sys/fs/nfsclient/nfs_clrpcops.c
Show First 20 Lines • Show All 66 Lines • ▼ Show 20 Lines | |||||
NFSCLSTATEMUTEX; | NFSCLSTATEMUTEX; | ||||
int nfstest_outofseq = 0; | int nfstest_outofseq = 0; | ||||
int nfscl_assumeposixlocks = 1; | int nfscl_assumeposixlocks = 1; | ||||
int nfscl_enablecallb = 0; | int nfscl_enablecallb = 0; | ||||
short nfsv4_cbport = NFSV4_CBPORT; | short nfsv4_cbport = NFSV4_CBPORT; | ||||
int nfstest_openallsetattr = 0; | int nfstest_openallsetattr = 0; | ||||
#endif /* !APPLEKEXT */ | #endif /* !APPLEKEXT */ | ||||
#define DIRHDSIZ (sizeof (struct dirent) - (MAXNAMLEN + 1)) | #define DIRHDSIZ offsetof(struct dirent, d_name) | ||||
/* | /* | ||||
* nfscl_getsameserver() can return one of three values: | * nfscl_getsameserver() can return one of three values: | ||||
* NFSDSP_USETHISSESSION - Use this session for the DS. | * NFSDSP_USETHISSESSION - Use this session for the DS. | ||||
* NFSDSP_SEQTHISSESSION - Use the nfsclds_sequence field of this dsp for new | * NFSDSP_SEQTHISSESSION - Use the nfsclds_sequence field of this dsp for new | ||||
* session. | * session. | ||||
* NFSDSP_NOTFOUND - No matching server was found. | * NFSDSP_NOTFOUND - No matching server was found. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 2,772 Lines • ▼ Show 20 Lines | if (uiop->uio_offset == 0) { | ||||
dotdotfileid = dotfileid; | dotdotfileid = dotfileid; | ||||
} else { | } else { | ||||
error = nd->nd_repstat; | error = nd->nd_repstat; | ||||
} | } | ||||
mbuf_freem(nd->nd_mrep); | mbuf_freem(nd->nd_mrep); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
nd->nd_mrep = NULL; | nd->nd_mrep = NULL; | ||||
dp = (struct dirent *) CAST_DOWN(caddr_t, uio_iov_base(uiop)); | dp = (struct dirent *)uio_iov_base(uiop); | ||||
dp->d_off = 0; | |||||
dp->d_type = DT_DIR; | dp->d_type = DT_DIR; | ||||
dp->d_fileno = dotfileid; | dp->d_fileno = dotfileid; | ||||
dp->d_namlen = 1; | dp->d_namlen = 1; | ||||
*((uint64_t *)dp->d_name) = 0; /* Zero pad it. */ | |||||
dp->d_name[0] = '.'; | dp->d_name[0] = '.'; | ||||
dp->d_name[1] = '\0'; | dp->d_reclen = _GENERIC_DIRSIZ(dp) + NFSX_HYPER; | ||||
dp->d_reclen = DIRENT_SIZE(dp) + NFSX_HYPER; | |||||
/* | /* | ||||
* Just make these offset cookie 0. | * Just make these offset cookie 0. | ||||
*/ | */ | ||||
tl = (u_int32_t *)&dp->d_name[4]; | tl = (u_int32_t *)&dp->d_name[8]; | ||||
*tl++ = 0; | *tl++ = 0; | ||||
*tl = 0; | *tl = 0; | ||||
blksiz += dp->d_reclen; | blksiz += dp->d_reclen; | ||||
uio_uio_resid_add(uiop, -(dp->d_reclen)); | uio_uio_resid_add(uiop, -(dp->d_reclen)); | ||||
uiop->uio_offset += dp->d_reclen; | uiop->uio_offset += dp->d_reclen; | ||||
uio_iov_base_add(uiop, dp->d_reclen); | uio_iov_base_add(uiop, dp->d_reclen); | ||||
uio_iov_len_add(uiop, -(dp->d_reclen)); | uio_iov_len_add(uiop, -(dp->d_reclen)); | ||||
dp = (struct dirent *) CAST_DOWN(caddr_t, uio_iov_base(uiop)); | dp = (struct dirent *)uio_iov_base(uiop); | ||||
dp->d_off = 0; | |||||
dp->d_type = DT_DIR; | dp->d_type = DT_DIR; | ||||
dp->d_fileno = dotdotfileid; | dp->d_fileno = dotdotfileid; | ||||
dp->d_namlen = 2; | dp->d_namlen = 2; | ||||
*((uint64_t *)dp->d_name) = 0; | |||||
dp->d_name[0] = '.'; | dp->d_name[0] = '.'; | ||||
dp->d_name[1] = '.'; | dp->d_name[1] = '.'; | ||||
dp->d_name[2] = '\0'; | dp->d_reclen = _GENERIC_DIRSIZ(dp) + NFSX_HYPER; | ||||
dp->d_reclen = DIRENT_SIZE(dp) + NFSX_HYPER; | |||||
/* | /* | ||||
* Just make these offset cookie 0. | * Just make these offset cookie 0. | ||||
*/ | */ | ||||
tl = (u_int32_t *)&dp->d_name[4]; | tl = (u_int32_t *)&dp->d_name[8]; | ||||
*tl++ = 0; | *tl++ = 0; | ||||
*tl = 0; | *tl = 0; | ||||
blksiz += dp->d_reclen; | blksiz += dp->d_reclen; | ||||
uio_uio_resid_add(uiop, -(dp->d_reclen)); | uio_uio_resid_add(uiop, -(dp->d_reclen)); | ||||
uiop->uio_offset += dp->d_reclen; | uiop->uio_offset += dp->d_reclen; | ||||
uio_iov_base_add(uiop, dp->d_reclen); | uio_iov_base_add(uiop, dp->d_reclen); | ||||
uio_iov_len_add(uiop, -(dp->d_reclen)); | uio_iov_len_add(uiop, -(dp->d_reclen)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | while (more_dirs && bigenough) { | ||||
nfsva.na_fileid = | nfsva.na_fileid = | ||||
fxdr_unsigned(long, *tl++); | fxdr_unsigned(long, *tl++); | ||||
len = fxdr_unsigned(int, *tl); | len = fxdr_unsigned(int, *tl); | ||||
} | } | ||||
if (len <= 0 || len > NFS_MAXNAMLEN) { | if (len <= 0 || len > NFS_MAXNAMLEN) { | ||||
error = EBADRPC; | error = EBADRPC; | ||||
goto nfsmout; | goto nfsmout; | ||||
} | } | ||||
tlen = NFSM_RNDUP(len); | tlen = roundup2(len, 8); | ||||
if (tlen == len) | if (tlen == len) | ||||
tlen += 4; /* To ensure null termination */ | tlen += 8; /* To ensure null termination. */ | ||||
left = DIRBLKSIZ - blksiz; | left = DIRBLKSIZ - blksiz; | ||||
if ((int)(tlen + DIRHDSIZ + NFSX_HYPER) > left) { | if (_GENERIC_DIRLEN(len) + NFSX_HYPER > left) { | ||||
dp->d_reclen += left; | dp->d_reclen += left; | ||||
uio_iov_base_add(uiop, left); | uio_iov_base_add(uiop, left); | ||||
uio_iov_len_add(uiop, -(left)); | uio_iov_len_add(uiop, -(left)); | ||||
uio_uio_resid_add(uiop, -(left)); | uio_uio_resid_add(uiop, -(left)); | ||||
uiop->uio_offset += left; | uiop->uio_offset += left; | ||||
blksiz = 0; | blksiz = 0; | ||||
} | } | ||||
if ((int)(tlen + DIRHDSIZ + NFSX_HYPER) > uio_uio_resid(uiop)) | if (_GENERIC_DIRLEN(len) + NFSX_HYPER > | ||||
uio_uio_resid(uiop)) | |||||
bigenough = 0; | bigenough = 0; | ||||
if (bigenough) { | if (bigenough) { | ||||
dp = (struct dirent *) CAST_DOWN(caddr_t, uio_iov_base(uiop)); | dp = (struct dirent *)uio_iov_base(uiop); | ||||
dp->d_off = 0; | |||||
dp->d_namlen = len; | dp->d_namlen = len; | ||||
dp->d_reclen = tlen + DIRHDSIZ + NFSX_HYPER; | dp->d_reclen = _GENERIC_DIRLEN(len) + | ||||
NFSX_HYPER; | |||||
dp->d_type = DT_UNKNOWN; | dp->d_type = DT_UNKNOWN; | ||||
blksiz += dp->d_reclen; | blksiz += dp->d_reclen; | ||||
if (blksiz == DIRBLKSIZ) | if (blksiz == DIRBLKSIZ) | ||||
blksiz = 0; | blksiz = 0; | ||||
uio_uio_resid_add(uiop, -(DIRHDSIZ)); | uio_uio_resid_add(uiop, -(DIRHDSIZ)); | ||||
uiop->uio_offset += DIRHDSIZ; | uiop->uio_offset += DIRHDSIZ; | ||||
uio_iov_base_add(uiop, DIRHDSIZ); | uio_iov_base_add(uiop, DIRHDSIZ); | ||||
uio_iov_len_add(uiop, -(DIRHDSIZ)); | uio_iov_len_add(uiop, -(DIRHDSIZ)); | ||||
error = nfsm_mbufuio(nd, uiop, len); | error = nfsm_mbufuio(nd, uiop, len); | ||||
if (error) | if (error) | ||||
goto nfsmout; | goto nfsmout; | ||||
cp = CAST_DOWN(caddr_t, uio_iov_base(uiop)); | cp = uio_iov_base(uiop); | ||||
tlen -= len; | tlen -= len; | ||||
*cp = '\0'; /* null terminate */ | *cp = '\0'; /* null terminate */ | ||||
cp += tlen; /* points to cookie storage */ | cp += tlen; /* points to cookie storage */ | ||||
tl2 = (u_int32_t *)cp; | tl2 = (u_int32_t *)cp; | ||||
uio_iov_base_add(uiop, (tlen + NFSX_HYPER)); | uio_iov_base_add(uiop, (tlen + NFSX_HYPER)); | ||||
uio_iov_len_add(uiop, -(tlen + NFSX_HYPER)); | uio_iov_len_add(uiop, -(tlen + NFSX_HYPER)); | ||||
uio_uio_resid_add(uiop, -(tlen + NFSX_HYPER)); | uio_uio_resid_add(uiop, -(tlen + NFSX_HYPER)); | ||||
uiop->uio_offset += (tlen + NFSX_HYPER); | uiop->uio_offset += (tlen + NFSX_HYPER); | ||||
▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | else if (!bigenough) | ||||
*eofp = 0; | *eofp = 0; | ||||
else | else | ||||
*eofp = eof; | *eofp = eof; | ||||
} | } | ||||
/* | /* | ||||
* Add extra empty records to any remaining DIRBLKSIZ chunks. | * Add extra empty records to any remaining DIRBLKSIZ chunks. | ||||
*/ | */ | ||||
while (uio_uio_resid(uiop) > 0 && ((size_t)(uio_uio_resid(uiop))) != tresid) { | while (uio_uio_resid(uiop) > 0 && uio_uio_resid(uiop) != tresid) { | ||||
dp = (struct dirent *) CAST_DOWN(caddr_t, uio_iov_base(uiop)); | dp = (struct dirent *)uio_iov_base(uiop); | ||||
dp->d_type = DT_UNKNOWN; | dp->d_type = DT_UNKNOWN; | ||||
dp->d_fileno = 0; | dp->d_fileno = 0; | ||||
dp->d_namlen = 0; | dp->d_namlen = 0; | ||||
dp->d_name[0] = '\0'; | dp->d_name[0] = '\0'; | ||||
tl = (u_int32_t *)&dp->d_name[4]; | tl = (u_int32_t *)&dp->d_name[4]; | ||||
*tl++ = cookie.lval[0]; | *tl++ = cookie.lval[0]; | ||||
*tl = cookie.lval[1]; | *tl = cookie.lval[1]; | ||||
dp->d_reclen = DIRBLKSIZ; | dp->d_reclen = DIRBLKSIZ; | ||||
▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | if (uiop->uio_offset == 0) { | ||||
} else { | } else { | ||||
error = nd->nd_repstat; | error = nd->nd_repstat; | ||||
} | } | ||||
mbuf_freem(nd->nd_mrep); | mbuf_freem(nd->nd_mrep); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
nd->nd_mrep = NULL; | nd->nd_mrep = NULL; | ||||
dp = (struct dirent *)uio_iov_base(uiop); | dp = (struct dirent *)uio_iov_base(uiop); | ||||
dp->d_off = 0; | |||||
dp->d_type = DT_DIR; | dp->d_type = DT_DIR; | ||||
dp->d_fileno = dotfileid; | dp->d_fileno = dotfileid; | ||||
dp->d_namlen = 1; | dp->d_namlen = 1; | ||||
*((uint64_t *)dp->d_name) = 0; /* Zero pad it. */ | |||||
dp->d_name[0] = '.'; | dp->d_name[0] = '.'; | ||||
dp->d_name[1] = '\0'; | dp->d_reclen = _GENERIC_DIRSIZ(dp) + NFSX_HYPER; | ||||
dp->d_reclen = DIRENT_SIZE(dp) + NFSX_HYPER; | |||||
/* | /* | ||||
* Just make these offset cookie 0. | * Just make these offset cookie 0. | ||||
*/ | */ | ||||
tl = (u_int32_t *)&dp->d_name[4]; | tl = (u_int32_t *)&dp->d_name[8]; | ||||
*tl++ = 0; | *tl++ = 0; | ||||
*tl = 0; | *tl = 0; | ||||
blksiz += dp->d_reclen; | blksiz += dp->d_reclen; | ||||
uio_uio_resid_add(uiop, -(dp->d_reclen)); | uio_uio_resid_add(uiop, -(dp->d_reclen)); | ||||
uiop->uio_offset += dp->d_reclen; | uiop->uio_offset += dp->d_reclen; | ||||
uio_iov_base_add(uiop, dp->d_reclen); | uio_iov_base_add(uiop, dp->d_reclen); | ||||
uio_iov_len_add(uiop, -(dp->d_reclen)); | uio_iov_len_add(uiop, -(dp->d_reclen)); | ||||
dp = (struct dirent *)uio_iov_base(uiop); | dp = (struct dirent *)uio_iov_base(uiop); | ||||
dp->d_off = 0; | |||||
dp->d_type = DT_DIR; | dp->d_type = DT_DIR; | ||||
dp->d_fileno = dotdotfileid; | dp->d_fileno = dotdotfileid; | ||||
dp->d_namlen = 2; | dp->d_namlen = 2; | ||||
*((uint64_t *)dp->d_name) = 0; | |||||
dp->d_name[0] = '.'; | dp->d_name[0] = '.'; | ||||
dp->d_name[1] = '.'; | dp->d_name[1] = '.'; | ||||
dp->d_name[2] = '\0'; | dp->d_reclen = _GENERIC_DIRSIZ(dp) + NFSX_HYPER; | ||||
dp->d_reclen = DIRENT_SIZE(dp) + NFSX_HYPER; | |||||
/* | /* | ||||
* Just make these offset cookie 0. | * Just make these offset cookie 0. | ||||
*/ | */ | ||||
tl = (u_int32_t *)&dp->d_name[4]; | tl = (u_int32_t *)&dp->d_name[8]; | ||||
*tl++ = 0; | *tl++ = 0; | ||||
*tl = 0; | *tl = 0; | ||||
blksiz += dp->d_reclen; | blksiz += dp->d_reclen; | ||||
uio_uio_resid_add(uiop, -(dp->d_reclen)); | uio_uio_resid_add(uiop, -(dp->d_reclen)); | ||||
uiop->uio_offset += dp->d_reclen; | uiop->uio_offset += dp->d_reclen; | ||||
uio_iov_base_add(uiop, dp->d_reclen); | uio_iov_base_add(uiop, dp->d_reclen); | ||||
uio_iov_len_add(uiop, -(dp->d_reclen)); | uio_iov_len_add(uiop, -(dp->d_reclen)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | while (more_dirs && bigenough) { | ||||
fileno = fxdr_unsigned(long, *++tl); | fileno = fxdr_unsigned(long, *++tl); | ||||
tl++; | tl++; | ||||
} | } | ||||
len = fxdr_unsigned(int, *tl); | len = fxdr_unsigned(int, *tl); | ||||
if (len <= 0 || len > NFS_MAXNAMLEN) { | if (len <= 0 || len > NFS_MAXNAMLEN) { | ||||
error = EBADRPC; | error = EBADRPC; | ||||
goto nfsmout; | goto nfsmout; | ||||
} | } | ||||
tlen = NFSM_RNDUP(len); | tlen = roundup2(len, 8); | ||||
if (tlen == len) | if (tlen == len) | ||||
tlen += 4; /* To ensure null termination */ | tlen += 8; /* To ensure null termination. */ | ||||
left = DIRBLKSIZ - blksiz; | left = DIRBLKSIZ - blksiz; | ||||
if ((tlen + DIRHDSIZ + NFSX_HYPER) > left) { | if (_GENERIC_DIRLEN(len) + NFSX_HYPER > left) { | ||||
dp->d_reclen += left; | dp->d_reclen += left; | ||||
uio_iov_base_add(uiop, left); | uio_iov_base_add(uiop, left); | ||||
uio_iov_len_add(uiop, -(left)); | uio_iov_len_add(uiop, -(left)); | ||||
uio_uio_resid_add(uiop, -(left)); | uio_uio_resid_add(uiop, -(left)); | ||||
uiop->uio_offset += left; | uiop->uio_offset += left; | ||||
blksiz = 0; | blksiz = 0; | ||||
} | } | ||||
if ((tlen + DIRHDSIZ + NFSX_HYPER) > uio_uio_resid(uiop)) | if (_GENERIC_DIRLEN(len) + NFSX_HYPER > | ||||
uio_uio_resid(uiop)) | |||||
bigenough = 0; | bigenough = 0; | ||||
if (bigenough) { | if (bigenough) { | ||||
dp = (struct dirent *)uio_iov_base(uiop); | dp = (struct dirent *)uio_iov_base(uiop); | ||||
dp->d_off = 0; | |||||
dp->d_namlen = len; | dp->d_namlen = len; | ||||
dp->d_reclen = tlen + DIRHDSIZ + NFSX_HYPER; | dp->d_reclen = _GENERIC_DIRLEN(len) + | ||||
NFSX_HYPER; | |||||
dp->d_type = DT_UNKNOWN; | dp->d_type = DT_UNKNOWN; | ||||
blksiz += dp->d_reclen; | blksiz += dp->d_reclen; | ||||
if (blksiz == DIRBLKSIZ) | if (blksiz == DIRBLKSIZ) | ||||
blksiz = 0; | blksiz = 0; | ||||
uio_uio_resid_add(uiop, -(DIRHDSIZ)); | uio_uio_resid_add(uiop, -(DIRHDSIZ)); | ||||
uiop->uio_offset += DIRHDSIZ; | uiop->uio_offset += DIRHDSIZ; | ||||
uio_iov_base_add(uiop, DIRHDSIZ); | uio_iov_base_add(uiop, DIRHDSIZ); | ||||
uio_iov_len_add(uiop, -(DIRHDSIZ)); | uio_iov_len_add(uiop, -(DIRHDSIZ)); | ||||
▲ Show 20 Lines • Show All 2,582 Lines • Show Last 20 Lines |