1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12 /*
13 * Copyright 2013 Damian Bogel. All rights reserved.
14 */
15
16 #ifndef _FSD_H
17 #define _FSD_H
18
19 /*
20 * TODO: Describe the purpose of the file here.
21 */
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #include <sys/ksynch.h>
28 #include <sys/list.h>
29 #include <sys/types.h>
30 #include <sys/vfs.h>
31
32
33 #define FSD_DEV_PATH "/dev/fsd"
34
35 /*
36 * Commands for ioctl().
37 */
38 #define FSDIOC (('f' << 24) | ('s' << 16) | ('d' << 8))
39 #define FSD_GET_STATUS (FSDIOC | 1)
40 #define FSD_ENABLE (FSDIOC | 2)
41 #define FSD_DISABLE (FSDIOC | 3)
42 #define FSD_DISTURB (FSDIOC | 4)
43 #define FSD_NODISTURB (FSDIOC | 5)
44 #define FSD_DISTURB_NEW (FSDIOC | 6)
45 #define FSD_NODISTURB_NEW (FSDIOC | 7)
46
47 #define FSD_ENTRY_NOT_FOUND 1
48 #define FSD_BAD_STAT 2
49 #define FSD_BAD_FD 3
50 #define FSD_NOT_ENABLED 4
51
52 typedef struct fsd_stat {
53 uint64_t fsds_read_less_chance;
54 uint64_t fsds_read_less_r[2]; /* range */
55 } fsd_stat_t;
56
57
58 typedef struct fsd_ioc_stat {
59 int64_t fsdis_mnt;
60 fsd_stat_t fsdis_stat;
61 } fsd_ioc_stat_t;
62
63 /*
64 * Once a set of hooks is installed on a filesystem, there's no need
65 * to bother fsh if we want to change the parameters of disturbance.
66 * Intead, we use fsdsi_lock to protect the fsd_stat_int_t when it's being
67 * used and changed.
68 */
69 typedef struct fsd_stat_int {
70 krwlock_t fsdsi_lock; /* protects fsdsi_stat */
71 vfs_t *fsdsi_vfsp;
72 fsd_stat_t fsdsi_stat;
73 list_node_t fsdsi_next;
74 } fsd_stat_int_t;
75
76 #ifdef __cplusplus
77 }
78 #endif
79
80 #endif /* _FSD_H */