xref: /illumos-gate/usr/src/uts/common/sys/vscan.h (revision fa94a07fd0519b8abfd871ad8fe60e6bebe1e2bb)
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 2007 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_MAX_FILES	1024	/* max concurent file scans */
43 #define	VS_DRV_PATH		"/devices/pseudo/vscan@0:vscan"
44 #define	VS_DRV_IOCTL_ENABLE	0x0001	/* door rendezvous */
45 #define	VS_DRV_IOCTL_DISABLE	0x0002	/* vscand shutting down */
46 #define	VS_DRV_IOCTL_CONFIG	0x0004	/* vscand config data update */
47 
48 /* vsr_access */
49 #define	VS_ACCESS_UNDEFINED	0
50 #define	VS_ACCESS_ALLOW		1
51 #define	VS_ACCESS_DENY		2
52 
53 #define	VS_TYPES_LEN		4096	/* vs_config_t - types buffer */
54 
55 /*
56  * AV_SCANSTAMP_SZ is the size of the scanstamp stored in the
57  * filesystem. vs_scanstamp_t is 1 character longer to allow
58  * a null terminated string to be used within vscan
59  */
60 typedef char vs_scanstamp_t[AV_SCANSTAMP_SZ + 1];
61 
62 /* used for both request to and response from vscand */
63 typedef struct vs_scan_req {
64 	uint32_t vsr_id;
65 	uint32_t vsr_flags;
66 	uint64_t vsr_size;
67 	uint8_t vsr_modified;
68 	uint8_t vsr_quarantined;
69 	char vsr_path[MAXPATHLEN];
70 	vs_scanstamp_t vsr_scanstamp;
71 	uint32_t vsr_access; /* VS_ACCESS_ALLOW, VS_ACCESS_DENY */
72 } vs_scan_req_t;
73 
74 
75 /* passed in VS_DRV_IOCTL_CONFIG */
76 typedef struct vs_config {
77 	char vsc_types[VS_TYPES_LEN];
78 	uint64_t vsc_types_len;
79 	uint64_t vsc_max_size;	/* files > max size (bytes) not scan */
80 	uint64_t vsc_allow;	/* allow access to file exceeding max_size? */
81 } vs_config_t;
82 
83 
84 #ifdef _KERNEL
85 
86 /*
87  * max no of types in vs_config_t.vsc_types
88  * used as dimention for array of pointers to types
89  */
90 #define	VS_TYPES_MAX		VS_TYPES_LEN / 2
91 
92 int vscan_svc_init(void);
93 void vscan_svc_fini(void);
94 void vscan_svc_enable(boolean_t);
95 int vscan_svc_configure(vs_config_t *);
96 boolean_t vscan_svc_in_use(void);
97 vnode_t *vscan_svc_get_vnode(int);
98 
99 int vscan_door_init(void);
100 void vscan_door_fini(void);
101 int vscan_door_open(int);
102 void vscan_door_close(void);
103 int vscan_door_scan_file(vs_scan_req_t *);
104 
105 #endif /* _KERNEL */
106 
107 #ifdef __cplusplus
108 }
109 #endif
110 
111 
112 #endif /* _VSCAN_H */
113