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_co_lockstatus(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 smb_co_unlock(&smb_vclist, 0);
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 lockmgr(&smb_vclist.co_lock, LK_DRAIN, NULL);
94 smb_co_done(&smb_vclist);
99 smb_sm_lockvclist(int flags)
102 return smb_co_lock(&smb_vclist, flags | LK_CANRECURSE);
106 smb_sm_unlockvclist(void)
109 smb_co_unlock(&smb_vclist, LK_RELEASE);
113 smb_sm_lookupint(struct smb_vcspec *vcspec, struct smb_sharespec *shspec,
114 struct smb_cred *scred, struct smb_vc **vcpp)
116 struct smb_connobj *scp;
121 vcspec->shspec = shspec;
124 SMBCO_FOREACH(scp, &smb_vclist) {
125 vcp = (struct smb_vc *)scp;
126 error = smb_vc_lock(vcp, LK_EXCLUSIVE);
130 if ((vcp->obj.co_flags & SMBV_PRIVATE) ||
131 !CONNADDREQ(vcp->vc_paddr, vcspec->sap) ||
132 strcmp(vcp->vc_username, vcspec->username) != 0)
134 if (vcspec->owner != SMBM_ANY_OWNER) {
135 if (vcp->vc_uid != vcspec->owner)
139 if (vcspec->group != SMBM_ANY_GROUP) {
140 if (vcp->vc_grp != vcspec->group)
144 if (vcspec->mode & SMBM_EXACT) {
145 if (!exact || (vcspec->mode & SMBM_MASK) !=
149 if (smb_vc_access(vcp, scred, vcspec->mode) != 0)
153 error = (int)smb_vc_lookupshare(vcp, shspec, scred,
163 smb_vc_unlock(vcp, 0);
173 smb_sm_lookup(struct smb_vcspec *vcspec, struct smb_sharespec *shspec,
174 struct smb_cred *scred, struct smb_vc **vcpp)
177 struct smb_share *ssp = NULL;
182 error = smb_sm_lockvclist(LK_EXCLUSIVE);
185 error = smb_sm_lookupint(vcspec, shspec, scred, vcpp);
186 if (error == 0 || (vcspec->flags & SMBV_CREATE) == 0) {
187 smb_sm_unlockvclist();
190 error = smb_sm_lookupint(vcspec, NULL, scred, &vcp);
192 error = smb_vc_create(vcspec, scred, &vcp);
195 error = smb_vc_connect(vcp, scred);
201 error = smb_share_create(vcp, shspec, scred, &ssp);
204 error = smb_smb_treeconnect(ssp, scred);
208 smb_share_put(ssp, scred);
210 smb_sm_unlockvclist();
214 smb_vc_lock(vcp, LK_EXCLUSIVE);
215 smb_vc_put(vcp, scred);
221 * Common code for connection object
224 smb_co_init(struct smb_connobj *cp, int level, char *ilockname, char *lockname)
226 SLIST_INIT(&cp->co_children);
227 smb_sl_init(&cp->co_interlock, ilockname);
228 lockinit(&cp->co_lock, PZERO, lockname, 0, 0);
229 cp->co_level = level;
231 if (smb_co_lock(cp, LK_EXCLUSIVE) != 0)
232 panic("smb_co_init: lock failed");
236 smb_co_done(struct smb_connobj *cp)
238 smb_sl_destroy(&cp->co_interlock);
239 lockmgr(&cp->co_lock, LK_RELEASE, NULL);
240 lockdestroy(&cp->co_lock);
244 smb_co_gone(struct smb_connobj *cp, struct smb_cred *scred)
246 struct smb_connobj *parent;
249 cp->co_gone(cp, scred);
250 parent = cp->co_parent;
252 smb_co_lock(parent, LK_EXCLUSIVE);
253 SLIST_REMOVE(&parent->co_children, cp, smb_connobj, co_next);
254 smb_co_put(parent, scred);
261 smb_co_ref(struct smb_connobj *cp)
270 smb_co_rele(struct smb_connobj *cp, struct smb_cred *scred)
274 if (cp->co_usecount > 1) {
279 if (cp->co_usecount == 0) {
280 SMBERROR("negative use_count for object %d", cp->co_level);
285 cp->co_flags |= SMBO_GONE;
287 lockmgr(&cp->co_lock, LK_DRAIN | LK_INTERLOCK, &cp->co_interlock);
288 smb_co_gone(cp, scred);
292 smb_co_get(struct smb_connobj *cp, int flags, struct smb_cred *scred)
296 if ((flags & LK_INTERLOCK) == 0)
299 error = smb_co_lock(cp, flags | LK_INTERLOCK);
310 smb_co_put(struct smb_connobj *cp, struct smb_cred *scred)
314 if (cp->co_usecount > 1) {
316 } else if (cp->co_usecount == 1) {
318 cp->co_flags |= SMBO_GONE;
320 SMBERROR("negative usecount");
322 lockmgr(&cp->co_lock, LK_RELEASE | LK_INTERLOCK, &cp->co_interlock);
323 if ((cp->co_flags & SMBO_GONE) == 0)
325 lockmgr(&cp->co_lock, LK_DRAIN, NULL);
326 smb_co_gone(cp, scred);
330 smb_co_lockstatus(struct smb_connobj *cp)
332 return lockstatus(&cp->co_lock);
336 smb_co_lock(struct smb_connobj *cp, int flags)
339 if (cp->co_flags & SMBO_GONE)
341 if ((flags & LK_TYPE_MASK) == 0)
342 flags |= LK_EXCLUSIVE;
343 if (smb_co_lockstatus(cp) == LK_EXCLUSIVE &&
344 (flags & LK_CANRECURSE) == 0) {
345 SMBERROR("recursive lock for object %d\n", cp->co_level);
348 return lockmgr(&cp->co_lock, flags, &cp->co_interlock);
352 smb_co_unlock(struct smb_connobj *cp, int flags)
354 (void)lockmgr(&cp->co_lock, flags | LK_RELEASE, &cp->co_interlock);
358 smb_co_addchild(struct smb_connobj *parent, struct smb_connobj *child)
361 KASSERT(smb_co_lockstatus(parent) == LK_EXCLUSIVE,
362 ("smb_co_addchild: parent not locked"));
363 KASSERT(smb_co_lockstatus(child) == LK_EXCLUSIVE,
364 ("smb_co_addchild: child not locked"));
367 SLIST_INSERT_HEAD(&parent->co_children, child, co_next);
368 child->co_parent = parent;
372 * Session implementation
376 smb_vc_create(struct smb_vcspec *vcspec,
377 struct smb_cred *scred, struct smb_vc **vcpp)
380 struct ucred *cred = scred->scr_cred;
381 uid_t uid = vcspec->owner;
382 gid_t gid = vcspec->group;
383 uid_t realuid = cred->cr_uid;
384 char *domain = vcspec->domain;
387 isroot = smb_suser(cred) == 0;
389 * Only superuser can create VCs with different uid and gid
391 if (uid != SMBM_ANY_OWNER && uid != realuid && !isroot)
393 if (gid != SMBM_ANY_GROUP && !groupmember(gid, cred) && !isroot)
396 vcp = smb_zmalloc(sizeof(*vcp), M_SMBCONN, M_WAITOK);
397 smb_co_init(VCTOCP(vcp), SMBL_VC, "smb_vc ilock", "smb_vc");
398 vcp->obj.co_free = smb_vc_free;
399 vcp->obj.co_gone = smb_vc_gone;
400 vcp->vc_number = smb_vcnext++;
401 vcp->vc_timo = SMB_DEFRQTIMO;
402 vcp->vc_smbuid = SMB_UID_UNKNOWN;
403 vcp->vc_mode = vcspec->rights & SMBM_MASK;
404 vcp->obj.co_flags = vcspec->flags & (SMBV_PRIVATE | SMBV_SINGLESHARE);
405 vcp->vc_tdesc = &smb_tran_nbtcp_desc;
407 vcp->vc_mackey = NULL;
408 vcp->vc_mackeylen = 0;
410 if (uid == SMBM_ANY_OWNER)
412 if (gid == SMBM_ANY_GROUP)
413 gid = cred->cr_groups[0];
417 smb_sl_init(&vcp->vc_stlock, "vcstlock");
420 vcp->vc_paddr = sodupsockaddr(vcspec->sap, M_WAITOK);
421 if (vcp->vc_paddr == NULL)
423 vcp->vc_laddr = sodupsockaddr(vcspec->lap, M_WAITOK);
424 if (vcp->vc_laddr == NULL)
426 vcp->vc_pass = smb_strdup(vcspec->pass);
427 if (vcp->vc_pass == NULL)
429 vcp->vc_domain = smb_strdup((domain && domain[0]) ? domain :
431 if (vcp->vc_domain == NULL)
433 vcp->vc_srvname = smb_strdup(vcspec->srvname);
434 if (vcp->vc_srvname == NULL)
436 vcp->vc_username = smb_strdup(vcspec->username);
437 if (vcp->vc_username == NULL)
439 error = (int)iconv_open("tolower", vcspec->localcs, &vcp->vc_tolower);
442 error = (int)iconv_open("toupper", vcspec->localcs, &vcp->vc_toupper);
445 if (vcspec->servercs[0]) {
446 error = (int)iconv_open(vcspec->servercs, vcspec->localcs,
447 &vcp->vc_cp_toserver);
450 error = (int)iconv_open(vcspec->localcs, vcspec->servercs,
451 &vcp->vc_cp_tolocal);
454 vcp->vc_toserver = vcp->vc_cp_toserver;
455 vcp->vc_tolocal = vcp->vc_cp_tolocal;
456 iconv_add(ENCODING_UNICODE, ENCODING_UNICODE, SMB_UNICODE_NAME);
457 iconv_add(ENCODING_UNICODE, SMB_UNICODE_NAME, ENCODING_UNICODE);
458 error = (int)iconv_open(SMB_UNICODE_NAME, vcspec->localcs,
459 &vcp->vc_ucs_toserver);
461 error = (int)iconv_open(vcspec->localcs, SMB_UNICODE_NAME,
462 &vcp->vc_ucs_tolocal);
465 if (vcp->vc_ucs_toserver)
466 iconv_close(vcp->vc_ucs_toserver);
467 vcp->vc_ucs_toserver = NULL;
468 vcp->vc_ucs_tolocal = NULL;
471 error = (int)smb_iod_create(vcp);
475 smb_co_addchild(&smb_vclist, VCTOCP(vcp));
479 smb_vc_put(vcp, scred);
484 smb_vc_free(struct smb_connobj *cp)
486 struct smb_vc *vcp = CPTOVC(cp);
489 smb_iod_destroy(vcp->vc_iod);
490 SMB_STRFREE(vcp->vc_username);
491 SMB_STRFREE(vcp->vc_srvname);
492 SMB_STRFREE(vcp->vc_pass);
493 SMB_STRFREE(vcp->vc_domain);
495 free(vcp->vc_mackey, M_SMBTEMP);
497 free(vcp->vc_paddr, M_SONAME);
499 free(vcp->vc_laddr, M_SONAME);
501 iconv_close(vcp->vc_tolower);
503 iconv_close(vcp->vc_toupper);
505 vcp->vc_tolocal = NULL;
506 if (vcp->vc_toserver)
507 vcp->vc_toserver = NULL;
508 if (vcp->vc_cp_tolocal)
509 iconv_close(vcp->vc_cp_tolocal);
510 if (vcp->vc_cp_toserver)
511 iconv_close(vcp->vc_cp_toserver);
512 if (vcp->vc_ucs_tolocal)
513 iconv_close(vcp->vc_ucs_tolocal);
514 if (vcp->vc_ucs_toserver)
515 iconv_close(vcp->vc_ucs_toserver);
516 smb_co_done(VCTOCP(vcp));
517 smb_sl_destroy(&vcp->vc_stlock);
518 free(vcp, M_SMBCONN);
522 * Called when use count of VC dropped to zero.
523 * VC should be locked on enter with LK_DRAIN.
526 smb_vc_gone(struct smb_connobj *cp, struct smb_cred *scred)
528 struct smb_vc *vcp = CPTOVC(cp);
530 smb_vc_disconnect(vcp);
534 smb_vc_ref(struct smb_vc *vcp)
536 smb_co_ref(VCTOCP(vcp));
540 smb_vc_rele(struct smb_vc *vcp, struct smb_cred *scred)
542 smb_co_rele(VCTOCP(vcp), scred);
546 smb_vc_get(struct smb_vc *vcp, int flags, struct smb_cred *scred)
548 return smb_co_get(VCTOCP(vcp), flags, scred);
552 smb_vc_put(struct smb_vc *vcp, struct smb_cred *scred)
554 smb_co_put(VCTOCP(vcp), scred);
558 smb_vc_lock(struct smb_vc *vcp, int flags)
560 return smb_co_lock(VCTOCP(vcp), flags);
564 smb_vc_unlock(struct smb_vc *vcp, int flags)
566 smb_co_unlock(VCTOCP(vcp), flags);
570 smb_vc_access(struct smb_vc *vcp, struct smb_cred *scred, mode_t mode)
572 struct ucred *cred = scred->scr_cred;
574 if (smb_suser(cred) == 0 || cred->cr_uid == vcp->vc_uid)
577 if (!groupmember(vcp->vc_grp, cred))
579 return (vcp->vc_mode & mode) == mode ? 0 : EACCES;
583 smb_vc_cmpshare(struct smb_share *ssp, struct smb_sharespec *dp)
587 if (strcmp(ssp->ss_name, dp->name) != 0)
589 if (dp->owner != SMBM_ANY_OWNER) {
590 if (ssp->ss_uid != dp->owner)
594 if (dp->group != SMBM_ANY_GROUP) {
595 if (ssp->ss_grp != dp->group)
600 if (dp->mode & SMBM_EXACT) {
603 return (dp->mode & SMBM_MASK) == ssp->ss_mode ? 0 : 1;
605 if (smb_share_access(ssp, dp->scred, dp->mode) != 0)
611 * Lookup share in the given VC. Share referenced and locked on return.
612 * VC expected to be locked on entry and will be left locked on exit.
615 smb_vc_lookupshare(struct smb_vc *vcp, struct smb_sharespec *dp,
616 struct smb_cred *scred, struct smb_share **sspp)
618 struct smb_connobj *scp = NULL;
619 struct smb_share *ssp = NULL;
624 SMBCO_FOREACH(scp, VCTOCP(vcp)) {
625 ssp = (struct smb_share *)scp;
626 error = smb_share_lock(ssp, LK_EXCLUSIVE);
629 if (smb_vc_cmpshare(ssp, dp) == 0)
631 smb_share_unlock(ssp, 0);
643 smb_vc_connect(struct smb_vc *vcp, struct smb_cred *scred)
646 return smb_iod_request(vcp->vc_iod, SMBIOD_EV_CONNECT | SMBIOD_EV_SYNC, NULL);
650 * Destroy VC to server, invalidate shares linked with it.
651 * Transport should be locked on entry.
654 smb_vc_disconnect(struct smb_vc *vcp)
657 smb_iod_request(vcp->vc_iod, SMBIOD_EV_DISCONNECT | SMBIOD_EV_SYNC, NULL);
661 static char smb_emptypass[] = "";
664 smb_vc_getpass(struct smb_vc *vcp)
668 return smb_emptypass;
672 smb_vc_getinfo(struct smb_vc *vcp, struct smb_vc_info *vip)
674 bzero(vip, sizeof(struct smb_vc_info));
675 vip->itype = SMB_INFO_VC;
676 vip->usecount = vcp->obj.co_usecount;
677 vip->uid = vcp->vc_uid;
678 vip->gid = vcp->vc_grp;
679 vip->mode = vcp->vc_mode;
680 vip->flags = vcp->obj.co_flags;
681 vip->sopt = vcp->vc_sopt;
682 vip->iodstate = vcp->vc_iod->iod_state;
683 bzero(&vip->sopt.sv_skey, sizeof(vip->sopt.sv_skey));
684 snprintf(vip->srvname, sizeof(vip->srvname), "%s", vcp->vc_srvname);
685 snprintf(vip->vcname, sizeof(vip->vcname), "%s", vcp->vc_username);
690 smb_vc_nextmid(struct smb_vc *vcp)
694 SMB_CO_LOCK(&vcp->obj);
696 SMB_CO_UNLOCK(&vcp->obj);
701 * Share implementation
704 * Allocate share structure and attach it to the given VC
705 * Connection expected to be locked on entry. Share will be returned
709 smb_share_create(struct smb_vc *vcp, struct smb_sharespec *shspec,
710 struct smb_cred *scred, struct smb_share **sspp)
712 struct smb_share *ssp;
713 struct ucred *cred = scred->scr_cred;
714 uid_t realuid = cred->cr_uid;
715 uid_t uid = shspec->owner;
716 gid_t gid = shspec->group;
719 isroot = smb_suser(cred) == 0;
721 * Only superuser can create shares with different uid and gid
723 if (uid != SMBM_ANY_OWNER && uid != realuid && !isroot)
725 if (gid != SMBM_ANY_GROUP && !groupmember(gid, cred) && !isroot)
727 error = smb_vc_lookupshare(vcp, shspec, scred, &ssp);
729 smb_share_put(ssp, scred);
732 if (uid == SMBM_ANY_OWNER)
734 if (gid == SMBM_ANY_GROUP)
735 gid = cred->cr_groups[0];
736 ssp = smb_zmalloc(sizeof(*ssp), M_SMBCONN, M_WAITOK);
737 smb_co_init(SSTOCP(ssp), SMBL_SHARE, "smbss ilock", "smbss");
738 ssp->obj.co_free = smb_share_free;
739 ssp->obj.co_gone = smb_share_gone;
740 smb_sl_init(&ssp->ss_stlock, "ssstlock");
741 ssp->ss_name = smb_strdup(shspec->name);
742 if (shspec->pass && shspec->pass[0])
743 ssp->ss_pass = smb_strdup(shspec->pass);
744 ssp->ss_type = shspec->stype;
745 ssp->ss_tid = SMB_TID_UNKNOWN;
748 ssp->ss_mode = shspec->rights & SMBM_MASK;
749 smb_co_addchild(VCTOCP(vcp), SSTOCP(ssp));
755 smb_share_free(struct smb_connobj *cp)
757 struct smb_share *ssp = CPTOSS(cp);
759 SMB_STRFREE(ssp->ss_name);
760 SMB_STRFREE(ssp->ss_pass);
761 smb_sl_destroy(&ssp->ss_stlock);
762 smb_co_done(SSTOCP(ssp));
763 free(ssp, M_SMBCONN);
767 smb_share_gone(struct smb_connobj *cp, struct smb_cred *scred)
769 struct smb_share *ssp = CPTOSS(cp);
771 smb_smb_treedisconnect(ssp, scred);
775 smb_share_ref(struct smb_share *ssp)
777 smb_co_ref(SSTOCP(ssp));
781 smb_share_rele(struct smb_share *ssp, struct smb_cred *scred)
783 smb_co_rele(SSTOCP(ssp), scred);
787 smb_share_get(struct smb_share *ssp, int flags, struct smb_cred *scred)
789 return smb_co_get(SSTOCP(ssp), flags, scred);
793 smb_share_put(struct smb_share *ssp, struct smb_cred *scred)
795 smb_co_put(SSTOCP(ssp), scred);
799 smb_share_lock(struct smb_share *ssp, int flags)
801 return smb_co_lock(SSTOCP(ssp), flags);
805 smb_share_unlock(struct smb_share *ssp, int flags)
807 smb_co_unlock(SSTOCP(ssp), flags);
811 smb_share_access(struct smb_share *ssp, struct smb_cred *scred, mode_t mode)
813 struct ucred *cred = scred->scr_cred;
815 if (smb_suser(cred) == 0 || cred->cr_uid == ssp->ss_uid)
818 if (!groupmember(ssp->ss_grp, cred))
820 return (ssp->ss_mode & mode) == mode ? 0 : EACCES;
824 smb_share_invalidate(struct smb_share *ssp)
826 ssp->ss_tid = SMB_TID_UNKNOWN;
830 smb_share_valid(struct smb_share *ssp)
832 return ssp->ss_tid != SMB_TID_UNKNOWN &&
833 ssp->ss_vcgenid == SSTOVC(ssp)->vc_genid;
837 smb_share_getpass(struct smb_share *ssp)
846 return smb_emptypass;
850 smb_share_getinfo(struct smb_share *ssp, struct smb_share_info *sip)
852 bzero(sip, sizeof(struct smb_share_info));
853 sip->itype = SMB_INFO_SHARE;
854 sip->usecount = ssp->obj.co_usecount;
855 sip->tid = ssp->ss_tid;
856 sip->type= ssp->ss_type;
857 sip->uid = ssp->ss_uid;
858 sip->gid = ssp->ss_grp;
859 sip->mode= ssp->ss_mode;
860 sip->flags = ssp->obj.co_flags;
861 snprintf(sip->sname, sizeof(sip->sname), "%s", ssp->ss_name);
866 * Dump an entire tree into sysctl call
869 smb_sysctl_treedump(SYSCTL_HANDLER_ARGS)
871 struct thread *td = req->td;
872 struct smb_cred scred;
873 struct smb_connobj *scp1, *scp2;
875 struct smb_share *ssp;
876 struct smb_vc_info vci;
877 struct smb_share_info ssi;
880 smb_makescred(&scred, td, td->td_ucred);
881 error = sysctl_wire_old_buffer(req, 0);
884 error = smb_sm_lockvclist(LK_SHARED);
887 SMBCO_FOREACH(scp1, &smb_vclist) {
888 vcp = (struct smb_vc *)scp1;
889 error = smb_vc_lock(vcp, LK_SHARED);
892 smb_vc_getinfo(vcp, &vci);
893 error = SYSCTL_OUT(req, &vci, sizeof(struct smb_vc_info));
895 smb_vc_unlock(vcp, 0);
898 SMBCO_FOREACH(scp2, VCTOCP(vcp)) {
899 ssp = (struct smb_share *)scp2;
900 error = smb_share_lock(ssp, LK_SHARED);
905 smb_share_getinfo(ssp, &ssi);
906 smb_share_unlock(ssp, 0);
907 error = SYSCTL_OUT(req, &ssi, sizeof(struct smb_share_info));
911 smb_vc_unlock(vcp, 0);
916 itype = SMB_INFO_NONE;
917 error = SYSCTL_OUT(req, &itype, sizeof(itype));
919 smb_sm_unlockvclist();