vscan_drv.c revision bfc848c632c9eacb2a640246d96e198f1b185c03
883N/A * The contents of this file are subject to the terms of the 883N/A * Common Development and Distribution License (the "License"). 883N/A * You may not use this file except in compliance with the License. 883N/A * See the License for the specific language governing permissions 883N/A * and limitations under the License. 883N/A * When distributing Covered Code, include this CDDL HEADER in each 883N/A * If applicable, add the following below this CDDL HEADER, with the 883N/A * fields enclosed by brackets "[]" replaced with your own identifying 883N/A * information: Portions Copyright [yyyy] [name of copyright owner] 883N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 883N/A * Use is subject to license terms. 883N/A#
pragma ident "%Z%%M% %I% %E% SMI" 883N/A/* seconds to wait for daemon to reconnect before disabling */ 883N/A/* length of minor node name - vscan%d */ 883N/A * Operations on instance 0 represent vscand initiated state 883N/A * open(0) - vscand connect 883N/A * close(0) - vscan disconnect 883N/A * enable(0) - vscand enable (ready to hand requests) 883N/A * disable(0) - vscand disable (shutting down) 883N/A * +------------------------+ 883N/A * +------------------------+ 883N/A * +------------------------+ 883N/A * | VS_DRV_IDLE |<------| 883N/A * +------------------------+ | 883N/A * | open(0) | close(0) | 883N/A * +------------------------+ | 883N/A * | VS_DRV_CONNECTED |<-| | 883N/A * +------------------------+ | | 883N/A * | enable(0) | disable(0) | | 883N/A * +------------------------+ | | 883N/A * | VS_DRV_ENABLED | | | 883N/A * +------------------------+ | | 883N/A * +------------------------+ | | timeout 883N/A * | VS_DRV_DELAYED_DISABLE | -- | 883N/A * +------------------------+ ------| 883N/A * Instance 0 controls the state of the driver: vscan_drv_state. 883N/A * vscan_drv_inst_state[0] should NOT be used. 883N/A * vscan_drv_inst_state[n] represents the state of driver 883N/A * instance n, used by vscand to access file data for the 883N/A * scan request with index n in vscan_svc_reqs. 883N/A * Minor nodes are created as required then all are destroyed 883N/A * during driver detach. 883N/A * +------------------------+ 883N/A * | VS_DRV_INST_UNCONFIG | 883N/A * +------------------------+ 883N/A * | create_node(n) | detach 883N/A * +------------------------+ 883N/A * | VS_DRV_INST_INIT |<-| 883N/A * +------------------------+ | * +------------------------+ | * | VS_DRV_INST_OPEN |--| * +------------------------+ | * +------------------------+ | * | VS_DRV_INST_READING |--| * +------------------------+ * module linkage info for the kernel &
cbops,
/* devo_cb_ops */ "virus scanning",
/* drv_linkinfo */ MODREV_1,
/* revision of the module, must be: MODREV_1 */ &
modldrv,
/* ptr to linkage structures */ /* create minor node 0 for daemon-driver synchronization */ /* remove all minor nodes */ * If the driver state is not IDLE or UNCONFIG then the * driver is in use. Otherwise, check the service interface * (vscan_svc) to see if it is still in use - for example * there there may be requests still in progress. * If inst == 0, this is vscand initializing. * If the driver is in DELAYED_DISABLE, ie vscand previously * disconnected without a clean shutdown and the driver is * waiting for a period to allow vscand to reconnect, signal * vscan_drv_cv to cancel the delayed disable. * If inst != 0, open the file associated with inst. /* check if caller has privilege for virus scanning */ * If inst == 0, this is vscand detaching. * If the driver is in ENABLED state vscand has terminated without * a clean shutdown (nod DISABLE received). Enter DELAYED_DISABLE * state and initiate a delayed disable to allow vscand time to * If inst != 0, close the file associated with inst /* instance 0 - daemon disconnect */ }
else {
/* VS_DRV_ENABLED */ * vscan_drv_delayed_disable * Invoked from vscan_drv_close if the daemon disconnects * without first sending disable (e.g. daemon crashed). * Delays for vs_reconnect_timeout before disabling, to allow * the daemon to reconnect. During this time, scan requests * Process ioctls from vscand: * VS_IOCTL_ENABLE - vscand is ready to handle scan requests, * VS_IOCTL_DISABLE - vscand is shutting down, disable VFS interface * VS_IOCTL_RESULT - scan response data * VS_IOCTL_CONFIG - configuration data from vscand * VS_IOCTL_MAX_REQ - provide the max request idx to vscand, * to allow vscand to set appropriate resource allocation limits * Create minor node with which vscan daemon will communicate * to access a file. Invoked from vscan_svc before scan request * Minor node 0 is reserved for daemon-driver synchronization * and is created during attach. * All minor nodes are removed during detach.