xref: /titanic_44/usr/src/uts/common/sys/vscan.h (revision 91d7f85e02991954d1e1bd44673df567ad8dcc87)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_VSCAN_H
27 #define	_VSCAN_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 #include <sys/param.h>
36 #include <sys/vnode.h>
37 
38 /*
39  * vscan.h provides definitions for vscan kernel module
40  */
41 
42 #define	VS_DRV_PATH		"/dev/vscan/vscan" /* append minor dev num */
43 
44 #define	VS_IOCTL_ENABLE		0x01	/* door rendezvous */
45 #define	VS_IOCTL_DISABLE	0x02	/* vscand shutting down */
46 #define	VS_IOCTL_CONFIG		0x03	/* vscand config data update */
47 #define	VS_IOCTL_RESULT		0x04	/* scan result */
48 #define	VS_IOCTL_MAX_REQ	0x05	/* max in-progress req vscand */
49 
50 /* Scan Result - vsr_result */
51 #define	VS_STATUS_UNDEFINED	0
52 #define	VS_STATUS_NO_SCAN	1	/* scan not required */
53 #define	VS_STATUS_ERROR		2	/* scan failed */
54 #define	VS_STATUS_CLEAN		3	/* scan successful, file clean */
55 #define	VS_STATUS_INFECTED	4	/* scan successful, file infected */
56 #define	VS_STATUS_SCANNING	5	/* scan in progress - async */
57 
58 /* Configuration data vs_config_t - vsc_types */
59 #define	VS_TYPES_LEN		4096	/* vs_config_t - types buffer */
60 #define	VS_TYPES_MAX		VS_TYPES_LEN / 2
61 
62 
63 /*
64  * AV_SCANSTAMP_SZ is the size of the scanstamp stored in the
65  * filesystem. vs_scanstamp_t is 1 character longer to allow
66  * a null terminated string to be used within vscan
67  */
68 typedef char vs_scanstamp_t[AV_SCANSTAMP_SZ + 1];
69 
70 /* used for door request to vscand */
71 typedef struct vs_scan_req {
72 	uint32_t vsr_idx;
73 	uint32_t vsr_seqnum;
74 	uint64_t vsr_size;
75 	uint32_t vsr_flags;
76 	uint8_t vsr_modified;
77 	uint8_t vsr_quarantined;
78 	char vsr_path[MAXPATHLEN];
79 	vs_scanstamp_t vsr_scanstamp;
80 } vs_scan_req_t;
81 
82 
83 /* passed in VS_IOCTL_RESULT - async response from vscand */
84 typedef struct vs_scan_rsp {
85 	uint32_t vsr_idx;
86 	uint32_t vsr_seqnum;
87 	uint32_t vsr_result;
88 	vs_scanstamp_t vsr_scanstamp;
89 } vs_scan_rsp_t;
90 
91 
92 /* passed in VS_IOCTL_CONFIG */
93 typedef struct vs_config {
94 	char vsc_types[VS_TYPES_LEN];
95 	uint64_t vsc_types_len;
96 	uint64_t vsc_max_size;	/* files > max size (bytes) not scan */
97 	uint64_t vsc_allow;	/* allow access to file exceeding max_size? */
98 } vs_config_t;
99 
100 
101 #ifdef _KERNEL
102 int vscan_svc_init(void);
103 void vscan_svc_fini(void);
104 int vscan_svc_enable(void);
105 void vscan_svc_disable(void);
106 int vscan_svc_configure(vs_config_t *);
107 boolean_t vscan_svc_in_use(void);
108 void vscan_svc_scan_result(vs_scan_rsp_t *);
109 void vscan_svc_scan_abort(void);
110 vnode_t *vscan_svc_get_vnode(int);
111 
112 int vscan_door_init(void);
113 void vscan_door_fini(void);
114 int vscan_door_open(int);
115 void vscan_door_close(void);
116 int vscan_door_scan_file(vs_scan_req_t *);
117 
118 boolean_t vscan_drv_create_node(int);
119 
120 #endif /* _KERNEL */
121 
122 #ifdef __cplusplus
123 }
124 #endif
125 
126 
127 #endif /* _VSCAN_H */
128