annotate src/lib-fs/fs-api.h @ 20717:4e90ac53cd05

lib-fs: Moved fs_write_stream_abort_parent() to fs-api-private.h Only fs wrapper drivers are supposed to call it.
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Fri, 09 Sep 2016 02:50:27 +0300
parents ff73fdd0558d
children 59a3ab804bcc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12309
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
1 #ifndef FS_API_H
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2 #define FS_API_H
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
4 struct stat;
15085
8f4ce0932777 lib-fs: fs_init() API changed to allow returning an error.
Timo Sirainen <tss@iki.fi>
parents: 12309
diff changeset
5 struct fs;
12309
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
6 struct fs_file;
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
7 struct fs_lock;
16721
7e0ebc2faf3c lib-fs: Added support for giving a hash of the written data to be verified by storage.
Timo Sirainen <tss@iki.fi>
parents: 16404
diff changeset
8 struct hash_method;
12309
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
9
18258
a27eed623099 lib-fs: Added FS_METADATA_OBJECTID macro.
Timo Sirainen <tss@iki.fi>
parents: 18257
diff changeset
10 /* Metadata with this prefix shouldn't actually be sent to storage. */
a27eed623099 lib-fs: Added FS_METADATA_OBJECTID macro.
Timo Sirainen <tss@iki.fi>
parents: 18257
diff changeset
11 #define FS_METADATA_INTERNAL_PREFIX ":/X-Dovecot-fs-api-"
a27eed623099 lib-fs: Added FS_METADATA_OBJECTID macro.
Timo Sirainen <tss@iki.fi>
parents: 18257
diff changeset
12 /* fs_write*() may return a hex-encoded object ID after write is finished.
a27eed623099 lib-fs: Added FS_METADATA_OBJECTID macro.
Timo Sirainen <tss@iki.fi>
parents: 18257
diff changeset
13 This can be later on used to optimize reads by setting it before reading
a27eed623099 lib-fs: Added FS_METADATA_OBJECTID macro.
Timo Sirainen <tss@iki.fi>
parents: 18257
diff changeset
14 the file. */
a27eed623099 lib-fs: Added FS_METADATA_OBJECTID macro.
Timo Sirainen <tss@iki.fi>
parents: 18257
diff changeset
15 #define FS_METADATA_OBJECTID FS_METADATA_INTERNAL_PREFIX"ObjectID"
a27eed623099 lib-fs: Added FS_METADATA_OBJECTID macro.
Timo Sirainen <tss@iki.fi>
parents: 18257
diff changeset
16
15198
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
17 enum fs_properties {
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
18 FS_PROPERTY_METADATA = 0x01,
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
19 FS_PROPERTY_LOCKS = 0x02,
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
20 FS_PROPERTY_FASTCOPY = 0x04,
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
21 FS_PROPERTY_RENAME = 0x08,
15399
39578785ee92 lib-fs: Added ITER and RELIABLEITER properties for backends.
Timo Sirainen <tss@iki.fi>
parents: 15397
diff changeset
22 FS_PROPERTY_STAT = 0x10,
39578785ee92 lib-fs: Added ITER and RELIABLEITER properties for backends.
Timo Sirainen <tss@iki.fi>
parents: 15397
diff changeset
23 /* Iteration is possible */
39578785ee92 lib-fs: Added ITER and RELIABLEITER properties for backends.
Timo Sirainen <tss@iki.fi>
parents: 15397
diff changeset
24 FS_PROPERTY_ITER = 0x20,
39578785ee92 lib-fs: Added ITER and RELIABLEITER properties for backends.
Timo Sirainen <tss@iki.fi>
parents: 15397
diff changeset
25 /* Iteration always returns all of the files (instead of possibly
39578785ee92 lib-fs: Added ITER and RELIABLEITER properties for backends.
Timo Sirainen <tss@iki.fi>
parents: 15397
diff changeset
26 slightly out of date view) */
15456
959afc4f76eb lib-fs: Added FS_PROPERTY_DIRECTORIES.
Timo Sirainen <tss@iki.fi>
parents: 15445
diff changeset
27 FS_PROPERTY_RELIABLEITER= 0x40,
959afc4f76eb lib-fs: Added FS_PROPERTY_DIRECTORIES.
Timo Sirainen <tss@iki.fi>
parents: 15445
diff changeset
28 /* Backend uses directories, which aren't automatically deleted
959afc4f76eb lib-fs: Added FS_PROPERTY_DIRECTORIES.
Timo Sirainen <tss@iki.fi>
parents: 15445
diff changeset
29 when its children are deleted. */
16721
7e0ebc2faf3c lib-fs: Added support for giving a hash of the written data to be verified by storage.
Timo Sirainen <tss@iki.fi>
parents: 16404
diff changeset
30 FS_PROPERTY_DIRECTORIES = 0x80,
7e0ebc2faf3c lib-fs: Added support for giving a hash of the written data to be verified by storage.
Timo Sirainen <tss@iki.fi>
parents: 16404
diff changeset
31 FS_PROPERTY_WRITE_HASH_MD5 = 0x100,
17614
2fada3a76d10 lib-fs: Added FS_PROPERTY_COPY_METADATA and fs_set_metadata() tracking.
Timo Sirainen <tss@iki.fi>
parents: 17612
diff changeset
32 FS_PROPERTY_WRITE_HASH_SHA256 = 0x200,
2fada3a76d10 lib-fs: Added FS_PROPERTY_COPY_METADATA and fs_set_metadata() tracking.
Timo Sirainen <tss@iki.fi>
parents: 17612
diff changeset
33 /* fs_copy() will copy the metadata if fs_set_metadata() hasn't
2fada3a76d10 lib-fs: Added FS_PROPERTY_COPY_METADATA and fs_set_metadata() tracking.
Timo Sirainen <tss@iki.fi>
parents: 17612
diff changeset
34 been explicitly called. */
18099
8973329d1ceb lib-fs: Added FS_PROPERTY_ASYNC.
Timo Sirainen <tss@iki.fi>
parents: 18093
diff changeset
35 FS_PROPERTY_COPY_METADATA = 0x400,
8973329d1ceb lib-fs: Added FS_PROPERTY_ASYNC.
Timo Sirainen <tss@iki.fi>
parents: 18093
diff changeset
36 /* Backend support asynchronous file operations. */
8973329d1ceb lib-fs: Added FS_PROPERTY_ASYNC.
Timo Sirainen <tss@iki.fi>
parents: 18093
diff changeset
37 FS_PROPERTY_ASYNC = 0x800,
18257
29bd2bcd56d6 lib-fs: Added flag for iteration returning object IDs.
Timo Sirainen <tss@iki.fi>
parents: 18099
diff changeset
38 /* Backend supports FS_ITER_FLAG_OBJECTIDS. */
20169
e9dd4bfa2c8c lib-fs: Added FS_PROPERTY_FASTCOPY_CHANGED_METADATA
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19399
diff changeset
39 FS_PROPERTY_OBJECTIDS = 0x1000,
e9dd4bfa2c8c lib-fs: Added FS_PROPERTY_FASTCOPY_CHANGED_METADATA
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19399
diff changeset
40 /* fs_copy() is fast even when file's metadata is changed */
e9dd4bfa2c8c lib-fs: Added FS_PROPERTY_FASTCOPY_CHANGED_METADATA
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 19399
diff changeset
41 FS_PROPERTY_FASTCOPY_CHANGED_METADATA = 0x2000,
15198
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
42 };
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
43
12309
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
44 enum fs_open_mode {
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
45 /* Open only for reading, or fail with ENOENT if it doesn't exist */
15198
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
46 FS_OPEN_MODE_READONLY,
12309
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
47 /* Create a new file, fail with EEXIST if it already exists */
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
48 FS_OPEN_MODE_CREATE,
15198
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
49 /* Create a new file with a new unique name. The generated name is a
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
50 128bit hex-encoded string. The fs_open()'s path parameter specifies
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
51 only the directory where the file is created to. */
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
52 FS_OPEN_MODE_CREATE_UNIQUE_128,
12309
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
53 /* Create or replace a file */
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
54 FS_OPEN_MODE_REPLACE,
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
55 /* Append to existing file, fail with ENOENT if it doesn't exist */
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
56 FS_OPEN_MODE_APPEND
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
57
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
58 #define FS_OPEN_MODE_MASK 0x0f
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
59 };
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
60
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
61 enum fs_open_flags {
15740
397253f15f36 lib-fs: Changed FS_OPEN_FLAG_UNIMPORTANT to a reversed FS_OPEN_FLAG_FSYNC.
Timo Sirainen <tss@iki.fi>
parents: 15729
diff changeset
62 /* File is important and writing must call fsync() or have equivalent
397253f15f36 lib-fs: Changed FS_OPEN_FLAG_UNIMPORTANT to a reversed FS_OPEN_FLAG_FSYNC.
Timo Sirainen <tss@iki.fi>
parents: 15729
diff changeset
63 behavior. */
397253f15f36 lib-fs: Changed FS_OPEN_FLAG_UNIMPORTANT to a reversed FS_OPEN_FLAG_FSYNC.
Timo Sirainen <tss@iki.fi>
parents: 15729
diff changeset
64 FS_OPEN_FLAG_FSYNC = 0x10,
15198
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
65 /* Asynchronous writes: fs_write() will fail with EAGAIN if it needs to
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
66 be called again (the retries can use size=0). For streams
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
67 fs_write_stream_finish() may request retrying with 0.
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
68
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
69 Asynchronous reads: fs_read() will fail with EAGAIN if it's not
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
70 finished and fs_read_stream() returns a nonblocking stream. */
15729
8515223e4766 lib-fs: Added FS_OPEN_FLAG_SEEKABLE. Globally handle fs_read_stream() seekability and waits.
Timo Sirainen <tss@iki.fi>
parents: 15652
diff changeset
71 FS_OPEN_FLAG_ASYNC = 0x20,
8515223e4766 lib-fs: Added FS_OPEN_FLAG_SEEKABLE. Globally handle fs_read_stream() seekability and waits.
Timo Sirainen <tss@iki.fi>
parents: 15652
diff changeset
72 /* fs_read_stream() must return a seekable input stream */
16835
5672c40cf421 lib-fs: Added FS_OPEN_FLAG_ASYNC_NOQUEUE
Timo Sirainen <tss@iki.fi>
parents: 16722
diff changeset
73 FS_OPEN_FLAG_SEEKABLE = 0x40,
5672c40cf421 lib-fs: Added FS_OPEN_FLAG_ASYNC_NOQUEUE
Timo Sirainen <tss@iki.fi>
parents: 16722
diff changeset
74 /* Backend should handle this file's operations immediately without
5672c40cf421 lib-fs: Added FS_OPEN_FLAG_ASYNC_NOQUEUE
Timo Sirainen <tss@iki.fi>
parents: 16722
diff changeset
75 any additional command queueing. The caller is assumed to be the one
5672c40cf421 lib-fs: Added FS_OPEN_FLAG_ASYNC_NOQUEUE
Timo Sirainen <tss@iki.fi>
parents: 16722
diff changeset
76 doing any rate limiting if needed. This flag can only be used with
5672c40cf421 lib-fs: Added FS_OPEN_FLAG_ASYNC_NOQUEUE
Timo Sirainen <tss@iki.fi>
parents: 16722
diff changeset
77 ASYNC flag, synchronous requests are never queued. */
5672c40cf421 lib-fs: Added FS_OPEN_FLAG_ASYNC_NOQUEUE
Timo Sirainen <tss@iki.fi>
parents: 16722
diff changeset
78 FS_OPEN_FLAG_ASYNC_NOQUEUE = 0x80
12309
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
79 };
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
80
15652
6e5adbf30e35 lib-fs: Added flags to iteration, and FS_ITER_FLAG_DIRS as the first flag.
Timo Sirainen <tss@iki.fi>
parents: 15456
diff changeset
81 enum fs_iter_flags {
6e5adbf30e35 lib-fs: Added flags to iteration, and FS_ITER_FLAG_DIRS as the first flag.
Timo Sirainen <tss@iki.fi>
parents: 15456
diff changeset
82 /* Iterate only directories, not files */
16722
6ed90c968ab1 lib-fs: Added support for asynchronous fs iteration.
Timo Sirainen <tss@iki.fi>
parents: 16721
diff changeset
83 FS_ITER_FLAG_DIRS = 0x01,
6ed90c968ab1 lib-fs: Added support for asynchronous fs iteration.
Timo Sirainen <tss@iki.fi>
parents: 16721
diff changeset
84 /* Request asynchronous iteration. */
18257
29bd2bcd56d6 lib-fs: Added flag for iteration returning object IDs.
Timo Sirainen <tss@iki.fi>
parents: 18099
diff changeset
85 FS_ITER_FLAG_ASYNC = 0x02,
29bd2bcd56d6 lib-fs: Added flag for iteration returning object IDs.
Timo Sirainen <tss@iki.fi>
parents: 18099
diff changeset
86 /* Instead of returning object names, return <objectid>/<object name>.
29bd2bcd56d6 lib-fs: Added flag for iteration returning object IDs.
Timo Sirainen <tss@iki.fi>
parents: 18099
diff changeset
87 If this isn't supported, the <objectid> is returned empty. The
29bd2bcd56d6 lib-fs: Added flag for iteration returning object IDs.
Timo Sirainen <tss@iki.fi>
parents: 18099
diff changeset
88 object IDs are always hex-encoded data. This flag can be used only
29bd2bcd56d6 lib-fs: Added flag for iteration returning object IDs.
Timo Sirainen <tss@iki.fi>
parents: 18099
diff changeset
89 if FS_PROPERTY_OBJECTIDS is enabled. */
18284
e270bf24491c lib-fs: Added FS_ITER_FLAG_NOCACHE
Timo Sirainen <tss@iki.fi>
parents: 18258
diff changeset
90 FS_ITER_FLAG_OBJECTIDS = 0x04,
e270bf24491c lib-fs: Added FS_ITER_FLAG_NOCACHE
Timo Sirainen <tss@iki.fi>
parents: 18258
diff changeset
91 /* Explicitly disable all caching for this iteration (if anything
e270bf24491c lib-fs: Added FS_ITER_FLAG_NOCACHE
Timo Sirainen <tss@iki.fi>
parents: 18258
diff changeset
92 happens to be enabled). This should be used only in situations where
e270bf24491c lib-fs: Added FS_ITER_FLAG_NOCACHE
Timo Sirainen <tss@iki.fi>
parents: 18258
diff changeset
93 the iteration is used to fix something that is broken, e.g. doveadm
e270bf24491c lib-fs: Added FS_ITER_FLAG_NOCACHE
Timo Sirainen <tss@iki.fi>
parents: 18258
diff changeset
94 force-resync. */
e270bf24491c lib-fs: Added FS_ITER_FLAG_NOCACHE
Timo Sirainen <tss@iki.fi>
parents: 18258
diff changeset
95 FS_ITER_FLAG_NOCACHE = 0x08
15652
6e5adbf30e35 lib-fs: Added flags to iteration, and FS_ITER_FLAG_DIRS as the first flag.
Timo Sirainen <tss@iki.fi>
parents: 15456
diff changeset
96 };
6e5adbf30e35 lib-fs: Added flags to iteration, and FS_ITER_FLAG_DIRS as the first flag.
Timo Sirainen <tss@iki.fi>
parents: 15456
diff changeset
97
19148
d8c27e220815 lib-fs: Track operation timing statistics if enable_timing setting is set.
Timo Sirainen <tss@iki.fi>
parents: 18760
diff changeset
98 enum fs_op {
d8c27e220815 lib-fs: Track operation timing statistics if enable_timing setting is set.
Timo Sirainen <tss@iki.fi>
parents: 18760
diff changeset
99 FS_OP_WAIT,
d8c27e220815 lib-fs: Track operation timing statistics if enable_timing setting is set.
Timo Sirainen <tss@iki.fi>
parents: 18760
diff changeset
100 FS_OP_METADATA,
d8c27e220815 lib-fs: Track operation timing statistics if enable_timing setting is set.
Timo Sirainen <tss@iki.fi>
parents: 18760
diff changeset
101 FS_OP_PREFETCH,
d8c27e220815 lib-fs: Track operation timing statistics if enable_timing setting is set.
Timo Sirainen <tss@iki.fi>
parents: 18760
diff changeset
102 FS_OP_READ,
d8c27e220815 lib-fs: Track operation timing statistics if enable_timing setting is set.
Timo Sirainen <tss@iki.fi>
parents: 18760
diff changeset
103 FS_OP_WRITE,
d8c27e220815 lib-fs: Track operation timing statistics if enable_timing setting is set.
Timo Sirainen <tss@iki.fi>
parents: 18760
diff changeset
104 FS_OP_LOCK,
d8c27e220815 lib-fs: Track operation timing statistics if enable_timing setting is set.
Timo Sirainen <tss@iki.fi>
parents: 18760
diff changeset
105 FS_OP_EXISTS,
d8c27e220815 lib-fs: Track operation timing statistics if enable_timing setting is set.
Timo Sirainen <tss@iki.fi>
parents: 18760
diff changeset
106 FS_OP_STAT,
d8c27e220815 lib-fs: Track operation timing statistics if enable_timing setting is set.
Timo Sirainen <tss@iki.fi>
parents: 18760
diff changeset
107 FS_OP_COPY,
d8c27e220815 lib-fs: Track operation timing statistics if enable_timing setting is set.
Timo Sirainen <tss@iki.fi>
parents: 18760
diff changeset
108 FS_OP_RENAME,
d8c27e220815 lib-fs: Track operation timing statistics if enable_timing setting is set.
Timo Sirainen <tss@iki.fi>
parents: 18760
diff changeset
109 FS_OP_DELETE,
d8c27e220815 lib-fs: Track operation timing statistics if enable_timing setting is set.
Timo Sirainen <tss@iki.fi>
parents: 18760
diff changeset
110 FS_OP_ITER,
d8c27e220815 lib-fs: Track operation timing statistics if enable_timing setting is set.
Timo Sirainen <tss@iki.fi>
parents: 18760
diff changeset
111
d8c27e220815 lib-fs: Track operation timing statistics if enable_timing setting is set.
Timo Sirainen <tss@iki.fi>
parents: 18760
diff changeset
112 FS_OP_COUNT
d8c27e220815 lib-fs: Track operation timing statistics if enable_timing setting is set.
Timo Sirainen <tss@iki.fi>
parents: 18760
diff changeset
113 };
d8c27e220815 lib-fs: Track operation timing statistics if enable_timing setting is set.
Timo Sirainen <tss@iki.fi>
parents: 18760
diff changeset
114
12309
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
115 struct fs_settings {
17612
3f84f9cb7460 lib-fs: Added fs_settings.username and .session_id
Timo Sirainen <tss@iki.fi>
parents: 16862
diff changeset
116 /* Username and session ID are mainly used for debugging/logging,
3f84f9cb7460 lib-fs: Added fs_settings.username and .session_id
Timo Sirainen <tss@iki.fi>
parents: 16862
diff changeset
117 but may also be useful for other purposes if they exist (they
3f84f9cb7460 lib-fs: Added fs_settings.username and .session_id
Timo Sirainen <tss@iki.fi>
parents: 16862
diff changeset
118 may be NULL). */
3f84f9cb7460 lib-fs: Added fs_settings.username and .session_id
Timo Sirainen <tss@iki.fi>
parents: 16862
diff changeset
119 const char *username;
3f84f9cb7460 lib-fs: Added fs_settings.username and .session_id
Timo Sirainen <tss@iki.fi>
parents: 16862
diff changeset
120 const char *session_id;
3f84f9cb7460 lib-fs: Added fs_settings.username and .session_id
Timo Sirainen <tss@iki.fi>
parents: 16862
diff changeset
121
15198
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
122 /* Dovecot instance's base_dir */
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
123 const char *base_dir;
15400
5552ac605201 lib-fs: Added a temp_dir setting that the caller can specify.
Timo Sirainen <tss@iki.fi>
parents: 15399
diff changeset
124 /* Directory where temporary files can be created at any time
5552ac605201 lib-fs: Added a temp_dir setting that the caller can specify.
Timo Sirainen <tss@iki.fi>
parents: 15399
diff changeset
125 (e.g. /tmp or mail_temp_dir) */
5552ac605201 lib-fs: Added a temp_dir setting that the caller can specify.
Timo Sirainen <tss@iki.fi>
parents: 15399
diff changeset
126 const char *temp_dir;
16038
aa255de644d0 lib-fs: Allow passing through SSL client settings via struct fs_settings.
Timo Sirainen <tss@iki.fi>
parents: 16018
diff changeset
127 /* SSL client settings. */
aa255de644d0 lib-fs: Allow passing through SSL client settings via struct fs_settings.
Timo Sirainen <tss@iki.fi>
parents: 16018
diff changeset
128 const struct ssl_iostream_settings *ssl_client_set;
15400
5552ac605201 lib-fs: Added a temp_dir setting that the caller can specify.
Timo Sirainen <tss@iki.fi>
parents: 15399
diff changeset
129
15198
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
130 /* Automatically try to rmdir() directories up to this path when
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
131 deleting files. */
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
132 const char *root_path;
12309
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
133 /* When creating temporary files, use this prefix
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
134 (to avoid conflicts with existing files). */
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
135 const char *temp_file_prefix;
16862
d23c8e97dc69 lib-fs: Added dns_client to fs_settings.
Timo Sirainen <tss@iki.fi>
parents: 16835
diff changeset
136 /* If the backend needs to do DNS lookups, use this dns_client for
d23c8e97dc69 lib-fs: Added dns_client to fs_settings.
Timo Sirainen <tss@iki.fi>
parents: 16835
diff changeset
137 them. */
d23c8e97dc69 lib-fs: Added dns_client to fs_settings.
Timo Sirainen <tss@iki.fi>
parents: 16835
diff changeset
138 struct dns_client *dns_client;
16230
821a2b489039 lib-fs: Added debug setting.
Timo Sirainen <tss@iki.fi>
parents: 16038
diff changeset
139
821a2b489039 lib-fs: Added debug setting.
Timo Sirainen <tss@iki.fi>
parents: 16038
diff changeset
140 /* Enable debugging */
821a2b489039 lib-fs: Added debug setting.
Timo Sirainen <tss@iki.fi>
parents: 16038
diff changeset
141 bool debug;
19148
d8c27e220815 lib-fs: Track operation timing statistics if enable_timing setting is set.
Timo Sirainen <tss@iki.fi>
parents: 18760
diff changeset
142 /* Enable timing statistics */
d8c27e220815 lib-fs: Track operation timing statistics if enable_timing setting is set.
Timo Sirainen <tss@iki.fi>
parents: 18760
diff changeset
143 bool enable_timing;
12309
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
144 };
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
145
18290
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
146 struct fs_stats {
18300
0effbc9afeee lib-fs: struct fs_stats comment updates
Timo Sirainen <tss@iki.fi>
parents: 18290
diff changeset
147 /* Number of fs_prefetch() calls. Counted only if fs_read*() hasn't
0effbc9afeee lib-fs: struct fs_stats comment updates
Timo Sirainen <tss@iki.fi>
parents: 18290
diff changeset
148 already been called for the file (which would be pretty pointless
0effbc9afeee lib-fs: struct fs_stats comment updates
Timo Sirainen <tss@iki.fi>
parents: 18290
diff changeset
149 to do). */
18290
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
150 unsigned int prefetch_count;
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
151 /* Number of fs_read*() calls. Counted only if fs_prefetch() hasn't
18300
0effbc9afeee lib-fs: struct fs_stats comment updates
Timo Sirainen <tss@iki.fi>
parents: 18290
diff changeset
152 already been called for the file. */
18290
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
153 unsigned int read_count;
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
154 /* Number of fs_lookup_metadata() calls. Counted only if neither
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
155 fs_read*() nor fs_prefetch() has been called for the file. */
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
156 unsigned int lookup_metadata_count;
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
157 /* Number of fs_stat() calls. Counted only if none of the above
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
158 has been called (because the stat result should be cached). */
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
159 unsigned int stat_count;
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
160
18300
0effbc9afeee lib-fs: struct fs_stats comment updates
Timo Sirainen <tss@iki.fi>
parents: 18290
diff changeset
161 /* Number of fs_write*() calls. */
18290
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
162 unsigned int write_count;
18300
0effbc9afeee lib-fs: struct fs_stats comment updates
Timo Sirainen <tss@iki.fi>
parents: 18290
diff changeset
163 /* Number of fs_exists() calls, which actually went to the backend
0effbc9afeee lib-fs: struct fs_stats comment updates
Timo Sirainen <tss@iki.fi>
parents: 18290
diff changeset
164 instead of being handled by fs_stat() call due to fs_exists() not
0effbc9afeee lib-fs: struct fs_stats comment updates
Timo Sirainen <tss@iki.fi>
parents: 18290
diff changeset
165 being implemented. */
18290
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
166 unsigned int exists_count;
18300
0effbc9afeee lib-fs: struct fs_stats comment updates
Timo Sirainen <tss@iki.fi>
parents: 18290
diff changeset
167 /* Number of fs_delete() calls. */
18290
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
168 unsigned int delete_count;
18300
0effbc9afeee lib-fs: struct fs_stats comment updates
Timo Sirainen <tss@iki.fi>
parents: 18290
diff changeset
169 /* Number of fs_copy() calls. If backend doesn't implement copying
0effbc9afeee lib-fs: struct fs_stats comment updates
Timo Sirainen <tss@iki.fi>
parents: 18290
diff changeset
170 operation but falls back to regular read+write instead, this count
0effbc9afeee lib-fs: struct fs_stats comment updates
Timo Sirainen <tss@iki.fi>
parents: 18290
diff changeset
171 isn't increased but the read+write counters are. */
18290
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
172 unsigned int copy_count;
18300
0effbc9afeee lib-fs: struct fs_stats comment updates
Timo Sirainen <tss@iki.fi>
parents: 18290
diff changeset
173 /* Number of fs_rename() calls. */
18290
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
174 unsigned int rename_count;
18300
0effbc9afeee lib-fs: struct fs_stats comment updates
Timo Sirainen <tss@iki.fi>
parents: 18290
diff changeset
175 /* Number of fs_iter_init() calls. */
18290
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
176 unsigned int iter_count;
19148
d8c27e220815 lib-fs: Track operation timing statistics if enable_timing setting is set.
Timo Sirainen <tss@iki.fi>
parents: 18760
diff changeset
177
20329
e2bc96ed57ff lib-fs: Added write_bytes to statistics
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20320
diff changeset
178 /* Number of bytes written by fs_write*() calls. */
e2bc96ed57ff lib-fs: Added write_bytes to statistics
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20320
diff changeset
179 uint64_t write_bytes;
e2bc96ed57ff lib-fs: Added write_bytes to statistics
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20320
diff changeset
180
19148
d8c27e220815 lib-fs: Track operation timing statistics if enable_timing setting is set.
Timo Sirainen <tss@iki.fi>
parents: 18760
diff changeset
181 /* Cumulative sum of usecs spent on calls - set only if
d8c27e220815 lib-fs: Track operation timing statistics if enable_timing setting is set.
Timo Sirainen <tss@iki.fi>
parents: 18760
diff changeset
182 fs_settings.enable_timing=TRUE */
d8c27e220815 lib-fs: Track operation timing statistics if enable_timing setting is set.
Timo Sirainen <tss@iki.fi>
parents: 18760
diff changeset
183 struct timing *timings[FS_OP_COUNT];
18290
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
184 };
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
185
15198
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
186 struct fs_metadata {
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
187 const char *key;
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
188 const char *value;
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
189 };
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
190 ARRAY_DEFINE_TYPE(fs_metadata, struct fs_metadata);
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
191
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
192 typedef void fs_file_async_callback_t(void *context);
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
193
15085
8f4ce0932777 lib-fs: fs_init() API changed to allow returning an error.
Timo Sirainen <tss@iki.fi>
parents: 12309
diff changeset
194 int fs_init(const char *driver, const char *args,
8f4ce0932777 lib-fs: fs_init() API changed to allow returning an error.
Timo Sirainen <tss@iki.fi>
parents: 12309
diff changeset
195 const struct fs_settings *set,
8f4ce0932777 lib-fs: fs_init() API changed to allow returning an error.
Timo Sirainen <tss@iki.fi>
parents: 12309
diff changeset
196 struct fs **fs_r, const char **error_r);
18514
0b297bc94746 lib-fs: Added fs_ref() and fs_unref() for reference counting.
Timo Sirainen <tss@iki.fi>
parents: 18300
diff changeset
197 /* same as fs_unref() */
12309
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
198 void fs_deinit(struct fs **fs);
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
199
18514
0b297bc94746 lib-fs: Added fs_ref() and fs_unref() for reference counting.
Timo Sirainen <tss@iki.fi>
parents: 18300
diff changeset
200 void fs_ref(struct fs *fs);
0b297bc94746 lib-fs: Added fs_ref() and fs_unref() for reference counting.
Timo Sirainen <tss@iki.fi>
parents: 18300
diff changeset
201 void fs_unref(struct fs **fs);
0b297bc94746 lib-fs: Added fs_ref() and fs_unref() for reference counting.
Timo Sirainen <tss@iki.fi>
parents: 18300
diff changeset
202
18289
422b5a01d18e lib-fs: Added fs_get_parent() and fs_get_driver()
Timo Sirainen <tss@iki.fi>
parents: 18284
diff changeset
203 /* Returns the parent filesystem (if this is a wrapper fs) or NULL if
422b5a01d18e lib-fs: Added fs_get_parent() and fs_get_driver()
Timo Sirainen <tss@iki.fi>
parents: 18284
diff changeset
204 there's no parent. */
422b5a01d18e lib-fs: Added fs_get_parent() and fs_get_driver()
Timo Sirainen <tss@iki.fi>
parents: 18284
diff changeset
205 struct fs *fs_get_parent(struct fs *fs);
422b5a01d18e lib-fs: Added fs_get_parent() and fs_get_driver()
Timo Sirainen <tss@iki.fi>
parents: 18284
diff changeset
206 /* Returns the filesystem's driver name. */
422b5a01d18e lib-fs: Added fs_get_parent() and fs_get_driver()
Timo Sirainen <tss@iki.fi>
parents: 18284
diff changeset
207 const char *fs_get_driver(struct fs *fs);
16404
16183ae98947 lib-fs: Added fs_get_root_driver()
Timo Sirainen <tss@iki.fi>
parents: 16269
diff changeset
208 /* Returns the root fs's driver name (bypassing all wrapper fses) */
16183ae98947 lib-fs: Added fs_get_root_driver()
Timo Sirainen <tss@iki.fi>
parents: 16269
diff changeset
209 const char *fs_get_root_driver(struct fs *fs);
16183ae98947 lib-fs: Added fs_get_root_driver()
Timo Sirainen <tss@iki.fi>
parents: 16269
diff changeset
210
15198
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
211 struct fs_file *fs_file_init(struct fs *fs, const char *path, int mode_flags);
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
212 void fs_file_deinit(struct fs_file **file);
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
213
16269
5ce775d70c7d lib-fs: Added fs_file_close() to explicitly close all streams that the file has open.
Timo Sirainen <tss@iki.fi>
parents: 16230
diff changeset
214 /* If the file has an input streams open, close them. */
5ce775d70c7d lib-fs: Added fs_file_close() to explicitly close all streams that the file has open.
Timo Sirainen <tss@iki.fi>
parents: 16230
diff changeset
215 void fs_file_close(struct fs_file *file);
5ce775d70c7d lib-fs: Added fs_file_close() to explicitly close all streams that the file has open.
Timo Sirainen <tss@iki.fi>
parents: 16230
diff changeset
216
15198
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
217 /* Return properties supported by backend. */
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
218 enum fs_properties fs_get_properties(struct fs *fs);
12309
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
219
15198
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
220 /* Add/replace metadata when saving a file. This makes sense only when the
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
221 file is being created/replaced. */
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
222 void fs_set_metadata(struct fs_file *file, const char *key, const char *value);
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
223 /* Return file's all metadata. */
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
224 int fs_get_metadata(struct fs_file *file,
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
225 const ARRAY_TYPE(fs_metadata) **metadata_r);
18093
372de41933c0 lib-fs: Added fs_lookup_metadata() wrapper to fs_get_metadata()
Timo Sirainen <tss@iki.fi>
parents: 17614
diff changeset
226 /* Wrapper to fs_get_metadata() to lookup a specific key. Returns 1 if value_r
372de41933c0 lib-fs: Added fs_lookup_metadata() wrapper to fs_get_metadata()
Timo Sirainen <tss@iki.fi>
parents: 17614
diff changeset
227 is set, 0 if key wasn't found, -1 if error. */
372de41933c0 lib-fs: Added fs_lookup_metadata() wrapper to fs_get_metadata()
Timo Sirainen <tss@iki.fi>
parents: 17614
diff changeset
228 int fs_lookup_metadata(struct fs_file *file, const char *key,
372de41933c0 lib-fs: Added fs_lookup_metadata() wrapper to fs_get_metadata()
Timo Sirainen <tss@iki.fi>
parents: 17614
diff changeset
229 const char **value_r);
15198
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
230
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
231 /* Returns the path given to fs_open(). If file was opened with
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
232 FS_OPEN_MODE_CREATE_UNIQUE_128 and the write has already finished,
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
233 return the path including the generated filename. */
12309
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
234 const char *fs_file_path(struct fs_file *file);
16721
7e0ebc2faf3c lib-fs: Added support for giving a hash of the written data to be verified by storage.
Timo Sirainen <tss@iki.fi>
parents: 16404
diff changeset
235 /* Returns the file's fs. */
7e0ebc2faf3c lib-fs: Added support for giving a hash of the written data to be verified by storage.
Timo Sirainen <tss@iki.fi>
parents: 16404
diff changeset
236 struct fs *fs_file_fs(struct fs_file *file);
12309
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
237
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
238 /* Return the error message for the last failed operation. */
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
239 const char *fs_last_error(struct fs *fs);
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
240 /* Convenience function for the above. Errors aren't preserved across files. */
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
241 const char *fs_file_last_error(struct fs_file *file);
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
242
15198
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
243 /* Try to asynchronously prefetch file into memory. Returns TRUE if file is
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
244 already in memory (i.e. caller should handle this file before prefetching
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
245 more), FALSE if not. The length is a hint of how much the caller expects
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
246 to read, but it may be more or less (0=whole file). */
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
247 bool fs_prefetch(struct fs_file *file, uoff_t length);
12309
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
248 /* Returns >0 if something was read, -1 if error (errno is set). */
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
249 ssize_t fs_read(struct fs_file *file, void *buf, size_t size);
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
250 /* Returns a stream for reading from file. Multiple streams can be opened,
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
251 and caller must destroy the streams before closing the file. */
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
252 struct istream *fs_read_stream(struct fs_file *file, size_t max_buffer_size);
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
253
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
254 /* Returns 0 if ok, -1 if error (errno is set). Note: With CREATE/REPLACE mode
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
255 files you can call fs_write() only once, the file creation is finished by it.
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
256 CREATE can return EEXIST here, if the destination file was already created.
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
257 With APPEND mode each fs_write() atomically appends the given data to
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
258 file. */
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
259 int fs_write(struct fs_file *file, const void *data, size_t size);
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
260
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
261 /* Write to file via output stream. The stream will be destroyed by
18760
83f1b9956788 lib-fs: Updated fs_write_stream_*() comments related to ostream corking and nfinish.
Timo Sirainen <tss@iki.fi>
parents: 18514
diff changeset
262 fs_write_stream_finish/abort. The returned ostream is already corked and
83f1b9956788 lib-fs: Updated fs_write_stream_*() comments related to ostream corking and nfinish.
Timo Sirainen <tss@iki.fi>
parents: 18514
diff changeset
263 it doesn't need to be uncorked. */
12309
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
264 struct ostream *fs_write_stream(struct fs_file *file);
18760
83f1b9956788 lib-fs: Updated fs_write_stream_*() comments related to ostream corking and nfinish.
Timo Sirainen <tss@iki.fi>
parents: 18514
diff changeset
265 /* Finish writing via stream, calling also o_stream_nfinish() on the stream and
83f1b9956788 lib-fs: Updated fs_write_stream_*() comments related to ostream corking and nfinish.
Timo Sirainen <tss@iki.fi>
parents: 18514
diff changeset
266 handling any pending errors. The file will be created/replaced/appended only
12309
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
267 after this call, same as with fs_write(). Anything written to the stream
15198
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
268 won't be visible earlier. Returns 1 if ok, 0 if async write isn't finished
15229
260b1ec12f41 lib-fs: Fixes to async APIs.
Timo Sirainen <tss@iki.fi>
parents: 15198
diff changeset
269 yet (retry calling fs_write_stream_finish_async()), -1 if error */
12309
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
270 int fs_write_stream_finish(struct fs_file *file, struct ostream **output);
15229
260b1ec12f41 lib-fs: Fixes to async APIs.
Timo Sirainen <tss@iki.fi>
parents: 15198
diff changeset
271 int fs_write_stream_finish_async(struct fs_file *file);
18760
83f1b9956788 lib-fs: Updated fs_write_stream_*() comments related to ostream corking and nfinish.
Timo Sirainen <tss@iki.fi>
parents: 18514
diff changeset
272 /* Abort writing via stream. Anything written to the stream is discarded.
83f1b9956788 lib-fs: Updated fs_write_stream_*() comments related to ostream corking and nfinish.
Timo Sirainen <tss@iki.fi>
parents: 18514
diff changeset
273 o_stream_ignore_last_errors() is called on the output stream so the caller
20237
7f346855509b lib-fs: Clarified fs_write_stream_abort() API and dropped its _async().
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20236
diff changeset
274 doesn't need to do it. This must not be called after
7f346855509b lib-fs: Clarified fs_write_stream_abort() API and dropped its _async().
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20236
diff changeset
275 fs_write_stream_finish(), i.e. it can't be used to abort a pending async
7f346855509b lib-fs: Clarified fs_write_stream_abort() API and dropped its _async().
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20236
diff changeset
276 write. */
12309
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
277 void fs_write_stream_abort(struct fs_file *file, struct ostream **output);
20673
246105771e0e fs-api: Add and use fs_write_stream_abort_error
Aki Tuomi <aki.tuomi@dovecot.fi>
parents: 20548
diff changeset
278 void fs_write_stream_abort_error(struct fs_file *file, struct ostream **output, const char *error_fmt, ...) ATTR_FORMAT(3, 4);
12309
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
279
16721
7e0ebc2faf3c lib-fs: Added support for giving a hash of the written data to be verified by storage.
Timo Sirainen <tss@iki.fi>
parents: 16404
diff changeset
280 /* Set a hash to the following write. The storage can then verify that the
7e0ebc2faf3c lib-fs: Added support for giving a hash of the written data to be verified by storage.
Timo Sirainen <tss@iki.fi>
parents: 16404
diff changeset
281 input data matches the specified hash, or fail if it doesn't. Typically
7e0ebc2faf3c lib-fs: Added support for giving a hash of the written data to be verified by storage.
Timo Sirainen <tss@iki.fi>
parents: 16404
diff changeset
282 implemented by Content-MD5 header. */
7e0ebc2faf3c lib-fs: Added support for giving a hash of the written data to be verified by storage.
Timo Sirainen <tss@iki.fi>
parents: 16404
diff changeset
283 void fs_write_set_hash(struct fs_file *file, const struct hash_method *method,
7e0ebc2faf3c lib-fs: Added support for giving a hash of the written data to be verified by storage.
Timo Sirainen <tss@iki.fi>
parents: 16404
diff changeset
284 const void *digest);
7e0ebc2faf3c lib-fs: Added support for giving a hash of the written data to be verified by storage.
Timo Sirainen <tss@iki.fi>
parents: 16404
diff changeset
285
15198
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
286 /* Call the specified callback whenever the file can be read/written to.
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
287 May call the callback immediately. */
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
288 void fs_file_set_async_callback(struct fs_file *file,
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
289 fs_file_async_callback_t *callback,
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
290 void *context);
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
291 /* Wait until some file can be read/written to more before returning.
15396
38f3bd4bf6e3 lib-fs: fs_wait_async() can now return an error.
Timo Sirainen <tss@iki.fi>
parents: 15229
diff changeset
292 It's an error to call this when there are no pending async operations.
38f3bd4bf6e3 lib-fs: fs_wait_async() can now return an error.
Timo Sirainen <tss@iki.fi>
parents: 15229
diff changeset
293 Returns 0 if ok, -1 if timed out. */
38f3bd4bf6e3 lib-fs: fs_wait_async() can now return an error.
Timo Sirainen <tss@iki.fi>
parents: 15229
diff changeset
294 int fs_wait_async(struct fs *fs);
20320
71f46b6a90e8 lib-fs: Added fs_switch_ioloop()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20237
diff changeset
295 /* Switch the fs to the current ioloop. This can be used to do fs_wait_async()
71f46b6a90e8 lib-fs: Added fs_switch_ioloop()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20237
diff changeset
296 among other IO work. Returns TRUE if there is actually some work that can
71f46b6a90e8 lib-fs: Added fs_switch_ioloop()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20237
diff changeset
297 be waited on. */
71f46b6a90e8 lib-fs: Added fs_switch_ioloop()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20237
diff changeset
298 bool fs_switch_ioloop(struct fs *fs) ATTR_NOWARN_UNUSED_RESULT;
15198
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
299
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
300 /* Returns 1 if file exists, 0 if not, -1 if error occurred. */
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
301 int fs_exists(struct fs_file *file);
16018
dc4be035a038 lib-fs: Fixed fs_delete() API description.
Timo Sirainen <tss@iki.fi>
parents: 15740
diff changeset
302 /* Delete a file. Returns 0 if file was actually deleted by us, -1 if error. */
15198
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
303 int fs_delete(struct fs_file *file);
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
304
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
305 /* Returns 0 if ok, -1 if error occurred (e.g. errno=ENOENT).
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
306 All fs backends may not support all stat fields. */
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
307 int fs_stat(struct fs_file *file, struct stat *st_r);
20548
5f6962a5be0f lib-fs: Added fs_get_nlinks()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20329
diff changeset
308 /* Get number of links to the file. This is the same as using fs_stat()'s
5f6962a5be0f lib-fs: Added fs_get_nlinks()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20329
diff changeset
309 st_nlinks field, except not all backends support returning it via fs_stat().
5f6962a5be0f lib-fs: Added fs_get_nlinks()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20329
diff changeset
310 Returns 0 if ok, -1 if error occurred. */
5f6962a5be0f lib-fs: Added fs_get_nlinks()
Timo Sirainen <timo.sirainen@dovecot.fi>
parents: 20329
diff changeset
311 int fs_get_nlinks(struct fs_file *file, nlink_t *nlinks_r);
15198
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
312 /* Copy an object with possibly updated metadata. Destination parent
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
313 directories are created automatically. Returns 0 if ok, -1 if error
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
314 occurred. */
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
315 int fs_copy(struct fs_file *src, struct fs_file *dest);
15445
8f0af55ee4b6 lib-fs: Comment update
Timo Sirainen <tss@iki.fi>
parents: 15400
diff changeset
316 /* Try to finish asynchronous fs_copy(). Returns the same as fs_copy(). */
15229
260b1ec12f41 lib-fs: Fixes to async APIs.
Timo Sirainen <tss@iki.fi>
parents: 15198
diff changeset
317 int fs_copy_finish_async(struct fs_file *dest);
15198
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
318 /* Atomically rename a file. Destination parent directories are created
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
319 automatically. Returns 0 if ok, -1 if error occurred. */
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
320 int fs_rename(struct fs_file *src, struct fs_file *dest);
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
321
12309
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
322 /* Exclusively lock a file. If file is already locked, wait for it for given
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
323 number of seconds (0 = fail immediately). Returns 1 if locked, 0 if wait
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
324 timed out, -1 if error. */
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
325 int fs_lock(struct fs_file *file, unsigned int secs, struct fs_lock **lock_r);
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
326 void fs_unlock(struct fs_lock **lock);
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
327
15652
6e5adbf30e35 lib-fs: Added flags to iteration, and FS_ITER_FLAG_DIRS as the first flag.
Timo Sirainen <tss@iki.fi>
parents: 15456
diff changeset
328 /* Iterate through all files or directories in the given directory.
15397
bd01ca99bee5 lib-fs: Iterating a nonexistent directory should be the same as iterating an empty directory.
Timo Sirainen <tss@iki.fi>
parents: 15396
diff changeset
329 Doesn't recurse to child directories. It's not an error to iterate a
bd01ca99bee5 lib-fs: Iterating a nonexistent directory should be the same as iterating an empty directory.
Timo Sirainen <tss@iki.fi>
parents: 15396
diff changeset
330 nonexistent directory. */
15652
6e5adbf30e35 lib-fs: Added flags to iteration, and FS_ITER_FLAG_DIRS as the first flag.
Timo Sirainen <tss@iki.fi>
parents: 15456
diff changeset
331 struct fs_iter *
6e5adbf30e35 lib-fs: Added flags to iteration, and FS_ITER_FLAG_DIRS as the first flag.
Timo Sirainen <tss@iki.fi>
parents: 15456
diff changeset
332 fs_iter_init(struct fs *fs, const char *path, enum fs_iter_flags flags);
15198
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
333 /* Returns 0 if ok, -1 if iteration failed. */
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
334 int fs_iter_deinit(struct fs_iter **iter);
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
335 /* Returns the next filename. */
ce57bacc3010 lib-fs API cleanups and improvements
Timo Sirainen <tss@iki.fi>
parents: 15085
diff changeset
336 const char *fs_iter_next(struct fs_iter *iter);
12309
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
337
16722
6ed90c968ab1 lib-fs: Added support for asynchronous fs iteration.
Timo Sirainen <tss@iki.fi>
parents: 16721
diff changeset
338 /* For asynchronous iterations: Specify the callback that is called whenever
6ed90c968ab1 lib-fs: Added support for asynchronous fs iteration.
Timo Sirainen <tss@iki.fi>
parents: 16721
diff changeset
339 there's more data available for reading. */
6ed90c968ab1 lib-fs: Added support for asynchronous fs iteration.
Timo Sirainen <tss@iki.fi>
parents: 16721
diff changeset
340 void fs_iter_set_async_callback(struct fs_iter *iter,
6ed90c968ab1 lib-fs: Added support for asynchronous fs iteration.
Timo Sirainen <tss@iki.fi>
parents: 16721
diff changeset
341 fs_file_async_callback_t *callback,
6ed90c968ab1 lib-fs: Added support for asynchronous fs iteration.
Timo Sirainen <tss@iki.fi>
parents: 16721
diff changeset
342 void *context);
6ed90c968ab1 lib-fs: Added support for asynchronous fs iteration.
Timo Sirainen <tss@iki.fi>
parents: 16721
diff changeset
343 /* For asynchronous iterations: If fs_iter_next() returns NULL, use this
6ed90c968ab1 lib-fs: Added support for asynchronous fs iteration.
Timo Sirainen <tss@iki.fi>
parents: 16721
diff changeset
344 function to determine if you should wait for more data or finish up. */
6ed90c968ab1 lib-fs: Added support for asynchronous fs iteration.
Timo Sirainen <tss@iki.fi>
parents: 16721
diff changeset
345 bool fs_iter_have_more(struct fs_iter *iter);
6ed90c968ab1 lib-fs: Added support for asynchronous fs iteration.
Timo Sirainen <tss@iki.fi>
parents: 16721
diff changeset
346
18290
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
347 /* Return the filesystem's fs_stats. Note that each wrapper filesystem keeps
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
348 track of its own fs_stats calls. You can use fs_get_parent() to get to the
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
349 filesystem whose stats you want to see. */
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
350 const struct fs_stats *fs_get_stats(struct fs *fs);
18721584583b lib-fs: Track how many different operations have been done on the fs.
Timo Sirainen <tss@iki.fi>
parents: 18289
diff changeset
351
19399
fac18fa49f2d lib-fs: Added fs_stats_get_read/write_usecs()
Timo Sirainen <tss@iki.fi>
parents: 19148
diff changeset
352 /* Helper functions to count number of usecs for read/write operations. */
fac18fa49f2d lib-fs: Added fs_stats_get_read/write_usecs()
Timo Sirainen <tss@iki.fi>
parents: 19148
diff changeset
353 uint64_t fs_stats_get_read_usecs(const struct fs_stats *stats);
fac18fa49f2d lib-fs: Added fs_stats_get_read/write_usecs()
Timo Sirainen <tss@iki.fi>
parents: 19148
diff changeset
354 uint64_t fs_stats_get_write_usecs(const struct fs_stats *stats);
fac18fa49f2d lib-fs: Added fs_stats_get_read/write_usecs()
Timo Sirainen <tss@iki.fi>
parents: 19148
diff changeset
355
12309
e3fe87b855ef Added lib-fs for simple filesystem accessing. Implemented POSIX, SiS and SiS-queue backends.
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
356 #endif