Lines Matching defs:od

413 smb_odir_hold(smb_odir_t *od)
415 ASSERT(od);
416 ASSERT(od->d_magic == SMB_ODIR_MAGIC);
418 mutex_enter(&od->d_mutex);
420 switch (od->d_state) {
422 od->d_refcnt++;
423 od->d_state = SMB_ODIR_STATE_IN_USE;
426 od->d_refcnt++;
431 mutex_exit(&od->d_mutex);
435 mutex_exit(&od->d_mutex);
446 smb_odir_release(smb_odir_t *od)
448 SMB_ODIR_VALID(od);
450 mutex_enter(&od->d_mutex);
451 ASSERT(od->d_refcnt > 0);
453 switch (od->d_state) {
457 od->d_refcnt--;
458 if (od->d_refcnt == 0)
459 od->d_state = SMB_ODIR_STATE_OPEN;
462 od->d_refcnt--;
463 if (od->d_refcnt == 0) {
464 od->d_state = SMB_ODIR_STATE_CLOSED;
465 smb_tree_post_odir(od->d_tree, od);
473 mutex_exit(&od->d_mutex);
480 smb_odir_close(smb_odir_t *od)
482 ASSERT(od);
483 ASSERT(od->d_magic == SMB_ODIR_MAGIC);
485 mutex_enter(&od->d_mutex);
486 ASSERT(od->d_refcnt > 0);
487 switch (od->d_state) {
491 od->d_state = SMB_ODIR_STATE_CLOSING;
498 mutex_exit(&od->d_mutex);
516 smb_odir_read(smb_request_t *sr, smb_odir_t *od,
523 ASSERT(od);
524 ASSERT(od->d_magic == SMB_ODIR_MAGIC);
527 mutex_enter(&od->d_mutex);
528 ASSERT(od->d_refcnt > 0);
530 switch (od->d_state) {
537 mutex_exit(&od->d_mutex);
542 if ((rc = smb_odir_next_odirent(od, odirent)) != 0)
544 if (smb_odir_match_name(od, odirent))
548 mutex_exit(&od->d_mutex);
566 * and attributes: od->d_pattern and od->d_sattr.
587 smb_odir_read_fileinfo(smb_request_t *sr, smb_odir_t *od,
595 ASSERT(od);
596 ASSERT(od->d_magic == SMB_ODIR_MAGIC);
599 mutex_enter(&od->d_mutex);
600 ASSERT(od->d_refcnt > 0);
602 switch (od->d_state) {
609 mutex_exit(&od->d_mutex);
613 if ((od->d_flags & SMB_ODIR_FLAG_WILDCARDS) == 0) {
614 if (od->d_eof)
617 rc = smb_odir_single_fileinfo(sr, od, fileinfo);
618 od->d_eof = B_TRUE;
623 if ((rc = smb_odir_next_odirent(od, odirent)) != 0)
632 if (!smb_odir_match_name(od, odirent))
635 rc = smb_odir_wildcard_fileinfo(sr, od, odirent,
642 mutex_exit(&od->d_mutex);
672 smb_odir_read_streaminfo(smb_request_t *sr, smb_odir_t *od,
683 ASSERT(od);
684 ASSERT(od->d_magic == SMB_ODIR_MAGIC);
689 mutex_enter(&od->d_mutex);
690 ASSERT(od->d_refcnt > 0);
692 switch (od->d_state) {
699 mutex_exit(&od->d_mutex);
704 if (!(od->d_flags & SMB_ODIR_FLAG_XATTR)) {
706 mutex_exit(&od->d_mutex);
715 if ((rc = smb_odir_next_odirent(od, odirent)) != 0)
723 rc = smb_fsop_lookup(sr, od->d_cred, 0, od->d_tree->t_snode,
724 od->d_dnode, odirent->od_name, &fnode);
745 mutex_exit(&od->d_mutex);
768 smb_odir_save_cookie(smb_odir_t *od, int idx, uint32_t cookie)
770 ASSERT(od);
771 ASSERT(od->d_magic == SMB_ODIR_MAGIC);
774 mutex_enter(&od->d_mutex);
775 od->d_cookies[idx] = cookie;
776 mutex_exit(&od->d_mutex);
786 smb_odir_save_fname(smb_odir_t *od, uint32_t cookie, const char *fname)
788 ASSERT(od);
789 ASSERT(od->d_magic == SMB_ODIR_MAGIC);
791 mutex_enter(&od->d_mutex);
793 od->d_last_cookie = cookie;
794 bzero(od->d_last_name, MAXNAMELEN);
796 (void) strlcpy(od->d_last_name, fname, MAXNAMELEN);
798 mutex_exit(&od->d_mutex);
815 * smb_odir_resume_at indicates a new request, so reset od->d_bufptr
819 smb_odir_resume_at(smb_odir_t *od, smb_odir_resume_t *resume)
823 ASSERT(od);
824 ASSERT(od->d_magic == SMB_ODIR_MAGIC);
827 if ((od->d_flags & SMB_ODIR_FLAG_WILDCARDS) == 0) {
829 od->d_eof = B_FALSE;
832 mutex_enter(&od->d_mutex);
834 save_offset = od->d_offset;
854 od->d_offset = od->d_cookies[resume->or_idx];
858 od->d_offset = resume->or_cookie;
868 if (strcmp(resume->or_fname, od->d_last_name) &&
869 od->d_last_cookie != 0) {
870 od->d_offset = od->d_last_cookie;
872 od->d_offset = resume->or_cookie;
877 if (od->d_offset != save_offset) {
879 od->d_bufptr = NULL;
880 od->d_eof = B_FALSE;
883 mutex_exit(&od->d_mutex);
897 smb_odir_t *od;
909 od = kmem_cache_alloc(smb_cache_odir, KM_SLEEP);
910 bzero(od, sizeof (smb_odir_t));
912 mutex_init(&od->d_mutex, NULL, MUTEX_DEFAULT, NULL);
918 od->d_refcnt = 1;
919 od->d_state = SMB_ODIR_STATE_IN_USE;
920 od->d_magic = SMB_ODIR_MAGIC;
921 od->d_opened_by_pid = sr->smb_pid;
922 od->d_session = tree->t_session;
923 od->d_cred = cr;
925 * grab a ref for od->d_user
929 od->d_user = sr->uid_user;
930 od->d_tree = tree;
931 od->d_dnode = dnode;
933 od->d_odid = odid;
934 od->d_sattr = sattr;
935 (void) strlcpy(od->d_pattern, pattern, sizeof (od->d_pattern));
936 od->d_flags = 0;
937 if (smb_contains_wildcards(od->d_pattern))
938 od->d_flags |= SMB_ODIR_FLAG_WILDCARDS;
940 od->d_flags |= SMB_ODIR_FLAG_EDIRENT;
942 od->d_flags |= SMB_ODIR_FLAG_IGNORE_CASE;
944 od->d_flags |= SMB_ODIR_FLAG_SHORTNAMES;
946 od->d_flags |= SMB_ODIR_FLAG_CATIA;
948 od->d_flags |= SMB_ODIR_FLAG_ABE;
950 od->d_flags |= SMB_ODIR_FLAG_XATTR;
951 od->d_eof = B_FALSE;
954 smb_llist_insert_tail(&tree->t_odir_list, od);
958 return (od);
965 smb_odir_reopen(smb_odir_t *od, const char *pattern, uint16_t sattr)
968 SMB_ODIR_VALID(od);
970 mutex_enter(&od->d_mutex);
971 od->d_sattr = sattr;
972 (void) strlcpy(od->d_pattern, pattern, sizeof (od->d_pattern));
973 if (smb_contains_wildcards(od->d_pattern))
974 od->d_flags |= SMB_ODIR_FLAG_WILDCARDS;
976 od->d_flags &= ~SMB_ODIR_FLAG_WILDCARDS;
979 od->d_offset = 0;
980 od->d_bufptr = NULL;
981 od->d_eof = B_FALSE;
983 mutex_exit(&od->d_mutex);
996 smb_odir_t *od = (smb_odir_t *)arg;
998 SMB_ODIR_VALID(od);
999 ASSERT(od->d_refcnt == 0);
1000 ASSERT(od->d_state == SMB_ODIR_STATE_CLOSED);
1002 tree = od->d_tree;
1004 smb_llist_remove(&tree->t_odir_list, od);
1005 if (od->d_odid != 0)
1006 smb_idpool_free(&tree->t_odid_pool, od->d_odid);
1010 mutex_enter(&od->d_mutex);
1011 mutex_exit(&od->d_mutex);
1013 od->d_magic = 0;
1014 smb_node_release(od->d_dnode);
1015 smb_user_release(od->d_user);
1016 mutex_destroy(&od->d_mutex);
1017 kmem_cache_free(smb_cache_odir, od);
1043 smb_odir_next_odirent(smb_odir_t *od, smb_odirent_t *odirent)
1053 ASSERT(MUTEX_HELD(&od->d_mutex));
1057 if (od->d_bufptr != NULL) {
1058 if (od->d_flags & SMB_ODIR_FLAG_EDIRENT)
1059 reclen = od->d_edp->ed_reclen;
1061 reclen = od->d_dp->d_reclen;
1064 od->d_bufptr = NULL;
1066 od->d_bufptr += reclen;
1067 if (od->d_bufptr >= od->d_buf + od->d_bufsize)
1068 od->d_bufptr = NULL;
1072 if (od->d_bufptr == NULL) {
1073 if (od->d_eof)
1076 od->d_bufsize = sizeof (od->d_buf);
1078 if (od->d_flags & SMB_ODIR_FLAG_ABE)
1081 rc = smb_vop_readdir(od->d_dnode->vp, od->d_offset,
1082 od->d_buf, &od->d_bufsize, &eof, abe_flag, od->d_cred);
1084 if ((rc == 0) && (od->d_bufsize == 0))
1088 od->d_bufptr = NULL;
1089 od->d_bufsize = 0;
1093 od->d_eof = (eof != 0);
1094 od->d_bufptr = od->d_buf;
1097 if (od->d_flags & SMB_ODIR_FLAG_EDIRENT)
1098 od->d_offset = od->d_edp->ed_off;
1100 od->d_offset = od->d_dp->d_off;
1102 if (od->d_offset >= SMB_MAXDIRSIZE) {
1103 od->d_bufptr = NULL;
1104 od->d_bufsize = 0;
1105 od->d_eof = B_TRUE;
1109 if (od->d_flags & SMB_ODIR_FLAG_EDIRENT) {
1110 edp = od->d_edp;
1115 dp = od->d_dp;
1121 if ((od->d_flags & SMB_ODIR_FLAG_CATIA) &&
1122 ((od->d_flags & SMB_ODIR_FLAG_XATTR) == 0)) {
1136 * Lookup the file identified by od->d_pattern.
1149 smb_odir_single_fileinfo(smb_request_t *sr, smb_odir_t *od,
1163 ASSERT(od);
1164 ASSERT(od->d_magic == SMB_ODIR_MAGIC);
1166 ASSERT(MUTEX_HELD(&od->d_mutex));
1169 rc = smb_fsop_lookup(sr, od->d_cred, 0, od->d_tree->t_snode,
1170 od->d_dnode, od->d_pattern, &fnode);
1178 if (od->d_flags & SMB_ODIR_FLAG_IGNORE_CASE) {
1180 if (od->d_flags & SMB_ODIR_FLAG_CATIA)
1183 rc = smb_vop_lookup(od->d_dnode->vp, fnode->od_name, &vp,
1184 NULL, lookup_flags, &flags, od->d_tree->t_snode->vp,
1185 NULL, od->d_cred);
1205 smb_odir_lookup_link(sr, od, fnode->od_name, &tgt_node)) {
1217 if (!smb_sattr_check(attr.sa_dosattr, od->d_sattr)) {
1223 if (od->d_flags & SMB_ODIR_FLAG_SHORTNAMES) {
1274 smb_odir_wildcard_fileinfo(smb_request_t *sr, smb_odir_t *od,
1286 ASSERT(od);
1287 ASSERT(od->d_magic == SMB_ODIR_MAGIC);
1289 ASSERT(MUTEX_HELD(&od->d_mutex));
1292 rc = smb_fsop_lookup(sr, od->d_cred, SMB_CASE_SENSITIVE,
1293 od->d_tree->t_snode, od->d_dnode, odirent->od_name, &fnode);
1299 smb_odir_lookup_link(sr, od, odirent->od_name, &tgt_node)) {
1320 if (smb_tree_has_feature(od->d_tree, SMB_TREE_ABE))
1321 cr = od->d_cred;
1334 if (!smb_sattr_check(attr.sa_dosattr, od->d_sattr)) {
1340 if (od->d_flags & SMB_ODIR_FLAG_SHORTNAMES) {
1341 case_conflict = ((od->d_flags & SMB_ODIR_FLAG_IGNORE_CASE) &&
1353 fileinfo->fi_cookie = (uint32_t)od->d_offset;
1389 smb_odir_lookup_link(smb_request_t *sr, smb_odir_t *od,
1395 rc = smb_fsop_lookup(sr, od->d_cred, flags,
1396 od->d_tree->t_snode, od->d_dnode, fname, tgt_node);
1416 * - Check if odirent->od_name matches od->d_pattern.
1418 * odirent->od_name and check if it matches od->d_pattern.
1421 smb_odir_match_name(smb_odir_t *od, smb_odirent_t *odirent)
1426 boolean_t ci = (od->d_flags & SMB_ODIR_FLAG_IGNORE_CASE) != 0;
1431 if (smb_match(od->d_pattern, name, ci))
1434 if (od->d_flags & SMB_ODIR_FLAG_SHORTNAMES) {
1436 if (smb_match(od->d_pattern, shortname, ci))