Werner's Miscellanea
Sign in or create your account | Project List | Help
Werner's Miscellanea Git Source Tree
Root/
Source at commit ebb0d2708b542ee20929375d9a22d37d86b100a5 created 10 years 1 month ago. By Werner Almesberger, ircstat/README: change date format from MMYY to YYMM | |
---|---|
1 | /* |
2 | * fakefile.h - Programmed file system illusion |
3 | * |
4 | * Copyright 2012 by Werner Almesberger |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. |
10 | */ |
11 | |
12 | #ifndef FAKEFILE_H |
13 | #define FAKEFILE_H |
14 | |
15 | #include <sys/types.h> |
16 | #include <sys/stat.h> |
17 | |
18 | |
19 | enum fakefile_event_type { |
20 | ff_et_exit, |
21 | ff_et_open, |
22 | ff_et_read, |
23 | ff_et_write, |
24 | ff_et_close, |
25 | ff_et_unlink, |
26 | ff_et_rename, |
27 | ff_et_fstat, |
28 | }; |
29 | |
30 | struct fakefile_event { |
31 | enum fakefile_event_type type; |
32 | union { |
33 | struct fakefile_exit { |
34 | /* in */ |
35 | int status; |
36 | } exit; |
37 | struct fakefile_open { |
38 | /* in */ |
39 | char *name; |
40 | int flags; |
41 | int mode; |
42 | /* out */ |
43 | void *handle; |
44 | int res; /* < 0: -errno; 0: regular open (in slave) */ |
45 | } open; |
46 | struct fakefile_read { |
47 | /* in */ |
48 | const void *handle; |
49 | /* in/out */ |
50 | void *buf; |
51 | ssize_t len; |
52 | } read; |
53 | struct fakefile_write { |
54 | /* in */ |
55 | const void *handle; |
56 | void *buf; |
57 | /* in/out */ |
58 | ssize_t len; |
59 | } write; |
60 | struct fakefile_close { |
61 | /* in */ |
62 | const void *handle; |
63 | /* out */ |
64 | int res; |
65 | } close; |
66 | struct fakefile_unlink { |
67 | } unlink; |
68 | struct fakefile_rename { |
69 | } rename; |
70 | struct fakefile_fstat { |
71 | /* in */ |
72 | const void *handle; |
73 | /* out */ |
74 | struct stat st; |
75 | int res; |
76 | } fstat; |
77 | } u; |
78 | void *user; |
79 | }; |
80 | |
81 | |
82 | struct fakefile *fakefile_execv(const char *path, char *const argv[]); |
83 | struct fakefile_event *fakefile_poll(void); |
84 | void fakefile_respond(struct fakefile_event *event); |
85 | void fakefile_end(struct fakefile *ff); |
86 | |
87 | void fakefile_file(struct fakefile *ff, const char *name, |
88 | const void *in, size_t len, void **out); |
89 | void fakefile_antifile(struct fakefile *ff, const char *name); |
90 | |
91 | #endif /* !FAKEFILE_H */ |
92 |
Branches:
master