2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
4 * Copyright (c) 2000-2001 Boris Popov
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/kernel.h>
39 #include <sys/malloc.h>
43 #include <sys/sysctl.h>
44 #include <sys/socketvar.h>
46 #include <sys/iconv.h>
48 #include <netsmb/smb.h>
49 #include <netsmb/smb_subr.h>
50 #include <netsmb/smb_conn.h>
51 #include <netsmb/smb_tran.h>
52 #include <netsmb/smb_trantcp.h>
54 static struct smb_connobj smb_vclist;
55 static int smb_vcnext = 1; /* next unique id for VC */
57 SYSCTL_NODE(_net, OID_AUTO, smb, CTLFLAG_RW | CTLFLAG_MPSAFE, NULL,
60 static MALLOC_DEFINE(M_SMBCONN, "smb_conn", "SMB connection");
62 static void smb_co_init(struct smb_connobj *cp, int level, char *ilockname,
64 static void smb_co_done(struct smb_connobj *cp);
65 static int smb_vc_disconnect(struct smb_vc *vcp);
66 static void smb_vc_free(struct smb_connobj *cp);
67 static void smb_vc_gone(struct smb_connobj *cp, struct smb_cred *scred);
68 static smb_co_free_t smb_share_free;
69 static smb_co_gone_t smb_share_gone;
71 static int smb_sysctl_treedump(SYSCTL_HANDLER_ARGS);
73 SYSCTL_PROC(_net_smb, OID_AUTO, treedump,
74 CTLFLAG_RD | CTLTYPE_OPAQUE | CTLFLAG_MPSAFE,
75 NULL, 0, smb_sysctl_treedump, "S,treedump",
82 smb_co_init(&smb_vclist, SMBL_SM, "smbsm ilock", "smbsm");
83 sx_xlock(&smb_vclist.co_interlock);
84 smb_co_unlock(&smb_vclist);
85 sx_unlock(&smb_vclist.co_interlock);
93 /* XXX: hold the mutex */
94 if (smb_vclist.co_usecount > 1) {
95 SMBERROR("%d connections still active\n", smb_vclist.co_usecount - 1);
98 smb_co_done(&smb_vclist);
103 smb_sm_lockvclist(void)
107 sx_xlock(&smb_vclist.co_interlock);
108 error = smb_co_lock(&smb_vclist);
109 sx_unlock(&smb_vclist.co_interlock);
115 smb_sm_unlockvclist(void)
118 sx_xlock(&smb_vclist.co_interlock);
119 smb_co_unlock(&smb_vclist);
120 sx_unlock(&smb_vclist.co_interlock);
124 smb_sm_lookupint(struct smb_vcspec *vcspec, struct smb_sharespec *shspec,
125 struct smb_cred *scred, struct smb_vc **vcpp)
127 struct smb_connobj *scp;
132 vcspec->shspec = shspec;
135 SMBCO_FOREACH(scp, &smb_vclist) {
136 vcp = (struct smb_vc *)scp;
137 error = smb_vc_lock(vcp);
141 if ((vcp->obj.co_flags & SMBV_PRIVATE) ||
142 !CONNADDREQ(vcp->vc_paddr, vcspec->sap) ||
143 strcmp(vcp->vc_username, vcspec->username) != 0)
145 if (vcspec->owner != SMBM_ANY_OWNER) {
146 if (vcp->vc_uid != vcspec->owner)
150 if (vcspec->group != SMBM_ANY_GROUP) {
151 if (vcp->vc_grp != vcspec->group)
155 if (vcspec->mode & SMBM_EXACT) {
156 if (!exact || (vcspec->mode & SMBM_MASK) !=
160 if (smb_vc_access(vcp, scred, vcspec->mode) != 0)
164 error = (int)smb_vc_lookupshare(vcp, shspec, scred,
184 smb_sm_lookup(struct smb_vcspec *vcspec, struct smb_sharespec *shspec,
185 struct smb_cred *scred, struct smb_vc **vcpp)
188 struct smb_share *ssp = NULL;
193 error = smb_sm_lockvclist();
196 error = smb_sm_lookupint(vcspec, shspec, scred, vcpp);
197 if (error == 0 || (vcspec->flags & SMBV_CREATE) == 0) {
198 smb_sm_unlockvclist();
201 error = smb_sm_lookupint(vcspec, NULL, scred, &vcp);
203 error = smb_vc_create(vcspec, scred, &vcp);
206 error = smb_vc_connect(vcp, scred);
212 error = smb_share_create(vcp, shspec, scred, &ssp);
215 error = smb_smb_treeconnect(ssp, scred);
219 smb_share_put(ssp, scred);
221 smb_sm_unlockvclist();
226 smb_vc_put(vcp, scred);
232 * Common code for connection object
235 smb_co_init(struct smb_connobj *cp, int level, char *ilockname, char *lockname)
237 SLIST_INIT(&cp->co_children);
238 sx_init_flags(&cp->co_interlock, ilockname, SX_RECURSE);
239 cv_init(&cp->co_lock, "smblock");
241 cp->co_locker = NULL;
242 cp->co_level = level;
244 sx_xlock(&cp->co_interlock);
246 sx_unlock(&cp->co_interlock);
250 smb_co_done(struct smb_connobj *cp)
253 sx_destroy(&cp->co_interlock);
254 cv_destroy(&cp->co_lock);
255 cp->co_locker = NULL;
261 smb_co_gone(struct smb_connobj *cp, struct smb_cred *scred)
263 struct smb_connobj *parent;
266 cp->co_gone(cp, scred);
267 parent = cp->co_parent;
269 sx_xlock(&parent->co_interlock);
271 sx_unlock(&parent->co_interlock);
272 SLIST_REMOVE(&parent->co_children, cp, smb_connobj, co_next);
273 smb_co_put(parent, scred);
280 smb_co_ref(struct smb_connobj *cp)
283 sx_xlock(&cp->co_interlock);
285 sx_unlock(&cp->co_interlock);
289 smb_co_rele(struct smb_connobj *cp, struct smb_cred *scred)
292 sx_xlock(&cp->co_interlock);
294 if (cp->co_usecount > 1) {
296 sx_unlock(&cp->co_interlock);
299 if (cp->co_usecount == 0) {
300 SMBERROR("negative use_count for object %d", cp->co_level);
301 sx_unlock(&cp->co_interlock);
305 cp->co_flags |= SMBO_GONE;
306 sx_unlock(&cp->co_interlock);
307 smb_co_gone(cp, scred);
311 smb_co_get(struct smb_connobj *cp, struct smb_cred *scred)
315 MPASS(sx_xholder(&cp->co_interlock) == curthread);
317 error = smb_co_lock(cp);
324 smb_co_put(struct smb_connobj *cp, struct smb_cred *scred)
327 sx_xlock(&cp->co_interlock);
328 if (cp->co_usecount > 1) {
330 } else if (cp->co_usecount == 1) {
332 cp->co_flags |= SMBO_GONE;
334 SMBERROR("negative usecount");
337 sx_unlock(&cp->co_interlock);
338 if ((cp->co_flags & SMBO_GONE) == 0)
340 smb_co_gone(cp, scred);
344 smb_co_lock(struct smb_connobj *cp)
347 MPASS(sx_xholder(&cp->co_interlock) == curthread);
349 if (cp->co_flags & SMBO_GONE)
351 if (cp->co_locker == NULL) {
352 cp->co_locker = curthread;
355 if (cp->co_locker == curthread) {
359 cv_wait(&cp->co_lock, &cp->co_interlock);
364 smb_co_unlock(struct smb_connobj *cp)
367 MPASS(sx_xholder(&cp->co_interlock) == curthread);
368 MPASS(cp->co_locker == curthread);
369 if (cp->co_lockcnt != 0) {
373 cp->co_locker = NULL;
374 cv_signal(&cp->co_lock);
378 smb_co_addchild(struct smb_connobj *parent, struct smb_connobj *child)
382 SLIST_INSERT_HEAD(&parent->co_children, child, co_next);
383 child->co_parent = parent;
387 * Session implementation
391 smb_vc_create(struct smb_vcspec *vcspec,
392 struct smb_cred *scred, struct smb_vc **vcpp)
395 struct ucred *cred = scred->scr_cred;
396 uid_t uid = vcspec->owner;
397 gid_t gid = vcspec->group;
398 uid_t realuid = cred->cr_uid;
399 char *domain = vcspec->domain;
402 isroot = smb_suser(cred) == 0;
404 * Only superuser can create VCs with different uid and gid
406 if (uid != SMBM_ANY_OWNER && uid != realuid && !isroot)
408 if (gid != SMBM_ANY_GROUP && !groupmember(gid, cred) && !isroot)
411 vcp = smb_zmalloc(sizeof(*vcp), M_SMBCONN, M_WAITOK);
412 smb_co_init(VCTOCP(vcp), SMBL_VC, "smb_vc ilock", "smb_vc");
413 vcp->obj.co_free = smb_vc_free;
414 vcp->obj.co_gone = smb_vc_gone;
415 vcp->vc_number = smb_vcnext++;
416 vcp->vc_timo = SMB_DEFRQTIMO;
417 vcp->vc_smbuid = SMB_UID_UNKNOWN;
418 vcp->vc_mode = vcspec->rights & SMBM_MASK;
419 vcp->obj.co_flags = vcspec->flags & (SMBV_PRIVATE | SMBV_SINGLESHARE);
420 vcp->vc_tdesc = &smb_tran_nbtcp_desc;
422 vcp->vc_mackey = NULL;
423 vcp->vc_mackeylen = 0;
425 if (uid == SMBM_ANY_OWNER)
427 if (gid == SMBM_ANY_GROUP)
428 gid = cred->cr_groups[0];
432 smb_sl_init(&vcp->vc_stlock, "vcstlock");
435 vcp->vc_paddr = sodupsockaddr(vcspec->sap, M_WAITOK);
436 if (vcp->vc_paddr == NULL)
438 vcp->vc_laddr = sodupsockaddr(vcspec->lap, M_WAITOK);
439 if (vcp->vc_laddr == NULL)
441 vcp->vc_pass = smb_strdup(vcspec->pass);
442 if (vcp->vc_pass == NULL)
444 vcp->vc_domain = smb_strdup((domain && domain[0]) ? domain :
446 if (vcp->vc_domain == NULL)
448 vcp->vc_srvname = smb_strdup(vcspec->srvname);
449 if (vcp->vc_srvname == NULL)
451 vcp->vc_username = smb_strdup(vcspec->username);
452 if (vcp->vc_username == NULL)
454 error = (int)iconv_open("tolower", vcspec->localcs, &vcp->vc_tolower);
457 error = (int)iconv_open("toupper", vcspec->localcs, &vcp->vc_toupper);
460 if (vcspec->servercs[0]) {
461 error = (int)iconv_open(vcspec->servercs, vcspec->localcs,
462 &vcp->vc_cp_toserver);
465 error = (int)iconv_open(vcspec->localcs, vcspec->servercs,
466 &vcp->vc_cp_tolocal);
469 vcp->vc_toserver = vcp->vc_cp_toserver;
470 vcp->vc_tolocal = vcp->vc_cp_tolocal;
471 iconv_add(ENCODING_UNICODE, ENCODING_UNICODE, SMB_UNICODE_NAME);
472 iconv_add(ENCODING_UNICODE, SMB_UNICODE_NAME, ENCODING_UNICODE);
473 error = (int)iconv_open(SMB_UNICODE_NAME, vcspec->localcs,
474 &vcp->vc_ucs_toserver);
476 error = (int)iconv_open(vcspec->localcs, SMB_UNICODE_NAME,
477 &vcp->vc_ucs_tolocal);
480 if (vcp->vc_ucs_toserver)
481 iconv_close(vcp->vc_ucs_toserver);
482 vcp->vc_ucs_toserver = NULL;
483 vcp->vc_ucs_tolocal = NULL;
486 error = (int)smb_iod_create(vcp);
490 smb_co_addchild(&smb_vclist, VCTOCP(vcp));
494 smb_vc_put(vcp, scred);
499 smb_vc_free(struct smb_connobj *cp)
501 struct smb_vc *vcp = CPTOVC(cp);
504 smb_iod_destroy(vcp->vc_iod);
505 SMB_STRFREE(vcp->vc_username);
506 SMB_STRFREE(vcp->vc_srvname);
507 SMB_STRFREE(vcp->vc_pass);
508 SMB_STRFREE(vcp->vc_domain);
510 free(vcp->vc_mackey, M_SMBTEMP);
512 free(vcp->vc_paddr, M_SONAME);
514 free(vcp->vc_laddr, M_SONAME);
516 iconv_close(vcp->vc_tolower);
518 iconv_close(vcp->vc_toupper);
520 vcp->vc_tolocal = NULL;
521 if (vcp->vc_toserver)
522 vcp->vc_toserver = NULL;
523 if (vcp->vc_cp_tolocal)
524 iconv_close(vcp->vc_cp_tolocal);
525 if (vcp->vc_cp_toserver)
526 iconv_close(vcp->vc_cp_toserver);
527 if (vcp->vc_ucs_tolocal)
528 iconv_close(vcp->vc_ucs_tolocal);
529 if (vcp->vc_ucs_toserver)
530 iconv_close(vcp->vc_ucs_toserver);
531 smb_co_done(VCTOCP(vcp));
532 smb_sl_destroy(&vcp->vc_stlock);
533 free(vcp, M_SMBCONN);
537 * Called when use count of VC dropped to zero.
540 smb_vc_gone(struct smb_connobj *cp, struct smb_cred *scred)
542 struct smb_vc *vcp = CPTOVC(cp);
544 smb_vc_disconnect(vcp);
548 smb_vc_ref(struct smb_vc *vcp)
550 smb_co_ref(VCTOCP(vcp));
554 smb_vc_rele(struct smb_vc *vcp, struct smb_cred *scred)
556 smb_co_rele(VCTOCP(vcp), scred);
560 smb_vc_get(struct smb_vc *vcp, struct smb_cred *scred)
562 struct smb_connobj *cp;
566 sx_xlock(&cp->co_interlock);
567 error = smb_co_get(cp, scred);
568 sx_unlock(&cp->co_interlock);
573 smb_vc_put(struct smb_vc *vcp, struct smb_cred *scred)
575 smb_co_put(VCTOCP(vcp), scred);
579 smb_vc_lock(struct smb_vc *vcp)
581 struct smb_connobj *cp;
585 sx_xlock(&cp->co_interlock);
586 error = smb_co_lock(cp);
587 sx_unlock(&cp->co_interlock);
592 smb_vc_unlock(struct smb_vc *vcp)
595 struct smb_connobj *cp;
598 sx_xlock(&cp->co_interlock);
600 sx_unlock(&cp->co_interlock);
604 smb_vc_access(struct smb_vc *vcp, struct smb_cred *scred, mode_t mode)
606 struct ucred *cred = scred->scr_cred;
608 if (smb_suser(cred) == 0 || cred->cr_uid == vcp->vc_uid)
611 if (!groupmember(vcp->vc_grp, cred))
613 return (vcp->vc_mode & mode) == mode ? 0 : EACCES;
617 smb_vc_cmpshare(struct smb_share *ssp, struct smb_sharespec *dp)
621 if (strcmp(ssp->ss_name, dp->name) != 0)
623 if (dp->owner != SMBM_ANY_OWNER) {
624 if (ssp->ss_uid != dp->owner)
628 if (dp->group != SMBM_ANY_GROUP) {
629 if (ssp->ss_grp != dp->group)
634 if (dp->mode & SMBM_EXACT) {
637 return (dp->mode & SMBM_MASK) == ssp->ss_mode ? 0 : 1;
639 if (smb_share_access(ssp, dp->scred, dp->mode) != 0)
645 * Lookup share in the given VC. Share referenced and locked on return.
646 * VC expected to be locked on entry and will be left locked on exit.
649 smb_vc_lookupshare(struct smb_vc *vcp, struct smb_sharespec *dp,
650 struct smb_cred *scred, struct smb_share **sspp)
652 struct smb_connobj *scp = NULL;
653 struct smb_share *ssp = NULL;
658 SMBCO_FOREACH(scp, VCTOCP(vcp)) {
659 ssp = (struct smb_share *)scp;
660 error = smb_share_lock(ssp);
663 if (smb_vc_cmpshare(ssp, dp) == 0)
665 smb_share_unlock(ssp);
677 smb_vc_connect(struct smb_vc *vcp, struct smb_cred *scred)
680 return smb_iod_request(vcp->vc_iod, SMBIOD_EV_CONNECT | SMBIOD_EV_SYNC, NULL);
684 * Destroy VC to server, invalidate shares linked with it.
685 * Transport should be locked on entry.
688 smb_vc_disconnect(struct smb_vc *vcp)
691 if (vcp->vc_iod != NULL)
692 smb_iod_request(vcp->vc_iod, SMBIOD_EV_DISCONNECT |
693 SMBIOD_EV_SYNC, NULL);
697 static char smb_emptypass[] = "";
700 smb_vc_getpass(struct smb_vc *vcp)
704 return smb_emptypass;
708 smb_vc_getinfo(struct smb_vc *vcp, struct smb_vc_info *vip)
710 bzero(vip, sizeof(struct smb_vc_info));
711 vip->itype = SMB_INFO_VC;
712 vip->usecount = vcp->obj.co_usecount;
713 vip->uid = vcp->vc_uid;
714 vip->gid = vcp->vc_grp;
715 vip->mode = vcp->vc_mode;
716 vip->flags = vcp->obj.co_flags;
717 vip->sopt = vcp->vc_sopt;
718 vip->iodstate = vcp->vc_iod->iod_state;
719 bzero(&vip->sopt.sv_skey, sizeof(vip->sopt.sv_skey));
720 snprintf(vip->srvname, sizeof(vip->srvname), "%s", vcp->vc_srvname);
721 snprintf(vip->vcname, sizeof(vip->vcname), "%s", vcp->vc_username);
726 smb_vc_nextmid(struct smb_vc *vcp)
730 sx_xlock(&vcp->obj.co_interlock);
732 sx_unlock(&vcp->obj.co_interlock);
737 * Share implementation
740 * Allocate share structure and attach it to the given VC
741 * Connection expected to be locked on entry. Share will be returned
745 smb_share_create(struct smb_vc *vcp, struct smb_sharespec *shspec,
746 struct smb_cred *scred, struct smb_share **sspp)
748 struct smb_share *ssp;
749 struct ucred *cred = scred->scr_cred;
750 uid_t realuid = cred->cr_uid;
751 uid_t uid = shspec->owner;
752 gid_t gid = shspec->group;
755 isroot = smb_suser(cred) == 0;
757 * Only superuser can create shares with different uid and gid
759 if (uid != SMBM_ANY_OWNER && uid != realuid && !isroot)
761 if (gid != SMBM_ANY_GROUP && !groupmember(gid, cred) && !isroot)
763 error = smb_vc_lookupshare(vcp, shspec, scred, &ssp);
765 smb_share_put(ssp, scred);
768 if (uid == SMBM_ANY_OWNER)
770 if (gid == SMBM_ANY_GROUP)
771 gid = cred->cr_groups[0];
772 ssp = smb_zmalloc(sizeof(*ssp), M_SMBCONN, M_WAITOK);
773 smb_co_init(SSTOCP(ssp), SMBL_SHARE, "smbss ilock", "smbss");
774 ssp->obj.co_free = smb_share_free;
775 ssp->obj.co_gone = smb_share_gone;
776 smb_sl_init(&ssp->ss_stlock, "ssstlock");
777 ssp->ss_name = smb_strdup(shspec->name);
778 if (shspec->pass && shspec->pass[0])
779 ssp->ss_pass = smb_strdup(shspec->pass);
780 ssp->ss_type = shspec->stype;
781 ssp->ss_tid = SMB_TID_UNKNOWN;
784 ssp->ss_mode = shspec->rights & SMBM_MASK;
785 smb_co_addchild(VCTOCP(vcp), SSTOCP(ssp));
791 smb_share_free(struct smb_connobj *cp)
793 struct smb_share *ssp = CPTOSS(cp);
795 SMB_STRFREE(ssp->ss_name);
796 SMB_STRFREE(ssp->ss_pass);
797 smb_sl_destroy(&ssp->ss_stlock);
798 smb_co_done(SSTOCP(ssp));
799 free(ssp, M_SMBCONN);
803 smb_share_gone(struct smb_connobj *cp, struct smb_cred *scred)
805 struct smb_share *ssp = CPTOSS(cp);
807 smb_smb_treedisconnect(ssp, scred);
811 smb_share_ref(struct smb_share *ssp)
813 smb_co_ref(SSTOCP(ssp));
817 smb_share_rele(struct smb_share *ssp, struct smb_cred *scred)
819 smb_co_rele(SSTOCP(ssp), scred);
823 smb_share_get(struct smb_share *ssp, struct smb_cred *scred)
825 struct smb_connobj *cp = SSTOCP(ssp);
828 sx_xlock(&cp->co_interlock);
829 error = smb_co_get(cp, scred);
830 sx_unlock(&cp->co_interlock);
835 smb_share_put(struct smb_share *ssp, struct smb_cred *scred)
838 smb_co_put(SSTOCP(ssp), scred);
842 smb_share_lock(struct smb_share *ssp)
844 struct smb_connobj *cp;
848 sx_xlock(&cp->co_interlock);
849 error = smb_co_lock(cp);
850 sx_unlock(&cp->co_interlock);
855 smb_share_unlock(struct smb_share *ssp)
857 struct smb_connobj *cp;
860 sx_xlock(&cp->co_interlock);
862 sx_unlock(&cp->co_interlock);
866 smb_share_access(struct smb_share *ssp, struct smb_cred *scred, mode_t mode)
868 struct ucred *cred = scred->scr_cred;
870 if (smb_suser(cred) == 0 || cred->cr_uid == ssp->ss_uid)
873 if (!groupmember(ssp->ss_grp, cred))
875 return (ssp->ss_mode & mode) == mode ? 0 : EACCES;
879 smb_share_invalidate(struct smb_share *ssp)
881 ssp->ss_tid = SMB_TID_UNKNOWN;
885 smb_share_valid(struct smb_share *ssp)
887 return ssp->ss_tid != SMB_TID_UNKNOWN &&
888 ssp->ss_vcgenid == SSTOVC(ssp)->vc_genid;
892 smb_share_getpass(struct smb_share *ssp)
901 return smb_emptypass;
905 smb_share_getinfo(struct smb_share *ssp, struct smb_share_info *sip)
907 bzero(sip, sizeof(struct smb_share_info));
908 sip->itype = SMB_INFO_SHARE;
909 sip->usecount = ssp->obj.co_usecount;
910 sip->tid = ssp->ss_tid;
911 sip->type= ssp->ss_type;
912 sip->uid = ssp->ss_uid;
913 sip->gid = ssp->ss_grp;
914 sip->mode= ssp->ss_mode;
915 sip->flags = ssp->obj.co_flags;
916 snprintf(sip->sname, sizeof(sip->sname), "%s", ssp->ss_name);
921 * Dump an entire tree into sysctl call
924 smb_sysctl_treedump(SYSCTL_HANDLER_ARGS)
926 struct smb_connobj *scp1, *scp2;
928 struct smb_share *ssp;
929 struct smb_vc_info vci;
930 struct smb_share_info ssi;
933 error = sysctl_wire_old_buffer(req, 0);
936 error = smb_sm_lockvclist();
939 SMBCO_FOREACH(scp1, &smb_vclist) {
940 vcp = (struct smb_vc *)scp1;
941 error = smb_vc_lock(vcp);
944 smb_vc_getinfo(vcp, &vci);
945 error = SYSCTL_OUT(req, &vci, sizeof(struct smb_vc_info));
950 SMBCO_FOREACH(scp2, VCTOCP(vcp)) {
951 ssp = (struct smb_share *)scp2;
952 error = smb_share_lock(ssp);
957 smb_share_getinfo(ssp, &ssi);
958 smb_share_unlock(ssp);
959 error = SYSCTL_OUT(req, &ssi, sizeof(struct smb_share_info));
968 itype = SMB_INFO_NONE;
969 error = SYSCTL_OUT(req, &itype, sizeof(itype));
971 smb_sm_unlockvclist();