xref: /illumos-gate/usr/src/uts/common/sys/vscan.h (revision 2d6eb4a5)
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 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/param.h>
34 #include <sys/vnode.h>
35 
36 /*
37  * vscan.h provides definitions for vscan kernel module
38  */
39 
40 #define	VS_DRV_PATH		"/dev/vscan/vscan" /* append minor dev num */
41 
42 #define	VS_IOCTL_ENABLE		0x01	/* door rendezvous */
43 #define	VS_IOCTL_DISABLE	0x02	/* vscand shutting down */
44 #define	VS_IOCTL_CONFIG		0x03	/* vscand config data update */
45 #define	VS_IOCTL_RESULT		0x04	/* scan result */
46 #define	VS_IOCTL_MAX_REQ	0x05	/* max in-progress req vscand */
47 
48 /* Scan Result - vsr_result */
49 #define	VS_STATUS_UNDEFINED	0
50 #define	VS_STATUS_NO_SCAN	1	/* scan not required */
51 #define	VS_STATUS_ERROR		2	/* scan failed */
52 #define	VS_STATUS_CLEAN		3	/* scan successful, file clean */
53 #define	VS_STATUS_INFECTED	4	/* scan successful, file infected */
54 #define	VS_STATUS_SCANNING	5	/* scan in progress - async */
55 
56 /* Configuration data vs_config_t - vsc_types */
57 #define	VS_TYPES_LEN		4096	/* vs_config_t - types buffer */
58 #define	VS_TYPES_MAX		VS_TYPES_LEN / 2
59 
60 
61 /*
62  * AV_SCANSTAMP_SZ is the size of the scanstamp stored in the
63  * filesystem. vs_scanstamp_t is 1 character longer to allow
64  * a null terminated string to be used within vscan
65  */
66 typedef char vs_scanstamp_t[AV_SCANSTAMP_SZ + 1];
67 
68 /* used for door request to vscand */
69 typedef struct vs_scan_req {
70 	uint32_t vsr_idx;
71 	uint32_t vsr_seqnum;
72 	uint64_t vsr_size;
73 	uint32_t vsr_flags;
74 	uint8_t vsr_modified;
75 	uint8_t vsr_quarantined;
76 	char vsr_path[MAXPATHLEN];
77 	vs_scanstamp_t vsr_scanstamp;
78 } vs_scan_req_t;
79 
80 
81 /* passed in VS_IOCTL_RESULT - async response from vscand */
82 typedef struct vs_scan_rsp {
83 	uint32_t vsr_idx;
84 	uint32_t vsr_seqnum;
85 	uint32_t vsr_result;
86 	vs_scanstamp_t vsr_scanstamp;
87 } vs_scan_rsp_t;
88 
89 
90 /* passed in VS_IOCTL_CONFIG */
91 typedef struct vs_config {
92 	char vsc_types[VS_TYPES_LEN];
93 	uint64_t vsc_types_len;
94 	uint64_t vsc_max_size;	/* files > max size (bytes) not scan */
95 	uint64_t vsc_allow;	/* allow access to file exceeding max_size? */
96 } vs_config_t;
97 
98 
99 #ifdef _KERNEL
100 int vscan_svc_init(void);
101 void vscan_svc_fini(void);
102 int vscan_svc_enable(void);
103 void vscan_svc_disable(void);
104 int vscan_svc_configure(vs_config_t *);
105 boolean_t vscan_svc_in_use(void);
106 void vscan_svc_scan_result(vs_scan_rsp_t *);
107 void vscan_svc_scan_abort(void);
108 vnode_t *vscan_svc_get_vnode(int);
109 
110 int vscan_door_init(void);
111 void vscan_door_fini(void);
112 int vscan_door_open(int);
113 void vscan_door_close(void);
114 int vscan_door_scan_file(vs_scan_req_t *);
115 
116 boolean_t vscan_drv_create_node(int);
117 
118 #endif /* _KERNEL */
119 
120 #ifdef __cplusplus
121 }
122 #endif
123 
124 
125 #endif /* _VSCAN_H */
126