Lines Matching refs:ctx

1736 smbfs_smb_search(struct smbfs_fctx *ctx)
1738 struct smb_vc *vcp = SSTOVC(ctx->f_ssp);
1746 maxent = min(ctx->f_left,
1748 if (ctx->f_rq) {
1749 smb_rq_done(ctx->f_rq);
1750 ctx->f_rq = NULL;
1752 error = smb_rq_alloc(SSTOCP(ctx->f_ssp), SMB_COM_SEARCH,
1753 ctx->f_scred, &rqp);
1756 ctx->f_rq = rqp;
1760 mb_put_uint16le(mbp, ctx->f_attrmask);
1764 if (ctx->f_flags & SMBFS_RDD_FINDFIRST) {
1765 error = smbfs_fullpath(mbp, vcp, ctx->f_dnp,
1766 ctx->f_wildcard, ctx->f_wclen, '\\');
1771 ctx->f_flags &= ~SMBFS_RDD_FINDFIRST;
1780 mb_put_mem(mbp, (char *)ctx->f_skey, SMB_SKEYLEN, MB_MSYSTEM);
1787 ctx->f_flags |= SMBFS_RDD_EOF;
1804 ctx->f_ecnt = ec;
1818 smbfs_smb_findopenLM1(struct smbfs_fctx *ctx, struct smbnode *dnp,
1822 ctx->f_type = ft_LM1;
1823 ctx->f_attrmask = attr;
1826 ctx->f_wildcard = "*.*";
1827 ctx->f_wclen = 3;
1829 ctx->f_wildcard = wildcard;
1830 ctx->f_wclen = wclen;
1833 ctx->f_wildcard = NULL;
1834 ctx->f_wclen = 0;
1836 ctx->f_name = (char *)ctx->f_fname;
1837 ctx->f_namesz = 0;
1842 smbfs_smb_findnextLM1(struct smbfs_fctx *ctx, uint16_t limit)
1853 if (ctx->f_ecnt == 0) {
1854 if (ctx->f_flags & SMBFS_RDD_EOF)
1856 ctx->f_left = ctx->f_limit = limit;
1858 error = smbfs_smb_search(ctx);
1862 rqp = ctx->f_rq;
1864 md_get_mem(mdp, (char *)ctx->f_skey, SMB_SKEYLEN, MB_MSYSTEM);
1869 cp = ctx->f_name;
1870 error = md_get_mem(mdp, cp, sizeof (ctx->f_fname), MB_MSYSTEM);
1871 cp[sizeof (ctx->f_fname) - 1] = 0;
1873 while (*cp == ' ' && cp >= ctx->f_name)
1875 ctx->f_attr.fa_attr = battr;
1877 &ctx->f_attr.fa_mtime);
1878 ctx->f_attr.fa_size = size;
1879 ctx->f_nmlen = strlen(ctx->f_name);
1880 ctx->f_ecnt--;
1881 ctx->f_left--;
1886 smbfs_smb_findcloseLM1(struct smbfs_fctx *ctx)
1888 if (ctx->f_rq)
1889 smb_rq_done(ctx->f_rq);
1897 smbfs_smb_trans2find2(struct smbfs_fctx *ctx)
1900 struct smb_vc *vcp = SSTOVC(ctx->f_ssp);
1906 if (ctx->f_t2) {
1907 smb_t2_done(ctx->f_t2);
1908 ctx->f_t2 = NULL;
1911 if (ctx->f_flags & SMBFS_RDD_FINDSINGLE) {
1913 ctx->f_flags |= SMBFS_RDD_NOCLOSE;
1915 if (ctx->f_flags & SMBFS_RDD_FINDFIRST) {
1916 error = smb_t2_alloc(SSTOCP(ctx->f_ssp), SMB_TRANS2_FIND_FIRST2,
1917 ctx->f_scred, &t2p);
1920 ctx->f_t2 = t2p;
1923 mb_put_uint16le(mbp, ctx->f_attrmask);
1924 mb_put_uint16le(mbp, ctx->f_limit);
1926 mb_put_uint16le(mbp, ctx->f_infolevel);
1928 error = smbfs_fullpath(mbp, vcp, ctx->f_dnp,
1929 ctx->f_wildcard, ctx->f_wclen, '\\');
1933 error = smb_t2_alloc(SSTOCP(ctx->f_ssp), SMB_TRANS2_FIND_NEXT2,
1934 ctx->f_scred, &t2p);
1937 ctx->f_t2 = t2p;
1940 mb_put_uint16le(mbp, ctx->f_Sid);
1941 mb_put_uint16le(mbp, ctx->f_limit);
1942 mb_put_uint16le(mbp, ctx->f_infolevel);
1944 mb_put_uint32le(mbp, ctx->f_rkey);
1947 if (ctx->f_rname) {
1949 mb_put_mem(mbp, ctx->f_rname, ctx->f_rnamelen,
1953 if (SMB_UNICODE_STRINGS(SSTOVC(ctx->f_ssp)))
1970 if (ctx->f_rname) {
1971 kmem_free(ctx->f_rname, ctx->f_rnamelen);
1972 ctx->f_rname = NULL;
1973 ctx->f_rnamelen = 0;
1977 if (ctx->f_flags & SMBFS_RDD_FINDFIRST) {
1978 if ((error = md_get_uint16le(mdp, &ctx->f_Sid)) != 0)
1980 ctx->f_flags &= ~SMBFS_RDD_FINDFIRST;
1996 ctx->f_ecnt = ecnt;
1997 if (eos || ctx->f_ecnt == 0)
1998 ctx->f_flags |= SMBFS_RDD_EOF | SMBFS_RDD_NOCLOSE;
1999 if (ctx->f_ecnt == 0)
2003 ctx->f_rnameofs = lno;
2004 ctx->f_eofs = 0;
2013 ctx->f_ecnt = 0; /* Force closed. */
2014 ctx->f_flags |= SMBFS_RDD_EOF;
2019 smbfs_smb_findclose2(struct smbfs_fctx *ctx)
2025 error = smb_rq_init(rqp, SSTOCP(ctx->f_ssp), SMB_COM_FIND_CLOSE2,
2026 ctx->f_scred);
2031 mb_put_uint16le(mbp, ctx->f_Sid);
2044 smbfs_smb_findopenLM2(struct smbfs_fctx *ctx, struct smbnode *dnp,
2048 ctx->f_type = ft_LM2;
2049 ctx->f_namesz = SMB_MAXFNAMELEN + 1;
2050 if (SMB_UNICODE_STRINGS(SSTOVC(ctx->f_ssp)))
2051 ctx->f_namesz *= 2;
2052 ctx->f_name = kmem_alloc(ctx->f_namesz, KM_SLEEP);
2053 ctx->f_infolevel = SMB_DIALECT(SSTOVC(ctx->f_ssp))
2056 ctx->f_attrmask = attr;
2057 ctx->f_wildcard = wildcard;
2058 ctx->f_wclen = wclen;
2063 smbfs_smb_findnextLM2(struct smbfs_fctx *ctx, uint16_t limit)
2075 if (ctx->f_ecnt == 0) {
2076 if (ctx->f_flags & SMBFS_RDD_EOF)
2078 ctx->f_left = ctx->f_limit = limit;
2080 error = smbfs_smb_trans2find2(ctx);
2083 ctx->f_otws++;
2085 t2p = ctx->f_t2;
2087 svtz = SSTOVC(ctx->f_ssp)->vc_sopt.sv_tz;
2088 switch (ctx->f_infolevel) {
2095 &ctx->f_attr.fa_createtime);
2098 smb_dos2unixtime(date, time, 0, svtz, &ctx->f_attr.fa_atime);
2101 smb_dos2unixtime(date, time, 0, svtz, &ctx->f_attr.fa_mtime);
2103 ctx->f_attr.fa_size = size;
2105 ctx->f_attr.fa_allocsz = size;
2107 ctx->f_attr.fa_attr = wattr;
2120 smb_time_NT2local(llongint, &ctx->f_attr.fa_createtime);
2122 smb_time_NT2local(llongint, &ctx->f_attr.fa_atime);
2124 smb_time_NT2local(llongint, &ctx->f_attr.fa_mtime);
2126 smb_time_NT2local(llongint, &ctx->f_attr.fa_ctime);
2128 ctx->f_attr.fa_size = llongint;
2130 ctx->f_attr.fa_allocsz = llongint;
2132 ctx->f_attr.fa_attr = dattr;
2137 if (ctx->f_infolevel == SMB_FIND_BOTH_DIRECTORY_INFO) {
2151 SMBVDEBUG("unexpected info level %d\n", ctx->f_infolevel);
2155 if (SMB_UNICODE_STRINGS(SSTOVC(ctx->f_ssp)))
2161 ASSERT(nmlen < ctx->f_namesz);
2162 cp = ctx->f_name;
2178 if (SMB_UNICODE_STRINGS(SSTOVC(ctx->f_ssp))) {
2198 ctx->f_rkey = resumekey;
2200 next = ctx->f_eofs + recsz;
2201 if (ctx->f_rnameofs &&
2202 ctx->f_rnameofs >= ctx->f_eofs &&
2203 ctx->f_rnameofs < (int)next) {
2208 if (ctx->f_rnamelen != nmlen) {
2209 if (ctx->f_rname)
2210 kmem_free(ctx->f_rname, ctx->f_rnamelen);
2211 ctx->f_rname = kmem_alloc(nmlen, KM_SLEEP);
2212 ctx->f_rnamelen = nmlen;
2214 bcopy(ctx->f_name, ctx->f_rname, nmlen);
2216 ctx->f_nmlen = nmlen;
2217 ctx->f_eofs = next;
2218 ctx->f_ecnt--;
2219 ctx->f_left--;
2221 smbfs_fname_tolocal(ctx);
2232 ctx->f_ecnt = 0; /* Force closed. */
2233 ctx->f_flags |= SMBFS_RDD_EOF;
2238 smbfs_smb_findcloseLM2(struct smbfs_fctx *ctx)
2241 if (ctx->f_name)
2242 kmem_free(ctx->f_name, ctx->f_namesz);
2243 if (ctx->f_t2)
2244 smb_t2_done(ctx->f_t2);
2250 if ((ctx->f_flags & (SMBFS_RDD_FINDFIRST | SMBFS_RDD_NOCLOSE)) == 0)
2251 error = smbfs_smb_findclose2(ctx);
2260 struct smbfs_fctx *ctx;
2263 ctx = kmem_zalloc(sizeof (*ctx), KM_SLEEP);
2265 ctx->f_flags = SMBFS_RDD_FINDFIRST;
2266 ctx->f_dnp = dnp;
2267 ctx->f_scred = scrp;
2268 ctx->f_ssp = dnp->n_mount->smi_share;
2271 error = smbfs_xa_findopen(ctx, dnp, wild, wlen);
2275 if (SMB_DIALECT(SSTOVC(ctx->f_ssp)) < SMB_DIALECT_LANMAN2_0) {
2276 error = smbfs_smb_findopenLM1(ctx, dnp, wild, wlen, attr);
2278 error = smbfs_smb_findopenLM2(ctx, dnp, wild, wlen, attr);
2283 (void) smbfs_smb_findclose(ctx, scrp);
2285 *ctxpp = ctx;
2290 smbfs_smb_findnext(struct smbfs_fctx *ctx, int limit, struct smb_cred *scrp)
2300 ctx->f_scred = scrp;
2302 bzero(&ctx->f_attr, sizeof (ctx->f_attr));
2303 switch (ctx->f_type) {
2305 error = smbfs_smb_findnextLM1(ctx, (uint16_t)limit);
2308 error = smbfs_smb_findnextLM2(ctx, (uint16_t)limit);
2311 error = smbfs_xa_findnext(ctx, (uint16_t)limit);
2321 * Skip "." or ".." - easy now that ctx->f_name
2324 if ((ctx->f_nmlen == 1 && ctx->f_name[0] == '.') ||
2325 (ctx->f_nmlen == 2 && ctx->f_name[0] == '.' &&
2326 ctx->f_name[1] == '.'))
2332 * Moved the smbfs_fname_tolocal(ctx) call into
2336 ctx->f_inum = smbfs_getino(ctx->f_dnp, ctx->f_name, ctx->f_nmlen);
2342 smbfs_smb_findclose(struct smbfs_fctx *ctx, struct smb_cred *scrp)
2346 ctx->f_scred = scrp;
2347 switch (ctx->f_type) {
2349 error = smbfs_smb_findcloseLM1(ctx);
2352 error = smbfs_smb_findcloseLM2(ctx);
2355 error = smbfs_xa_findclose(ctx);
2358 if (ctx->f_rname)
2359 kmem_free(ctx->f_rname, ctx->f_rnamelen);
2360 if (ctx->f_firstnm)
2361 kmem_free(ctx->f_firstnm, ctx->f_firstnmlen);
2362 kmem_free(ctx, sizeof (*ctx));
2371 struct smbfs_fctx *ctx;
2417 SMB_FA_SYSTEM | SMB_FA_HIDDEN | SMB_FA_DIR, scrp, &ctx);
2420 ctx->f_flags |= SMBFS_RDD_FINDSINGLE;
2421 error = smbfs_smb_findnext(ctx, 1, scrp);
2423 *fap = ctx->f_attr;
2431 ctx->f_name, ctx->f_nmlen);
2433 *nmlenp = ctx->f_nmlen;
2435 (void) smbfs_smb_findclose(ctx, scrp);