2 * Copyright (c) 2000-2001 Boris Popov
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/kernel.h>
37 #include <sys/malloc.h>
41 #include <sys/sysctl.h>
42 #include <sys/socketvar.h>
44 #include <sys/iconv.h>
46 #include <netsmb/smb.h>
47 #include <netsmb/smb_subr.h>
48 #include <netsmb/smb_conn.h>
49 #include <netsmb/smb_tran.h>
50 #include <netsmb/smb_trantcp.h>
52 static struct smb_connobj smb_vclist;
53 static int smb_vcnext = 1; /* next unique id for VC */
55 SYSCTL_NODE(_net, OID_AUTO, smb, CTLFLAG_RW, NULL, "SMB protocol");
57 static MALLOC_DEFINE(M_SMBCONN, "smb_conn", "SMB connection");
59 static void smb_co_init(struct smb_connobj *cp, int level, char *ilockname,
61 static void smb_co_done(struct smb_connobj *cp);
62 static int smb_vc_disconnect(struct smb_vc *vcp);
63 static void smb_vc_free(struct smb_connobj *cp);
64 static void smb_vc_gone(struct smb_connobj *cp, struct smb_cred *scred);
65 static smb_co_free_t smb_share_free;
66 static smb_co_gone_t smb_share_gone;
68 static int smb_sysctl_treedump(SYSCTL_HANDLER_ARGS);
70 SYSCTL_PROC(_net_smb, OID_AUTO, treedump, CTLFLAG_RD | CTLTYPE_OPAQUE,
71 NULL, 0, smb_sysctl_treedump, "S,treedump", "Requester tree");
77 smb_co_init(&smb_vclist, SMBL_SM, "smbsm ilock", "smbsm");
78 sx_xlock(&smb_vclist.co_interlock);
79 smb_co_unlock(&smb_vclist);
80 sx_unlock(&smb_vclist.co_interlock);
88 /* XXX: hold the mutex */
89 if (smb_vclist.co_usecount > 1) {
90 SMBERROR("%d connections still active\n", smb_vclist.co_usecount - 1);
93 smb_co_done(&smb_vclist);
98 smb_sm_lockvclist(void)
102 sx_xlock(&smb_vclist.co_interlock);
103 error = smb_co_lock(&smb_vclist);
104 sx_unlock(&smb_vclist.co_interlock);
110 smb_sm_unlockvclist(void)
113 sx_xlock(&smb_vclist.co_interlock);
114 smb_co_unlock(&smb_vclist);
115 sx_unlock(&smb_vclist.co_interlock);
119 smb_sm_lookupint(struct smb_vcspec *vcspec, struct smb_sharespec *shspec,
120 struct smb_cred *scred, struct smb_vc **vcpp)
122 struct smb_connobj *scp;
127 vcspec->shspec = shspec;
130 SMBCO_FOREACH(scp, &smb_vclist) {
131 vcp = (struct smb_vc *)scp;
132 error = smb_vc_lock(vcp);
136 if ((vcp->obj.co_flags & SMBV_PRIVATE) ||
137 !CONNADDREQ(vcp->vc_paddr, vcspec->sap) ||
138 strcmp(vcp->vc_username, vcspec->username) != 0)
140 if (vcspec->owner != SMBM_ANY_OWNER) {
141 if (vcp->vc_uid != vcspec->owner)
145 if (vcspec->group != SMBM_ANY_GROUP) {
146 if (vcp->vc_grp != vcspec->group)
150 if (vcspec->mode & SMBM_EXACT) {
151 if (!exact || (vcspec->mode & SMBM_MASK) !=
155 if (smb_vc_access(vcp, scred, vcspec->mode) != 0)
159 error = (int)smb_vc_lookupshare(vcp, shspec, scred,
179 smb_sm_lookup(struct smb_vcspec *vcspec, struct smb_sharespec *shspec,
180 struct smb_cred *scred, struct smb_vc **vcpp)
183 struct smb_share *ssp = NULL;
188 error = smb_sm_lockvclist();
191 error = smb_sm_lookupint(vcspec, shspec, scred, vcpp);
192 if (error == 0 || (vcspec->flags & SMBV_CREATE) == 0) {
193 smb_sm_unlockvclist();
196 error = smb_sm_lookupint(vcspec, NULL, scred, &vcp);
198 error = smb_vc_create(vcspec, scred, &vcp);
201 error = smb_vc_connect(vcp, scred);
207 error = smb_share_create(vcp, shspec, scred, &ssp);
210 error = smb_smb_treeconnect(ssp, scred);
214 smb_share_put(ssp, scred);
216 smb_sm_unlockvclist();
221 smb_vc_put(vcp, scred);
227 * Common code for connection object
230 smb_co_init(struct smb_connobj *cp, int level, char *ilockname, char *lockname)
232 SLIST_INIT(&cp->co_children);
233 sx_init_flags(&cp->co_interlock, ilockname, SX_RECURSE);
234 cv_init(&cp->co_lock, "smblock");
236 cp->co_locker = NULL;
237 cp->co_level = level;
239 sx_xlock(&cp->co_interlock);
241 sx_unlock(&cp->co_interlock);
245 smb_co_done(struct smb_connobj *cp)
248 sx_destroy(&cp->co_interlock);
249 cv_destroy(&cp->co_lock);
250 cp->co_locker = NULL;
256 smb_co_gone(struct smb_connobj *cp, struct smb_cred *scred)
258 struct smb_connobj *parent;
261 cp->co_gone(cp, scred);
262 parent = cp->co_parent;
264 sx_xlock(&parent->co_interlock);
266 sx_unlock(&parent->co_interlock);
267 SLIST_REMOVE(&parent->co_children, cp, smb_connobj, co_next);
268 smb_co_put(parent, scred);
275 smb_co_ref(struct smb_connobj *cp)
278 sx_xlock(&cp->co_interlock);
280 sx_unlock(&cp->co_interlock);
284 smb_co_rele(struct smb_connobj *cp, struct smb_cred *scred)
287 sx_xlock(&cp->co_interlock);
289 if (cp->co_usecount > 1) {
291 sx_unlock(&cp->co_interlock);
294 if (cp->co_usecount == 0) {
295 SMBERROR("negative use_count for object %d", cp->co_level);
296 sx_unlock(&cp->co_interlock);
300 cp->co_flags |= SMBO_GONE;
301 sx_unlock(&cp->co_interlock);
302 smb_co_gone(cp, scred);
306 smb_co_get(struct smb_connobj *cp, struct smb_cred *scred)
310 MPASS(sx_xholder(&cp->co_interlock) == curthread);
312 error = smb_co_lock(cp);
319 smb_co_put(struct smb_connobj *cp, struct smb_cred *scred)
322 sx_xlock(&cp->co_interlock);
323 if (cp->co_usecount > 1) {
325 } else if (cp->co_usecount == 1) {
327 cp->co_flags |= SMBO_GONE;
329 SMBERROR("negative usecount");
332 sx_unlock(&cp->co_interlock);
333 if ((cp->co_flags & SMBO_GONE) == 0)
335 smb_co_gone(cp, scred);
339 smb_co_lock(struct smb_connobj *cp)
342 MPASS(sx_xholder(&cp->co_interlock) == curthread);
344 if (cp->co_flags & SMBO_GONE)
346 if (cp->co_locker == NULL) {
347 cp->co_locker = curthread;
350 if (cp->co_locker == curthread) {
354 cv_wait(&cp->co_lock, &cp->co_interlock);
359 smb_co_unlock(struct smb_connobj *cp)
362 MPASS(sx_xholder(&cp->co_interlock) == curthread);
363 MPASS(cp->co_locker == curthread);
364 if (cp->co_lockcnt != 0) {
368 cp->co_locker = NULL;
369 cv_signal(&cp->co_lock);
373 smb_co_addchild(struct smb_connobj *parent, struct smb_connobj *child)
377 SLIST_INSERT_HEAD(&parent->co_children, child, co_next);
378 child->co_parent = parent;
382 * Session implementation
386 smb_vc_create(struct smb_vcspec *vcspec,
387 struct smb_cred *scred, struct smb_vc **vcpp)
390 struct ucred *cred = scred->scr_cred;
391 uid_t uid = vcspec->owner;
392 gid_t gid = vcspec->group;
393 uid_t realuid = cred->cr_uid;
394 char *domain = vcspec->domain;
397 isroot = smb_suser(cred) == 0;
399 * Only superuser can create VCs with different uid and gid
401 if (uid != SMBM_ANY_OWNER && uid != realuid && !isroot)
403 if (gid != SMBM_ANY_GROUP && !groupmember(gid, cred) && !isroot)
406 vcp = smb_zmalloc(sizeof(*vcp), M_SMBCONN, M_WAITOK);
407 smb_co_init(VCTOCP(vcp), SMBL_VC, "smb_vc ilock", "smb_vc");
408 vcp->obj.co_free = smb_vc_free;
409 vcp->obj.co_gone = smb_vc_gone;
410 vcp->vc_number = smb_vcnext++;
411 vcp->vc_timo = SMB_DEFRQTIMO;
412 vcp->vc_smbuid = SMB_UID_UNKNOWN;
413 vcp->vc_mode = vcspec->rights & SMBM_MASK;
414 vcp->obj.co_flags = vcspec->flags & (SMBV_PRIVATE | SMBV_SINGLESHARE);
415 vcp->vc_tdesc = &smb_tran_nbtcp_desc;
417 vcp->vc_mackey = NULL;
418 vcp->vc_mackeylen = 0;
420 if (uid == SMBM_ANY_OWNER)
422 if (gid == SMBM_ANY_GROUP)
423 gid = cred->cr_groups[0];
427 smb_sl_init(&vcp->vc_stlock, "vcstlock");
430 vcp->vc_paddr = sodupsockaddr(vcspec->sap, M_WAITOK);
431 if (vcp->vc_paddr == NULL)
433 vcp->vc_laddr = sodupsockaddr(vcspec->lap, M_WAITOK);
434 if (vcp->vc_laddr == NULL)
436 vcp->vc_pass = smb_strdup(vcspec->pass);
437 if (vcp->vc_pass == NULL)
439 vcp->vc_domain = smb_strdup((domain && domain[0]) ? domain :
441 if (vcp->vc_domain == NULL)
443 vcp->vc_srvname = smb_strdup(vcspec->srvname);
444 if (vcp->vc_srvname == NULL)
446 vcp->vc_username = smb_strdup(vcspec->username);
447 if (vcp->vc_username == NULL)
449 error = (int)iconv_open("tolower", vcspec->localcs, &vcp->vc_tolower);
452 error = (int)iconv_open("toupper", vcspec->localcs, &vcp->vc_toupper);
455 if (vcspec->servercs[0]) {
456 error = (int)iconv_open(vcspec->servercs, vcspec->localcs,
457 &vcp->vc_cp_toserver);
460 error = (int)iconv_open(vcspec->localcs, vcspec->servercs,
461 &vcp->vc_cp_tolocal);
464 vcp->vc_toserver = vcp->vc_cp_toserver;
465 vcp->vc_tolocal = vcp->vc_cp_tolocal;
466 iconv_add(ENCODING_UNICODE, ENCODING_UNICODE, SMB_UNICODE_NAME);
467 iconv_add(ENCODING_UNICODE, SMB_UNICODE_NAME, ENCODING_UNICODE);
468 error = (int)iconv_open(SMB_UNICODE_NAME, vcspec->localcs,
469 &vcp->vc_ucs_toserver);
471 error = (int)iconv_open(vcspec->localcs, SMB_UNICODE_NAME,
472 &vcp->vc_ucs_tolocal);
475 if (vcp->vc_ucs_toserver)
476 iconv_close(vcp->vc_ucs_toserver);
477 vcp->vc_ucs_toserver = NULL;
478 vcp->vc_ucs_tolocal = NULL;
481 error = (int)smb_iod_create(vcp);
485 smb_co_addchild(&smb_vclist, VCTOCP(vcp));
489 smb_vc_put(vcp, scred);
494 smb_vc_free(struct smb_connobj *cp)
496 struct smb_vc *vcp = CPTOVC(cp);
499 smb_iod_destroy(vcp->vc_iod);
500 SMB_STRFREE(vcp->vc_username);
501 SMB_STRFREE(vcp->vc_srvname);
502 SMB_STRFREE(vcp->vc_pass);
503 SMB_STRFREE(vcp->vc_domain);
505 free(vcp->vc_mackey, M_SMBTEMP);
507 free(vcp->vc_paddr, M_SONAME);
509 free(vcp->vc_laddr, M_SONAME);
511 iconv_close(vcp->vc_tolower);
513 iconv_close(vcp->vc_toupper);
515 vcp->vc_tolocal = NULL;
516 if (vcp->vc_toserver)
517 vcp->vc_toserver = NULL;
518 if (vcp->vc_cp_tolocal)
519 iconv_close(vcp->vc_cp_tolocal);
520 if (vcp->vc_cp_toserver)
521 iconv_close(vcp->vc_cp_toserver);
522 if (vcp->vc_ucs_tolocal)
523 iconv_close(vcp->vc_ucs_tolocal);
524 if (vcp->vc_ucs_toserver)
525 iconv_close(vcp->vc_ucs_toserver);
526 smb_co_done(VCTOCP(vcp));
527 smb_sl_destroy(&vcp->vc_stlock);
528 free(vcp, M_SMBCONN);
532 * Called when use count of VC dropped to zero.
535 smb_vc_gone(struct smb_connobj *cp, struct smb_cred *scred)
537 struct smb_vc *vcp = CPTOVC(cp);
539 smb_vc_disconnect(vcp);
543 smb_vc_ref(struct smb_vc *vcp)
545 smb_co_ref(VCTOCP(vcp));
549 smb_vc_rele(struct smb_vc *vcp, struct smb_cred *scred)
551 smb_co_rele(VCTOCP(vcp), scred);
555 smb_vc_get(struct smb_vc *vcp, struct smb_cred *scred)
557 struct smb_connobj *cp;
561 sx_xlock(&cp->co_interlock);
562 error = smb_co_get(cp, scred);
563 sx_unlock(&cp->co_interlock);
568 smb_vc_put(struct smb_vc *vcp, struct smb_cred *scred)
570 smb_co_put(VCTOCP(vcp), scred);
574 smb_vc_lock(struct smb_vc *vcp)
576 struct smb_connobj *cp;
580 sx_xlock(&cp->co_interlock);
581 error = smb_co_lock(cp);
582 sx_unlock(&cp->co_interlock);
587 smb_vc_unlock(struct smb_vc *vcp)
590 struct smb_connobj *cp;
593 sx_xlock(&cp->co_interlock);
595 sx_unlock(&cp->co_interlock);
599 smb_vc_access(struct smb_vc *vcp, struct smb_cred *scred, mode_t mode)
601 struct ucred *cred = scred->scr_cred;
603 if (smb_suser(cred) == 0 || cred->cr_uid == vcp->vc_uid)
606 if (!groupmember(vcp->vc_grp, cred))
608 return (vcp->vc_mode & mode) == mode ? 0 : EACCES;
612 smb_vc_cmpshare(struct smb_share *ssp, struct smb_sharespec *dp)
616 if (strcmp(ssp->ss_name, dp->name) != 0)
618 if (dp->owner != SMBM_ANY_OWNER) {
619 if (ssp->ss_uid != dp->owner)
623 if (dp->group != SMBM_ANY_GROUP) {
624 if (ssp->ss_grp != dp->group)
629 if (dp->mode & SMBM_EXACT) {
632 return (dp->mode & SMBM_MASK) == ssp->ss_mode ? 0 : 1;
634 if (smb_share_access(ssp, dp->scred, dp->mode) != 0)
640 * Lookup share in the given VC. Share referenced and locked on return.
641 * VC expected to be locked on entry and will be left locked on exit.
644 smb_vc_lookupshare(struct smb_vc *vcp, struct smb_sharespec *dp,
645 struct smb_cred *scred, struct smb_share **sspp)
647 struct smb_connobj *scp = NULL;
648 struct smb_share *ssp = NULL;
653 SMBCO_FOREACH(scp, VCTOCP(vcp)) {
654 ssp = (struct smb_share *)scp;
655 error = smb_share_lock(ssp);
658 if (smb_vc_cmpshare(ssp, dp) == 0)
660 smb_share_unlock(ssp);
672 smb_vc_connect(struct smb_vc *vcp, struct smb_cred *scred)
675 return smb_iod_request(vcp->vc_iod, SMBIOD_EV_CONNECT | SMBIOD_EV_SYNC, NULL);
679 * Destroy VC to server, invalidate shares linked with it.
680 * Transport should be locked on entry.
683 smb_vc_disconnect(struct smb_vc *vcp)
686 if (vcp->vc_iod != NULL)
687 smb_iod_request(vcp->vc_iod, SMBIOD_EV_DISCONNECT |
688 SMBIOD_EV_SYNC, NULL);
692 static char smb_emptypass[] = "";
695 smb_vc_getpass(struct smb_vc *vcp)
699 return smb_emptypass;
703 smb_vc_getinfo(struct smb_vc *vcp, struct smb_vc_info *vip)
705 bzero(vip, sizeof(struct smb_vc_info));
706 vip->itype = SMB_INFO_VC;
707 vip->usecount = vcp->obj.co_usecount;
708 vip->uid = vcp->vc_uid;
709 vip->gid = vcp->vc_grp;
710 vip->mode = vcp->vc_mode;
711 vip->flags = vcp->obj.co_flags;
712 vip->sopt = vcp->vc_sopt;
713 vip->iodstate = vcp->vc_iod->iod_state;
714 bzero(&vip->sopt.sv_skey, sizeof(vip->sopt.sv_skey));
715 snprintf(vip->srvname, sizeof(vip->srvname), "%s", vcp->vc_srvname);
716 snprintf(vip->vcname, sizeof(vip->vcname), "%s", vcp->vc_username);
721 smb_vc_nextmid(struct smb_vc *vcp)
725 sx_xlock(&vcp->obj.co_interlock);
727 sx_unlock(&vcp->obj.co_interlock);
732 * Share implementation
735 * Allocate share structure and attach it to the given VC
736 * Connection expected to be locked on entry. Share will be returned
740 smb_share_create(struct smb_vc *vcp, struct smb_sharespec *shspec,
741 struct smb_cred *scred, struct smb_share **sspp)
743 struct smb_share *ssp;
744 struct ucred *cred = scred->scr_cred;
745 uid_t realuid = cred->cr_uid;
746 uid_t uid = shspec->owner;
747 gid_t gid = shspec->group;
750 isroot = smb_suser(cred) == 0;
752 * Only superuser can create shares with different uid and gid
754 if (uid != SMBM_ANY_OWNER && uid != realuid && !isroot)
756 if (gid != SMBM_ANY_GROUP && !groupmember(gid, cred) && !isroot)
758 error = smb_vc_lookupshare(vcp, shspec, scred, &ssp);
760 smb_share_put(ssp, scred);
763 if (uid == SMBM_ANY_OWNER)
765 if (gid == SMBM_ANY_GROUP)
766 gid = cred->cr_groups[0];
767 ssp = smb_zmalloc(sizeof(*ssp), M_SMBCONN, M_WAITOK);
768 smb_co_init(SSTOCP(ssp), SMBL_SHARE, "smbss ilock", "smbss");
769 ssp->obj.co_free = smb_share_free;
770 ssp->obj.co_gone = smb_share_gone;
771 smb_sl_init(&ssp->ss_stlock, "ssstlock");
772 ssp->ss_name = smb_strdup(shspec->name);
773 if (shspec->pass && shspec->pass[0])
774 ssp->ss_pass = smb_strdup(shspec->pass);
775 ssp->ss_type = shspec->stype;
776 ssp->ss_tid = SMB_TID_UNKNOWN;
779 ssp->ss_mode = shspec->rights & SMBM_MASK;
780 smb_co_addchild(VCTOCP(vcp), SSTOCP(ssp));
786 smb_share_free(struct smb_connobj *cp)
788 struct smb_share *ssp = CPTOSS(cp);
790 SMB_STRFREE(ssp->ss_name);
791 SMB_STRFREE(ssp->ss_pass);
792 smb_sl_destroy(&ssp->ss_stlock);
793 smb_co_done(SSTOCP(ssp));
794 free(ssp, M_SMBCONN);
798 smb_share_gone(struct smb_connobj *cp, struct smb_cred *scred)
800 struct smb_share *ssp = CPTOSS(cp);
802 smb_smb_treedisconnect(ssp, scred);
806 smb_share_ref(struct smb_share *ssp)
808 smb_co_ref(SSTOCP(ssp));
812 smb_share_rele(struct smb_share *ssp, struct smb_cred *scred)
814 smb_co_rele(SSTOCP(ssp), scred);
818 smb_share_get(struct smb_share *ssp, struct smb_cred *scred)
820 struct smb_connobj *cp = SSTOCP(ssp);
823 sx_xlock(&cp->co_interlock);
824 error = smb_co_get(cp, scred);
825 sx_unlock(&cp->co_interlock);
830 smb_share_put(struct smb_share *ssp, struct smb_cred *scred)
833 smb_co_put(SSTOCP(ssp), scred);
837 smb_share_lock(struct smb_share *ssp)
839 struct smb_connobj *cp;
843 sx_xlock(&cp->co_interlock);
844 error = smb_co_lock(cp);
845 sx_unlock(&cp->co_interlock);
850 smb_share_unlock(struct smb_share *ssp)
852 struct smb_connobj *cp;
855 sx_xlock(&cp->co_interlock);
857 sx_unlock(&cp->co_interlock);
861 smb_share_access(struct smb_share *ssp, struct smb_cred *scred, mode_t mode)
863 struct ucred *cred = scred->scr_cred;
865 if (smb_suser(cred) == 0 || cred->cr_uid == ssp->ss_uid)
868 if (!groupmember(ssp->ss_grp, cred))
870 return (ssp->ss_mode & mode) == mode ? 0 : EACCES;
874 smb_share_invalidate(struct smb_share *ssp)
876 ssp->ss_tid = SMB_TID_UNKNOWN;
880 smb_share_valid(struct smb_share *ssp)
882 return ssp->ss_tid != SMB_TID_UNKNOWN &&
883 ssp->ss_vcgenid == SSTOVC(ssp)->vc_genid;
887 smb_share_getpass(struct smb_share *ssp)
896 return smb_emptypass;
900 smb_share_getinfo(struct smb_share *ssp, struct smb_share_info *sip)
902 bzero(sip, sizeof(struct smb_share_info));
903 sip->itype = SMB_INFO_SHARE;
904 sip->usecount = ssp->obj.co_usecount;
905 sip->tid = ssp->ss_tid;
906 sip->type= ssp->ss_type;
907 sip->uid = ssp->ss_uid;
908 sip->gid = ssp->ss_grp;
909 sip->mode= ssp->ss_mode;
910 sip->flags = ssp->obj.co_flags;
911 snprintf(sip->sname, sizeof(sip->sname), "%s", ssp->ss_name);
916 * Dump an entire tree into sysctl call
919 smb_sysctl_treedump(SYSCTL_HANDLER_ARGS)
921 struct smb_connobj *scp1, *scp2;
923 struct smb_share *ssp;
924 struct smb_vc_info vci;
925 struct smb_share_info ssi;
928 error = sysctl_wire_old_buffer(req, 0);
931 error = smb_sm_lockvclist();
934 SMBCO_FOREACH(scp1, &smb_vclist) {
935 vcp = (struct smb_vc *)scp1;
936 error = smb_vc_lock(vcp);
939 smb_vc_getinfo(vcp, &vci);
940 error = SYSCTL_OUT(req, &vci, sizeof(struct smb_vc_info));
945 SMBCO_FOREACH(scp2, VCTOCP(vcp)) {
946 ssp = (struct smb_share *)scp2;
947 error = smb_share_lock(ssp);
952 smb_share_getinfo(ssp, &ssi);
953 smb_share_unlock(ssp);
954 error = SYSCTL_OUT(req, &ssi, sizeof(struct smb_share_info));
963 itype = SMB_INFO_NONE;
964 error = SYSCTL_OUT(req, &itype, sizeof(itype));
966 smb_sm_unlockvclist();