24 * Use is subject to license terms.
25 */
26
27 #include <sys/stat.h>
28 #include <sys/ddi.h>
29 #include <sys/sunddi.h>
30 #include <sys/time.h>
31 #include <sys/varargs.h>
32 #include <sys/conf.h>
33 #include <sys/modctl.h>
34 #include <sys/cmn_err.h>
35 #include <sys/vnode.h>
36 #include <fs/fs_subr.h>
37 #include <sys/types.h>
38 #include <sys/file.h>
39 #include <sys/disp.h>
40 #include <sys/sdt.h>
41 #include <sys/cred.h>
42 #include <sys/list.h>
43 #include <sys/vscan.h>
44
45 #define VS_REQ_MAGIC 0x52515354 /* 'RQST' */
46
47 #define VS_REQS_DEFAULT 20000 /* pending scan requests - reql */
48 #define VS_NODES_DEFAULT 128 /* concurrent file scans */
49 #define VS_WORKERS_DEFAULT 32 /* worker threads */
50 #define VS_SCANWAIT_DEFAULT 15*60 /* seconds to wait for scan result */
51 #define VS_REQL_HANDLER_TIMEOUT 30
52 #define VS_EXT_RECURSE_DEPTH 8
53
54 /* access derived from scan result (VS_STATUS_XXX) and file attributes */
55 #define VS_ACCESS_UNDEFINED 0
56 #define VS_ACCESS_ALLOW 1 /* return 0 */
57 #define VS_ACCESS_DENY 2 /* return EACCES */
58
59 #define tolower(C) (((C) >= 'A' && (C) <= 'Z') ? (C) - 'A' + 'a' : (C))
60 #define offsetof(s, m) (size_t)(&(((s *)0)->m))
61
62 /* global variables - tunable via /etc/system */
63 uint32_t vs_reqs_max = VS_REQS_DEFAULT; /* max scan requests */
64 uint32_t vs_nodes_max = VS_NODES_DEFAULT; /* max in-progress scan requests */
65 uint32_t vs_workers = VS_WORKERS_DEFAULT; /* max workers send reqs to vscand */
66 uint32_t vs_scan_wait = VS_SCANWAIT_DEFAULT; /* secs to wait for scan result */
67
68
69 /*
70 * vscan_svc_state
71 *
72 * +-----------------+
73 * | VS_SVC_UNCONFIG |
74 * +-----------------+
75 * | ^
76 * | svc_init | svc_fini
77 * v |
78 * +-----------------+
79 * | VS_SVC_IDLE |<----|
80 * +-----------------+ |
|
24 * Use is subject to license terms.
25 */
26
27 #include <sys/stat.h>
28 #include <sys/ddi.h>
29 #include <sys/sunddi.h>
30 #include <sys/time.h>
31 #include <sys/varargs.h>
32 #include <sys/conf.h>
33 #include <sys/modctl.h>
34 #include <sys/cmn_err.h>
35 #include <sys/vnode.h>
36 #include <fs/fs_subr.h>
37 #include <sys/types.h>
38 #include <sys/file.h>
39 #include <sys/disp.h>
40 #include <sys/sdt.h>
41 #include <sys/cred.h>
42 #include <sys/list.h>
43 #include <sys/vscan.h>
44 #include <sys/sysmacros.h>
45
46 #define VS_REQ_MAGIC 0x52515354 /* 'RQST' */
47
48 #define VS_REQS_DEFAULT 20000 /* pending scan requests - reql */
49 #define VS_NODES_DEFAULT 128 /* concurrent file scans */
50 #define VS_WORKERS_DEFAULT 32 /* worker threads */
51 #define VS_SCANWAIT_DEFAULT 15*60 /* seconds to wait for scan result */
52 #define VS_REQL_HANDLER_TIMEOUT 30
53 #define VS_EXT_RECURSE_DEPTH 8
54
55 /* access derived from scan result (VS_STATUS_XXX) and file attributes */
56 #define VS_ACCESS_UNDEFINED 0
57 #define VS_ACCESS_ALLOW 1 /* return 0 */
58 #define VS_ACCESS_DENY 2 /* return EACCES */
59
60 #define tolower(C) (((C) >= 'A' && (C) <= 'Z') ? (C) - 'A' + 'a' : (C))
61
62 /* global variables - tunable via /etc/system */
63 uint32_t vs_reqs_max = VS_REQS_DEFAULT; /* max scan requests */
64 uint32_t vs_nodes_max = VS_NODES_DEFAULT; /* max in-progress scan requests */
65 uint32_t vs_workers = VS_WORKERS_DEFAULT; /* max workers send reqs to vscand */
66 uint32_t vs_scan_wait = VS_SCANWAIT_DEFAULT; /* secs to wait for scan result */
67
68
69 /*
70 * vscan_svc_state
71 *
72 * +-----------------+
73 * | VS_SVC_UNCONFIG |
74 * +-----------------+
75 * | ^
76 * | svc_init | svc_fini
77 * v |
78 * +-----------------+
79 * | VS_SVC_IDLE |<----|
80 * +-----------------+ |
|