author | Tero Marttila <terom@fixme.fi> |
Sat, 13 Dec 2008 19:55:50 +0200 | |
branch | new-evsql |
changeset 53 | 0d6e07f4c9a1 |
parent 27 | 461be4cd34a3 |
permissions | -rw-r--r-- |
7
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
1 |
#ifndef DIRBUF_H |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
2 |
#define DIRBUF_H |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
3 |
|
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
4 |
/* |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
5 |
* Simple dirent building |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
6 |
*/ |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
7 |
|
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
8 |
#include "evfuse.h" |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
9 |
|
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
10 |
/* |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
11 |
* Holds the dir entries |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
12 |
*/ |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
13 |
struct dirbuf { |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
14 |
char *buf; |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
15 |
size_t len; |
27 | 16 |
off_t off, req_off; |
7
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
17 |
}; |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
18 |
|
26
61668c57f4bb
preliminary *dir implementation
Tero Marttila <terom@fixme.fi>
parents:
7
diff
changeset
|
19 |
// maximum length for a dirbuf name, including NUL byte |
61668c57f4bb
preliminary *dir implementation
Tero Marttila <terom@fixme.fi>
parents:
7
diff
changeset
|
20 |
#define DIRBUF_NAME_MAX 256 |
61668c57f4bb
preliminary *dir implementation
Tero Marttila <terom@fixme.fi>
parents:
7
diff
changeset
|
21 |
|
61668c57f4bb
preliminary *dir implementation
Tero Marttila <terom@fixme.fi>
parents:
7
diff
changeset
|
22 |
/* |
27 | 23 |
* Initialize a dirbuf for a request. The dirbuf will be filled with at most req_size bytes of dir entries. |
24 |
* |
|
25 |
* req_size - how many bytes of dirbuf data we want, at most |
|
26 |
* req_off - the offset of the first dirent to include |
|
27 |
*/ |
|
28 |
int dirbuf_init (struct dirbuf *buf, size_t req_size, off_t req_off); |
|
29 |
||
30 |
/* |
|
26
61668c57f4bb
preliminary *dir implementation
Tero Marttila <terom@fixme.fi>
parents:
7
diff
changeset
|
31 |
* Estimate how many dir entries will, at most, fit into a difbuf of the given size, based on a minimum filename size. |
61668c57f4bb
preliminary *dir implementation
Tero Marttila <terom@fixme.fi>
parents:
7
diff
changeset
|
32 |
*/ |
27 | 33 |
size_t dirbuf_estimate (struct dirbuf *buf, size_t min_namelen); |
7
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
34 |
|
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
35 |
/* |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
36 |
* Add an dir entry to the dirbuf. The dirbuf should not be full. |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
37 |
* |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
38 |
* Offsets are followed: |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
39 |
* ent_off - the offset of this dirent |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
40 |
* next_off - the offset of the next dirent |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
41 |
* |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
42 |
* Only the S_IFMT bits of ent_mode are relevant. |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
43 |
* |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
44 |
* Returns 0 if the ent was added or skipped, -1 on error, 1 if the dirbuf is full (no more ents should be added). |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
45 |
*/ |
27 | 46 |
int dirbuf_add (fuse_req_t req, struct dirbuf *buf, off_t ent_off, off_t next_off, const char *ent_name, fuse_ino_t ent_ino, mode_t ent_mode); |
7
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
47 |
|
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
48 |
/* |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
49 |
* Attempt to send the readdir reply, free the buf, and return the error code from fuse_reply_buf |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
50 |
*/ |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
51 |
int dirbuf_done (fuse_req_t req, struct dirbuf *buf); |
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
52 |
|
27 | 53 |
/* |
54 |
* Release the dirop without sending any reply back. |
|
55 |
* |
|
56 |
* This is safe to be called multiple times. |
|
57 |
*/ |
|
58 |
void dirbuf_release (struct dirbuf *buf); |
|
59 |
||
7
3a603d755bcb
split off the dirbuf stuff into its own module
Tero Marttila <terom@fixme.fi>
parents:
diff
changeset
|
60 |
#endif /* DIRBUF_H */ |