root / lab4 / .minix-src / include / minix / fsdriver.h @ 14
History | View | Annotate | Download (4.92 KB)
1 | 13 | up20180614 | #ifndef _MINIX_FSDRIVER_H
|
---|---|---|---|
2 | #define _MINIX_FSDRIVER_H
|
||
3 | |||
4 | struct stat;
|
||
5 | struct statvfs;
|
||
6 | struct timespec;
|
||
7 | |||
8 | /* Resulting node properties. */
|
||
9 | struct fsdriver_node {
|
||
10 | ino_t fn_ino_nr; /* inode number */
|
||
11 | mode_t fn_mode; /* file mode */
|
||
12 | off_t fn_size; /* file size */
|
||
13 | uid_t fn_uid; /* owning user ID */
|
||
14 | gid_t fn_gid; /* owning group ID */
|
||
15 | dev_t fn_dev; /* device number, for block/char dev */
|
||
16 | }; |
||
17 | |||
18 | /* Opaque data structure for the fsdriver_copyin, _copyout, _zero functions. */
|
||
19 | struct fsdriver_data {
|
||
20 | endpoint_t endpt; /* source/destination endpoint */
|
||
21 | union {
|
||
22 | cp_grant_id_t grant; /* grant, if endpt != SELF */
|
||
23 | char *ptr; /* local pointer, if endpt == SELF */ |
||
24 | }; |
||
25 | size_t size; /* total buffer size (check only) */
|
||
26 | }; |
||
27 | |||
28 | /* Opaque data structure for the fsdriver_dentry_ functions. */
|
||
29 | struct fsdriver_dentry {
|
||
30 | const struct fsdriver_data *data; |
||
31 | size_t data_size; |
||
32 | size_t data_off; |
||
33 | char *buf;
|
||
34 | size_t buf_size; |
||
35 | size_t buf_off; |
||
36 | }; |
||
37 | |||
38 | /*
|
||
39 | * For a few groups of calls, the functions have the same signature, so that
|
||
40 | * the file system can use a single implementation for multiple functions
|
||
41 | * without requiring extra stubs. Thus, we pass in an extra parameter that
|
||
42 | * identifies the call; one of the values below. For the same reason, the peek
|
||
43 | * and bpeek calls have a "data" parameter which is always set to NULL.
|
||
44 | */
|
||
45 | #define FSC_READ 0 /* read or bread call */ |
||
46 | #define FSC_WRITE 1 /* write or bwrite call */ |
||
47 | #define FSC_PEEK 2 /* peek or bpeek call */ |
||
48 | |||
49 | #define FSC_UNLINK 0 /* unlink call */ |
||
50 | #define FSC_RMDIR 1 /* rmdir call */ |
||
51 | |||
52 | /* Function call table for file system services. */
|
||
53 | struct fsdriver {
|
||
54 | int (*fdr_mount)(dev_t dev, unsigned int flags, |
||
55 | struct fsdriver_node *root_node, unsigned int *res_flags); |
||
56 | void (*fdr_unmount)(void); |
||
57 | int (*fdr_lookup)(ino_t dir_nr, char *name, struct fsdriver_node *node, |
||
58 | int *is_mountpt);
|
||
59 | int (*fdr_newnode)(mode_t mode, uid_t uid, gid_t gid, dev_t dev,
|
||
60 | struct fsdriver_node *node);
|
||
61 | int (*fdr_putnode)(ino_t ino_nr, unsigned int count); |
||
62 | ssize_t (*fdr_read)(ino_t ino_nr, struct fsdriver_data *data,
|
||
63 | size_t bytes, off_t pos, int call);
|
||
64 | ssize_t (*fdr_write)(ino_t ino_nr, struct fsdriver_data *data,
|
||
65 | size_t bytes, off_t pos, int call);
|
||
66 | ssize_t (*fdr_peek)(ino_t ino_nr, struct fsdriver_data *data,
|
||
67 | size_t bytes, off_t pos, int call);
|
||
68 | ssize_t (*fdr_getdents)(ino_t ino_nr, struct fsdriver_data *data,
|
||
69 | size_t bytes, off_t *pos); |
||
70 | int (*fdr_trunc)(ino_t ino_nr, off_t start_pos, off_t end_pos);
|
||
71 | void (*fdr_seek)(ino_t ino);
|
||
72 | int (*fdr_create)(ino_t dir_nr, char *name, mode_t mode, uid_t uid, |
||
73 | gid_t gid, struct fsdriver_node *node);
|
||
74 | int (*fdr_mkdir)(ino_t dir_nr, char *name, mode_t mode, uid_t uid, |
||
75 | gid_t gid); |
||
76 | int (*fdr_mknod)(ino_t dir_nr, char *name, mode_t mode, uid_t uid, |
||
77 | gid_t gid, dev_t rdev); |
||
78 | int (*fdr_link)(ino_t dir_nr, char *name, ino_t ino_nr); |
||
79 | int (*fdr_unlink)(ino_t dir_nr, char *name, int call); |
||
80 | int (*fdr_rmdir)(ino_t dir_nr, char *name, int call); |
||
81 | int (*fdr_rename)(ino_t old_dir_nr, char *old_name, ino_t new_dir_nr, |
||
82 | char *new_name);
|
||
83 | int (*fdr_slink)(ino_t dir_nr, char *name, uid_t uid, gid_t gid, |
||
84 | struct fsdriver_data *data, size_t bytes);
|
||
85 | ssize_t (*fdr_rdlink)(ino_t ino_nr, struct fsdriver_data *data,
|
||
86 | size_t bytes); |
||
87 | int (*fdr_stat)(ino_t ino_nr, struct stat *buf); |
||
88 | int (*fdr_chown)(ino_t ino_nr, uid_t uid, gid_t gid, mode_t *mode);
|
||
89 | int (*fdr_chmod)(ino_t ino_nr, mode_t *mode);
|
||
90 | int (*fdr_utime)(ino_t ino_nr, struct timespec *atime, |
||
91 | struct timespec *mtime);
|
||
92 | int (*fdr_mountpt)(ino_t ino_nr);
|
||
93 | int (*fdr_statvfs)(struct statvfs *buf); |
||
94 | void (*fdr_sync)(void); |
||
95 | void (*fdr_driver)(dev_t dev, char *label); |
||
96 | ssize_t (*fdr_bread)(dev_t dev, struct fsdriver_data *data,
|
||
97 | size_t bytes, off_t pos, int call);
|
||
98 | ssize_t (*fdr_bwrite)(dev_t dev, struct fsdriver_data *data,
|
||
99 | size_t bytes, off_t pos, int call);
|
||
100 | ssize_t (*fdr_bpeek)(dev_t dev, struct fsdriver_data *data,
|
||
101 | size_t bytes, off_t pos, int call);
|
||
102 | void (*fdr_bflush)(dev_t dev);
|
||
103 | void (*fdr_postcall)(void); |
||
104 | void (*fdr_other)(const message *m_ptr, int ipc_status); |
||
105 | }; |
||
106 | |||
107 | /* Functions defined by libfsdriver. */
|
||
108 | void fsdriver_process(const struct fsdriver * __restrict fdp, |
||
109 | const message * __restrict m_ptr, int ipc_status, int asyn_reply); |
||
110 | void fsdriver_terminate(void); |
||
111 | void fsdriver_task(struct fsdriver *fdp); |
||
112 | |||
113 | int fsdriver_copyin(const struct fsdriver_data *data, size_t off, void *ptr, |
||
114 | size_t len); |
||
115 | int fsdriver_copyout(const struct fsdriver_data *data, size_t off, |
||
116 | const void *ptr, size_t len); |
||
117 | int fsdriver_zero(const struct fsdriver_data *data, size_t off, size_t len); |
||
118 | |||
119 | void fsdriver_dentry_init(struct fsdriver_dentry * __restrict dentry, |
||
120 | const struct fsdriver_data * __restrict data, size_t bytes, |
||
121 | char * __restrict buf, size_t bufsize);
|
||
122 | ssize_t fsdriver_dentry_add(struct fsdriver_dentry * __restrict dentry,
|
||
123 | ino_t ino_nr, const char * __restrict name, size_t namelen, |
||
124 | unsigned int type); |
||
125 | ssize_t fsdriver_dentry_finish(struct fsdriver_dentry *dentry);
|
||
126 | |||
127 | #endif /* !_MINIX_FSDRIVER_H */ |