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, NULL, "SMB protocol");
59 static MALLOC_DEFINE(M_SMBCONN, "smb_conn", "SMB connection");
61 static void smb_co_init(struct smb_connobj *cp, int level, char *ilockname,
63 static void smb_co_done(struct smb_connobj *cp);
64 static int smb_vc_disconnect(struct smb_vc *vcp);
65 static void smb_vc_free(struct smb_connobj *cp);
66 static void smb_vc_gone(struct smb_connobj *cp, struct smb_cred *scred);
67 static smb_co_free_t smb_share_free;
68 static smb_co_gone_t smb_share_gone;
70 static int smb_sysctl_treedump(SYSCTL_HANDLER_ARGS);
72 SYSCTL_PROC(_net_smb, OID_AUTO, treedump, CTLFLAG_RD | CTLTYPE_OPAQUE,
73 NULL, 0, smb_sysctl_treedump, "S,treedump", "Requester tree");
79 smb_co_init(&smb_vclist, SMBL_SM, "smbsm ilock", "smbsm");
80 sx_xlock(&smb_vclist.co_interlock);
81 smb_co_unlock(&smb_vclist);
82 sx_unlock(&smb_vclist.co_interlock);
90 /* XXX: hold the mutex */
91 if (smb_vclist.co_usecount > 1) {
92 SMBERROR("%d connections still active\n", smb_vclist.co_usecount - 1);
95 smb_co_done(&smb_vclist);
100 smb_sm_lockvclist(void)
104 sx_xlock(&smb_vclist.co_interlock);
105 error = smb_co_lock(&smb_vclist);
106 sx_unlock(&smb_vclist.co_interlock);
112 smb_sm_unlockvclist(void)
115 sx_xlock(&smb_vclist.co_interlock);
116 smb_co_unlock(&smb_vclist);
117 sx_unlock(&smb_vclist.co_interlock);
121 smb_sm_lookupint(struct smb_vcspec *vcspec, struct smb_sharespec *shspec,
122 struct smb_cred *scred, struct smb_vc **vcpp)
124 struct smb_connobj *scp;
129 vcspec->shspec = shspec;
132 SMBCO_FOREACH(scp, &smb_vclist) {
133 vcp = (struct smb_vc *)scp;
134 error = smb_vc_lock(vcp);
138 if ((vcp->obj.co_flags & SMBV_PRIVATE) ||
139 !CONNADDREQ(vcp->vc_paddr, vcspec->sap) ||
140 strcmp(vcp->vc_username, vcspec->username) != 0)
142 if (vcspec->owner != SMBM_ANY_OWNER) {
143 if (vcp->vc_uid != vcspec->owner)
147 if (vcspec->group != SMBM_ANY_GROUP) {
148 if (vcp->vc_grp != vcspec->group)
152 if (vcspec->mode & SMBM_EXACT) {
153 if (!exact || (vcspec->mode & SMBM_MASK) !=
157 if (smb_vc_access(vcp, scred, vcspec->mode) != 0)
161 error = (int)smb_vc_lookupshare(vcp, shspec, scred,
181 smb_sm_lookup(struct smb_vcspec *vcspec, struct smb_sharespec *shspec,
182 struct smb_cred *scred, struct smb_vc **vcpp)
185 struct smb_share *ssp = NULL;
190 error = smb_sm_lockvclist();
193 error = smb_sm_lookupint(vcspec, shspec, scred, vcpp);
194 if (error == 0 || (vcspec->flags & SMBV_CREATE) == 0) {
195 smb_sm_unlockvclist();
198 error = smb_sm_lookupint(vcspec, NULL, scred, &vcp);
200 error = smb_vc_create(vcspec, scred, &vcp);
203 error = smb_vc_connect(vcp, scred);
209 error = smb_share_create(vcp, shspec, scred, &ssp);
212 error = smb_smb_treeconnect(ssp, scred);
216 smb_share_put(ssp, scred);
218 smb_sm_unlockvclist();
223 smb_vc_put(vcp, scred);
229 * Common code for connection object
232 smb_co_init(struct smb_connobj *cp, int level, char *ilockname, char *lockname)
234 SLIST_INIT(&cp->co_children);
235 sx_init_flags(&cp->co_interlock, ilockname, SX_RECURSE);
236 cv_init(&cp->co_lock, "smblock");
238 cp->co_locker = NULL;
239 cp->co_level = level;
241 sx_xlock(&cp->co_interlock);
243 sx_unlock(&cp->co_interlock);
247 smb_co_done(struct smb_connobj *cp)
250 sx_destroy(&cp->co_interlock);
251 cv_destroy(&cp->co_lock);
252 cp->co_locker = NULL;
258 smb_co_gone(struct smb_connobj *cp, struct smb_cred *scred)
260 struct smb_connobj *parent;
263 cp->co_gone(cp, scred);
264 parent = cp->co_parent;
266 sx_xlock(&parent->co_interlock);
268 sx_unlock(&parent->co_interlock);
269 SLIST_REMOVE(&parent->co_children, cp, smb_connobj, co_next);
270 smb_co_put(parent, scred);
277 smb_co_ref(struct smb_connobj *cp)
280 sx_xlock(&cp->co_interlock);
282 sx_unlock(&cp->co_interlock);
286 smb_co_rele(struct smb_connobj *cp, struct smb_cred *scred)
289 sx_xlock(&cp->co_interlock);
291 if (cp->co_usecount > 1) {
293 sx_unlock(&cp->co_interlock);
296 if (cp->co_usecount == 0) {
297 SMBERROR("negative use_count for object %d", cp->co_level);
298 sx_unlock(&cp->co_interlock);
302 cp->co_flags |= SMBO_GONE;
303 sx_unlock(&cp->co_interlock);
304 smb_co_gone(cp, scred);
308 smb_co_get(struct smb_connobj *cp, struct smb_cred *scred)
312 MPASS(sx_xholder(&cp->co_interlock) == curthread);
314 error = smb_co_lock(cp);
321 smb_co_put(struct smb_connobj *cp, struct smb_cred *scred)
324 sx_xlock(&cp->co_interlock);
325 if (cp->co_usecount > 1) {
327 } else if (cp->co_usecount == 1) {
329 cp->co_flags |= SMBO_GONE;
331 SMBERROR("negative usecount");
334 sx_unlock(&cp->co_interlock);
335 if ((cp->co_flags & SMBO_GONE) == 0)
337 smb_co_gone(cp, scred);
341 smb_co_lock(struct smb_connobj *cp)
344 MPASS(sx_xholder(&cp->co_interlock) == curthread);
346 if (cp->co_flags & SMBO_GONE)
348 if (cp->co_locker == NULL) {
349 cp->co_locker = curthread;
352 if (cp->co_locker == curthread) {
356 cv_wait(&cp->co_lock, &cp->co_interlock);
361 smb_co_unlock(struct smb_connobj *cp)
364 MPASS(sx_xholder(&cp->co_interlock) == curthread);
365 MPASS(cp->co_locker == curthread);
366 if (cp->co_lockcnt != 0) {
370 cp->co_locker = NULL;
371 cv_signal(&cp->co_lock);
375 smb_co_addchild(struct smb_connobj *parent, struct smb_connobj *child)
379 SLIST_INSERT_HEAD(&parent->co_children, child, co_next);
380 child->co_parent = parent;
384 * Session implementation
388 smb_vc_create(struct smb_vcspec *vcspec,
389 struct smb_cred *scred, struct smb_vc **vcpp)
392 struct ucred *cred = scred->scr_cred;
393 uid_t uid = vcspec->owner;
394 gid_t gid = vcspec->group;
395 uid_t realuid = cred->cr_uid;
396 char *domain = vcspec->domain;
399 isroot = smb_suser(cred) == 0;
401 * Only superuser can create VCs with different uid and gid
403 if (uid != SMBM_ANY_OWNER && uid != realuid && !isroot)
405 if (gid != SMBM_ANY_GROUP && !groupmember(gid, cred) && !isroot)
408 vcp = smb_zmalloc(sizeof(*vcp), M_SMBCONN, M_WAITOK);
409 smb_co_init(VCTOCP(vcp), SMBL_VC, "smb_vc ilock", "smb_vc");
410 vcp->obj.co_free = smb_vc_free;
411 vcp->obj.co_gone = smb_vc_gone;
412 vcp->vc_number = smb_vcnext++;
413 vcp->vc_timo = SMB_DEFRQTIMO;
414 vcp->vc_smbuid = SMB_UID_UNKNOWN;
415 vcp->vc_mode = vcspec->rights & SMBM_MASK;
416 vcp->obj.co_flags = vcspec->flags & (SMBV_PRIVATE | SMBV_SINGLESHARE);
417 vcp->vc_tdesc = &smb_tran_nbtcp_desc;
419 vcp->vc_mackey = NULL;
420 vcp->vc_mackeylen = 0;
422 if (uid == SMBM_ANY_OWNER)
424 if (gid == SMBM_ANY_GROUP)
425 gid = cred->cr_groups[0];
429 smb_sl_init(&vcp->vc_stlock, "vcstlock");
432 vcp->vc_paddr = sodupsockaddr(vcspec->sap, M_WAITOK);
433 if (vcp->vc_paddr == NULL)
435 vcp->vc_laddr = sodupsockaddr(vcspec->lap, M_WAITOK);
436 if (vcp->vc_laddr == NULL)
438 vcp->vc_pass = smb_strdup(vcspec->pass);
439 if (vcp->vc_pass == NULL)
441 vcp->vc_domain = smb_strdup((domain && domain[0]) ? domain :
443 if (vcp->vc_domain == NULL)
445 vcp->vc_srvname = smb_strdup(vcspec->srvname);
446 if (vcp->vc_srvname == NULL)
448 vcp->vc_username = smb_strdup(vcspec->username);
449 if (vcp->vc_username == NULL)
451 error = (int)iconv_open("tolower", vcspec->localcs, &vcp->vc_tolower);
454 error = (int)iconv_open("toupper", vcspec->localcs, &vcp->vc_toupper);
457 if (vcspec->servercs[0]) {
458 error = (int)iconv_open(vcspec->servercs, vcspec->localcs,
459 &vcp->vc_cp_toserver);
462 error = (int)iconv_open(vcspec->localcs, vcspec->servercs,
463 &vcp->vc_cp_tolocal);
466 vcp->vc_toserver = vcp->vc_cp_toserver;
467 vcp->vc_tolocal = vcp->vc_cp_tolocal;
468 iconv_add(ENCODING_UNICODE, ENCODING_UNICODE, SMB_UNICODE_NAME);
469 iconv_add(ENCODING_UNICODE, SMB_UNICODE_NAME, ENCODING_UNICODE);
470 error = (int)iconv_open(SMB_UNICODE_NAME, vcspec->localcs,
471 &vcp->vc_ucs_toserver);
473 error = (int)iconv_open(vcspec->localcs, SMB_UNICODE_NAME,
474 &vcp->vc_ucs_tolocal);
477 if (vcp->vc_ucs_toserver)
478 iconv_close(vcp->vc_ucs_toserver);
479 vcp->vc_ucs_toserver = NULL;
480 vcp->vc_ucs_tolocal = NULL;
483 error = (int)smb_iod_create(vcp);
487 smb_co_addchild(&smb_vclist, VCTOCP(vcp));
491 smb_vc_put(vcp, scred);
496 smb_vc_free(struct smb_connobj *cp)
498 struct smb_vc *vcp = CPTOVC(cp);
501 smb_iod_destroy(vcp->vc_iod);
502 SMB_STRFREE(vcp->vc_username);
503 SMB_STRFREE(vcp->vc_srvname);
504 SMB_STRFREE(vcp->vc_pass);
505 SMB_STRFREE(vcp->vc_domain);
507 free(vcp->vc_mackey, M_SMBTEMP);
509 free(vcp->vc_paddr, M_SONAME);
511 free(vcp->vc_laddr, M_SONAME);
513 iconv_close(vcp->vc_tolower);
515 iconv_close(vcp->vc_toupper);
517 vcp->vc_tolocal = NULL;
518 if (vcp->vc_toserver)
519 vcp->vc_toserver = NULL;
520 if (vcp->vc_cp_tolocal)
521 iconv_close(vcp->vc_cp_tolocal);
522 if (vcp->vc_cp_toserver)
523 iconv_close(vcp->vc_cp_toserver);
524 if (vcp->vc_ucs_tolocal)
525 iconv_close(vcp->vc_ucs_tolocal);
526 if (vcp->vc_ucs_toserver)
527 iconv_close(vcp->vc_ucs_toserver);
528 smb_co_done(VCTOCP(vcp));
529 smb_sl_destroy(&vcp->vc_stlock);
530 free(vcp, M_SMBCONN);
534 * Called when use count of VC dropped to zero.
537 smb_vc_gone(struct smb_connobj *cp, struct smb_cred *scred)
539 struct smb_vc *vcp = CPTOVC(cp);
541 smb_vc_disconnect(vcp);
545 smb_vc_ref(struct smb_vc *vcp)
547 smb_co_ref(VCTOCP(vcp));
551 smb_vc_rele(struct smb_vc *vcp, struct smb_cred *scred)
553 smb_co_rele(VCTOCP(vcp), scred);
557 smb_vc_get(struct smb_vc *vcp, struct smb_cred *scred)
559 struct smb_connobj *cp;
563 sx_xlock(&cp->co_interlock);
564 error = smb_co_get(cp, scred);
565 sx_unlock(&cp->co_interlock);
570 smb_vc_put(struct smb_vc *vcp, struct smb_cred *scred)
572 smb_co_put(VCTOCP(vcp), scred);
576 smb_vc_lock(struct smb_vc *vcp)
578 struct smb_connobj *cp;
582 sx_xlock(&cp->co_interlock);
583 error = smb_co_lock(cp);
584 sx_unlock(&cp->co_interlock);
589 smb_vc_unlock(struct smb_vc *vcp)
592 struct smb_connobj *cp;
595 sx_xlock(&cp->co_interlock);
597 sx_unlock(&cp->co_interlock);
601 smb_vc_access(struct smb_vc *vcp, struct smb_cred *scred, mode_t mode)
603 struct ucred *cred = scred->scr_cred;
605 if (smb_suser(cred) == 0 || cred->cr_uid == vcp->vc_uid)
608 if (!groupmember(vcp->vc_grp, cred))
610 return (vcp->vc_mode & mode) == mode ? 0 : EACCES;
614 smb_vc_cmpshare(struct smb_share *ssp, struct smb_sharespec *dp)
618 if (strcmp(ssp->ss_name, dp->name) != 0)
620 if (dp->owner != SMBM_ANY_OWNER) {
621 if (ssp->ss_uid != dp->owner)
625 if (dp->group != SMBM_ANY_GROUP) {
626 if (ssp->ss_grp != dp->group)
631 if (dp->mode & SMBM_EXACT) {
634 return (dp->mode & SMBM_MASK) == ssp->ss_mode ? 0 : 1;
636 if (smb_share_access(ssp, dp->scred, dp->mode) != 0)
642 * Lookup share in the given VC. Share referenced and locked on return.
643 * VC expected to be locked on entry and will be left locked on exit.
646 smb_vc_lookupshare(struct smb_vc *vcp, struct smb_sharespec *dp,
647 struct smb_cred *scred, struct smb_share **sspp)
649 struct smb_connobj *scp = NULL;
650 struct smb_share *ssp = NULL;
655 SMBCO_FOREACH(scp, VCTOCP(vcp)) {
656 ssp = (struct smb_share *)scp;
657 error = smb_share_lock(ssp);
660 if (smb_vc_cmpshare(ssp, dp) == 0)
662 smb_share_unlock(ssp);
674 smb_vc_connect(struct smb_vc *vcp, struct smb_cred *scred)
677 return smb_iod_request(vcp->vc_iod, SMBIOD_EV_CONNECT | SMBIOD_EV_SYNC, NULL);
681 * Destroy VC to server, invalidate shares linked with it.
682 * Transport should be locked on entry.
685 smb_vc_disconnect(struct smb_vc *vcp)
688 if (vcp->vc_iod != NULL)
689 smb_iod_request(vcp->vc_iod, SMBIOD_EV_DISCONNECT |
690 SMBIOD_EV_SYNC, NULL);
694 static char smb_emptypass[] = "";
697 smb_vc_getpass(struct smb_vc *vcp)
701 return smb_emptypass;
705 smb_vc_getinfo(struct smb_vc *vcp, struct smb_vc_info *vip)
707 bzero(vip, sizeof(struct smb_vc_info));
708 vip->itype = SMB_INFO_VC;
709 vip->usecount = vcp->obj.co_usecount;
710 vip->uid = vcp->vc_uid;
711 vip->gid = vcp->vc_grp;
712 vip->mode = vcp->vc_mode;
713 vip->flags = vcp->obj.co_flags;
714 vip->sopt = vcp->vc_sopt;
715 vip->iodstate = vcp->vc_iod->iod_state;
716 bzero(&vip->sopt.sv_skey, sizeof(vip->sopt.sv_skey));
717 snprintf(vip->srvname, sizeof(vip->srvname), "%s", vcp->vc_srvname);
718 snprintf(vip->vcname, sizeof(vip->vcname), "%s", vcp->vc_username);
723 smb_vc_nextmid(struct smb_vc *vcp)
727 sx_xlock(&vcp->obj.co_interlock);
729 sx_unlock(&vcp->obj.co_interlock);
734 * Share implementation
737 * Allocate share structure and attach it to the given VC
738 * Connection expected to be locked on entry. Share will be returned
742 smb_share_create(struct smb_vc *vcp, struct smb_sharespec *shspec,
743 struct smb_cred *scred, struct smb_share **sspp)
745 struct smb_share *ssp;
746 struct ucred *cred = scred->scr_cred;
747 uid_t realuid = cred->cr_uid;
748 uid_t uid = shspec->owner;
749 gid_t gid = shspec->group;
752 isroot = smb_suser(cred) == 0;
754 * Only superuser can create shares with different uid and gid
756 if (uid != SMBM_ANY_OWNER && uid != realuid && !isroot)
758 if (gid != SMBM_ANY_GROUP && !groupmember(gid, cred) && !isroot)
760 error = smb_vc_lookupshare(vcp, shspec, scred, &ssp);
762 smb_share_put(ssp, scred);
765 if (uid == SMBM_ANY_OWNER)
767 if (gid == SMBM_ANY_GROUP)
768 gid = cred->cr_groups[0];
769 ssp = smb_zmalloc(sizeof(*ssp), M_SMBCONN, M_WAITOK);
770 smb_co_init(SSTOCP(ssp), SMBL_SHARE, "smbss ilock", "smbss");
771 ssp->obj.co_free = smb_share_free;
772 ssp->obj.co_gone = smb_share_gone;
773 smb_sl_init(&ssp->ss_stlock, "ssstlock");
774 ssp->ss_name = smb_strdup(shspec->name);
775 if (shspec->pass && shspec->pass[0])
776 ssp->ss_pass = smb_strdup(shspec->pass);
777 ssp->ss_type = shspec->stype;
778 ssp->ss_tid = SMB_TID_UNKNOWN;
781 ssp->ss_mode = shspec->rights & SMBM_MASK;
782 smb_co_addchild(VCTOCP(vcp), SSTOCP(ssp));
788 smb_share_free(struct smb_connobj *cp)
790 struct smb_share *ssp = CPTOSS(cp);
792 SMB_STRFREE(ssp->ss_name);
793 SMB_STRFREE(ssp->ss_pass);
794 smb_sl_destroy(&ssp->ss_stlock);
795 smb_co_done(SSTOCP(ssp));
796 free(ssp, M_SMBCONN);
800 smb_share_gone(struct smb_connobj *cp, struct smb_cred *scred)
802 struct smb_share *ssp = CPTOSS(cp);
804 smb_smb_treedisconnect(ssp, scred);
808 smb_share_ref(struct smb_share *ssp)
810 smb_co_ref(SSTOCP(ssp));
814 smb_share_rele(struct smb_share *ssp, struct smb_cred *scred)
816 smb_co_rele(SSTOCP(ssp), scred);
820 smb_share_get(struct smb_share *ssp, struct smb_cred *scred)
822 struct smb_connobj *cp = SSTOCP(ssp);
825 sx_xlock(&cp->co_interlock);
826 error = smb_co_get(cp, scred);
827 sx_unlock(&cp->co_interlock);
832 smb_share_put(struct smb_share *ssp, struct smb_cred *scred)
835 smb_co_put(SSTOCP(ssp), scred);
839 smb_share_lock(struct smb_share *ssp)
841 struct smb_connobj *cp;
845 sx_xlock(&cp->co_interlock);
846 error = smb_co_lock(cp);
847 sx_unlock(&cp->co_interlock);
852 smb_share_unlock(struct smb_share *ssp)
854 struct smb_connobj *cp;
857 sx_xlock(&cp->co_interlock);
859 sx_unlock(&cp->co_interlock);
863 smb_share_access(struct smb_share *ssp, struct smb_cred *scred, mode_t mode)
865 struct ucred *cred = scred->scr_cred;
867 if (smb_suser(cred) == 0 || cred->cr_uid == ssp->ss_uid)
870 if (!groupmember(ssp->ss_grp, cred))
872 return (ssp->ss_mode & mode) == mode ? 0 : EACCES;
876 smb_share_invalidate(struct smb_share *ssp)
878 ssp->ss_tid = SMB_TID_UNKNOWN;
882 smb_share_valid(struct smb_share *ssp)
884 return ssp->ss_tid != SMB_TID_UNKNOWN &&
885 ssp->ss_vcgenid == SSTOVC(ssp)->vc_genid;
889 smb_share_getpass(struct smb_share *ssp)
898 return smb_emptypass;
902 smb_share_getinfo(struct smb_share *ssp, struct smb_share_info *sip)
904 bzero(sip, sizeof(struct smb_share_info));
905 sip->itype = SMB_INFO_SHARE;
906 sip->usecount = ssp->obj.co_usecount;
907 sip->tid = ssp->ss_tid;
908 sip->type= ssp->ss_type;
909 sip->uid = ssp->ss_uid;
910 sip->gid = ssp->ss_grp;
911 sip->mode= ssp->ss_mode;
912 sip->flags = ssp->obj.co_flags;
913 snprintf(sip->sname, sizeof(sip->sname), "%s", ssp->ss_name);
918 * Dump an entire tree into sysctl call
921 smb_sysctl_treedump(SYSCTL_HANDLER_ARGS)
923 struct smb_connobj *scp1, *scp2;
925 struct smb_share *ssp;
926 struct smb_vc_info vci;
927 struct smb_share_info ssi;
930 error = sysctl_wire_old_buffer(req, 0);
933 error = smb_sm_lockvclist();
936 SMBCO_FOREACH(scp1, &smb_vclist) {
937 vcp = (struct smb_vc *)scp1;
938 error = smb_vc_lock(vcp);
941 smb_vc_getinfo(vcp, &vci);
942 error = SYSCTL_OUT(req, &vci, sizeof(struct smb_vc_info));
947 SMBCO_FOREACH(scp2, VCTOCP(vcp)) {
948 ssp = (struct smb_share *)scp2;
949 error = smb_share_lock(ssp);
954 smb_share_getinfo(ssp, &ssi);
955 smb_share_unlock(ssp);
956 error = SYSCTL_OUT(req, &ssi, sizeof(struct smb_share_info));
965 itype = SMB_INFO_NONE;
966 error = SYSCTL_OUT(req, &itype, sizeof(itype));
968 smb_sm_unlockvclist();