xref: /titanic_41/usr/src/uts/common/sys/vscan.h (revision bfc848c632c9eacb2a640246d96e198f1b185c03)
1911106dfSjm199354 /*
2911106dfSjm199354  * CDDL HEADER START
3911106dfSjm199354  *
4911106dfSjm199354  * The contents of this file are subject to the terms of the
5911106dfSjm199354  * Common Development and Distribution License (the "License").
6911106dfSjm199354  * You may not use this file except in compliance with the License.
7911106dfSjm199354  *
8911106dfSjm199354  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9911106dfSjm199354  * or http://www.opensolaris.org/os/licensing.
10911106dfSjm199354  * See the License for the specific language governing permissions
11911106dfSjm199354  * and limitations under the License.
12911106dfSjm199354  *
13911106dfSjm199354  * When distributing Covered Code, include this CDDL HEADER in each
14911106dfSjm199354  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15911106dfSjm199354  * If applicable, add the following below this CDDL HEADER, with the
16911106dfSjm199354  * fields enclosed by brackets "[]" replaced with your own identifying
17911106dfSjm199354  * information: Portions Copyright [yyyy] [name of copyright owner]
18911106dfSjm199354  *
19911106dfSjm199354  * CDDL HEADER END
20911106dfSjm199354  */
21911106dfSjm199354 /*
2253c11029Sjm199354  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23911106dfSjm199354  * Use is subject to license terms.
24911106dfSjm199354  */
25911106dfSjm199354 
26911106dfSjm199354 #ifndef	_VSCAN_H
27911106dfSjm199354 #define	_VSCAN_H
28911106dfSjm199354 
29911106dfSjm199354 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30911106dfSjm199354 
31911106dfSjm199354 #ifdef __cplusplus
32911106dfSjm199354 extern "C" {
33911106dfSjm199354 #endif
34911106dfSjm199354 
35911106dfSjm199354 #include <sys/param.h>
36911106dfSjm199354 #include <sys/vnode.h>
37911106dfSjm199354 
38911106dfSjm199354 /*
39911106dfSjm199354  * vscan.h provides definitions for vscan kernel module
40911106dfSjm199354  */
41911106dfSjm199354 
42*bfc848c6Sjm199354 #define	VS_DRV_PATH		"/dev/vscan/vscan" /* append minor dev num */
43*bfc848c6Sjm199354 
44*bfc848c6Sjm199354 #define	VS_IOCTL_ENABLE		0x01	/* door rendezvous */
45*bfc848c6Sjm199354 #define	VS_IOCTL_DISABLE	0x02	/* vscand shutting down */
46*bfc848c6Sjm199354 #define	VS_IOCTL_CONFIG		0x03	/* vscand config data update */
47*bfc848c6Sjm199354 #define	VS_IOCTL_RESULT		0x04	/* scan result */
48*bfc848c6Sjm199354 #define	VS_IOCTL_MAX_REQ	0x05	/* max in-progress req vscand */
49911106dfSjm199354 
5053c11029Sjm199354 /* Scan Result - vsr_result */
5153c11029Sjm199354 #define	VS_STATUS_UNDEFINED	0
5253c11029Sjm199354 #define	VS_STATUS_NO_SCAN	1	/* scan not required */
5353c11029Sjm199354 #define	VS_STATUS_ERROR		2	/* scan failed */
5453c11029Sjm199354 #define	VS_STATUS_CLEAN		3	/* scan successful, file clean */
5553c11029Sjm199354 #define	VS_STATUS_INFECTED	4	/* scan successful, file infected */
56*bfc848c6Sjm199354 #define	VS_STATUS_SCANNING	5	/* scan in progress - async */
57911106dfSjm199354 
58*bfc848c6Sjm199354 /* Configuration data vs_config_t - vsc_types */
59911106dfSjm199354 #define	VS_TYPES_LEN		4096	/* vs_config_t - types buffer */
60*bfc848c6Sjm199354 #define	VS_TYPES_MAX		VS_TYPES_LEN / 2
61*bfc848c6Sjm199354 
62911106dfSjm199354 
63911106dfSjm199354 /*
64911106dfSjm199354  * AV_SCANSTAMP_SZ is the size of the scanstamp stored in the
65911106dfSjm199354  * filesystem. vs_scanstamp_t is 1 character longer to allow
66911106dfSjm199354  * a null terminated string to be used within vscan
67911106dfSjm199354  */
68911106dfSjm199354 typedef char vs_scanstamp_t[AV_SCANSTAMP_SZ + 1];
69911106dfSjm199354 
70*bfc848c6Sjm199354 /* used for door request to vscand */
71911106dfSjm199354 typedef struct vs_scan_req {
72*bfc848c6Sjm199354 	uint32_t vsr_idx;
73*bfc848c6Sjm199354 	uint32_t vsr_seqnum;
74911106dfSjm199354 	uint64_t vsr_size;
75*bfc848c6Sjm199354 	uint32_t vsr_flags;
76911106dfSjm199354 	uint8_t vsr_modified;
77911106dfSjm199354 	uint8_t vsr_quarantined;
78911106dfSjm199354 	char vsr_path[MAXPATHLEN];
79911106dfSjm199354 	vs_scanstamp_t vsr_scanstamp;
80911106dfSjm199354 } vs_scan_req_t;
81911106dfSjm199354 
82911106dfSjm199354 
83*bfc848c6Sjm199354 /* passed in VS_IOCTL_RESULT - async response from vscand */
84*bfc848c6Sjm199354 typedef struct vs_scan_rsp {
85*bfc848c6Sjm199354 	uint32_t vsr_idx;
86*bfc848c6Sjm199354 	uint32_t vsr_seqnum;
87*bfc848c6Sjm199354 	uint32_t vsr_result;
88*bfc848c6Sjm199354 	vs_scanstamp_t vsr_scanstamp;
89*bfc848c6Sjm199354 } vs_scan_rsp_t;
90*bfc848c6Sjm199354 
91*bfc848c6Sjm199354 
92*bfc848c6Sjm199354 /* passed in VS_IOCTL_CONFIG */
93911106dfSjm199354 typedef struct vs_config {
94911106dfSjm199354 	char vsc_types[VS_TYPES_LEN];
95911106dfSjm199354 	uint64_t vsc_types_len;
96911106dfSjm199354 	uint64_t vsc_max_size;	/* files > max size (bytes) not scan */
97911106dfSjm199354 	uint64_t vsc_allow;	/* allow access to file exceeding max_size? */
98911106dfSjm199354 } vs_config_t;
99911106dfSjm199354 
100911106dfSjm199354 
101911106dfSjm199354 #ifdef _KERNEL
102911106dfSjm199354 int vscan_svc_init(void);
103911106dfSjm199354 void vscan_svc_fini(void);
104*bfc848c6Sjm199354 int vscan_svc_enable(void);
10553c11029Sjm199354 void vscan_svc_disable(void);
106911106dfSjm199354 int vscan_svc_configure(vs_config_t *);
107911106dfSjm199354 boolean_t vscan_svc_in_use(void);
108*bfc848c6Sjm199354 void vscan_svc_scan_result(vs_scan_rsp_t *);
109*bfc848c6Sjm199354 void vscan_svc_scan_abort(void);
110911106dfSjm199354 vnode_t *vscan_svc_get_vnode(int);
111911106dfSjm199354 
112911106dfSjm199354 int vscan_door_init(void);
113911106dfSjm199354 void vscan_door_fini(void);
114911106dfSjm199354 int vscan_door_open(int);
115911106dfSjm199354 void vscan_door_close(void);
116911106dfSjm199354 int vscan_door_scan_file(vs_scan_req_t *);
117911106dfSjm199354 
11853c11029Sjm199354 boolean_t vscan_drv_create_node(int);
11953c11029Sjm199354 
120911106dfSjm199354 #endif /* _KERNEL */
121911106dfSjm199354 
122911106dfSjm199354 #ifdef __cplusplus
123911106dfSjm199354 }
124911106dfSjm199354 #endif
125911106dfSjm199354 
126911106dfSjm199354 
127911106dfSjm199354 #endif /* _VSCAN_H */
128