FreeBSD/sys/netsmb/smb_conn.c
/*
 * Dump an entire tree into sysctl call
 */
Dump an entire tree into sysctl call
Dump an entire tree into sysctl call
static int
smb_sysctl_treedump(SYSCTL_HANDLER_ARGS)
{
	struct smb_connobj *scp1, *scp2;
	struct smb_vc *vcp;
	struct smb_share *ssp;
	struct smb_vc_info vci;
	struct smb_share_info ssi;
	int error, itype;
	error = sysctl_wire_old_buffer(req, 0);
	if (error)
		return (error);
	error = smb_sm_lockvclist();
	if (error)
		return error;
	SMBCO_FOREACH(scp1, &smb_vclist) {
		vcp = (struct smb_vc *)scp1;
		error = smb_vc_lock(vcp);
		if (error)
			continue;
		smb_vc_getinfo(vcp, &vci);
		error = SYSCTL_OUT(req, &vci, sizeof(struct smb_vc_info));
		if (error) {
			smb_vc_unlock(vcp);
			break;
		}
		SMBCO_FOREACH(scp2, VCTOCP(vcp)) {
			ssp = (struct smb_share *)scp2;
			error = smb_share_lock(ssp);
			if (error) {
				error = 0;
				continue;
			}
			smb_share_getinfo(ssp, &ssi);
			smb_share_unlock(ssp);
			error = SYSCTL_OUT(req, &ssi, sizeof(struct smb_share_info));
			if (error)
				break;
		}
		smb_vc_unlock(vcp);
		if (error)
			break;
	}
	if (!error) {
		itype = SMB_INFO_NONE;
		error = SYSCTL_OUT(req, &itype, sizeof(itype));
	}
	smb_sm_unlockvclist();
	return error;
}
static int smb_sysctl_treedump ( SYSCTL_HANDLER_ARGS ) { struct smb_connobj * scp1 , * scp2 ; struct smb_vc * vcp ; struct smb_share * ssp ; struct smb_vc_info vci ; struct smb_share_info ssi ; int error , itype ; error = sysctl_wire_old_buffer ( req , 0 ) ; if ( error ) return ( error ) ; error = smb_sm_lockvclist ( ) ; if ( error ) return error ; SMBCO_FOREACH ( scp1 , & smb_vclist ) { vcp = ( struct smb_vc * ) scp1 ; error = smb_vc_lock ( vcp ) ; if ( error ) continue ; smb_vc_getinfo ( vcp , & vci ) ; error = SYSCTL_OUT ( req , & vci , sizeof ( struct smb_vc_info ) ) ; if ( error ) { smb_vc_unlock ( vcp ) ; break ; } SMBCO_FOREACH ( scp2 , VCTOCP ( vcp ) ) { ssp = ( struct smb_share * ) scp2 ; error = smb_share_lock ( ssp ) ; if ( error ) { error = 0 ; continue ; } smb_share_getinfo ( ssp , & ssi ) ; smb_share_unlock ( ssp ) ; error = SYSCTL_OUT ( req , & ssi , sizeof ( struct smb_share_info ) ) ; if ( error ) break ; } smb_vc_unlock ( vcp ) ; if ( error ) break ; } if ( ! error ) { itype = SMB_INFO_NONE ; error = SYSCTL_OUT ( req , & itype , sizeof ( itype ) ) ; } smb_sm_unlockvclist ( ) ; return error ; }
Dump an entire tree into sysctl call
Dump an entire tree into sysctl call