terom@7: #ifndef DIRBUF_H terom@7: #define DIRBUF_H terom@7: terom@7: /* terom@7: * Simple dirent building terom@7: */ terom@7: terom@7: #include "evfuse.h" terom@7: terom@7: /* terom@7: * Holds the dir entries terom@7: */ terom@7: struct dirbuf { terom@7: char *buf; terom@7: size_t len; terom@7: size_t off; terom@7: }; terom@7: terom@26: // maximum length for a dirbuf name, including NUL byte terom@26: #define DIRBUF_NAME_MAX 256 terom@26: terom@26: /* terom@26: * Estimate how many dir entries will, at most, fit into a difbuf of the given size, based on a minimum filename size. terom@26: */ terom@26: size_t difbuf_estimate (size_t req_size, size_t min_namelen); terom@7: terom@7: /* terom@7: * Initialize a dirbuf for a request. The dirbuf will be filled with at most req_size bytes of dir entries. terom@7: */ terom@7: int dirbuf_init (struct dirbuf *buf, size_t req_size); terom@7: terom@7: /* terom@7: * Add an dir entry to the dirbuf. The dirbuf should not be full. terom@7: * terom@7: * Offsets are followed: terom@7: * req_off - the offset of the first dirent to include terom@7: * ent_off - the offset of this dirent terom@7: * next_off - the offset of the next dirent terom@7: * terom@7: * Only the S_IFMT bits of ent_mode are relevant. terom@7: * terom@7: * Returns 0 if the ent was added or skipped, -1 on error, 1 if the dirbuf is full (no more ents should be added). terom@7: */ terom@7: int dirbuf_add (fuse_req_t req, off_t req_off, struct dirbuf *buf, off_t ent_off, off_t next_off, const char *ent_name, fuse_ino_t ent_ino, mode_t ent_mode); terom@7: terom@7: /* terom@7: * Attempt to send the readdir reply, free the buf, and return the error code from fuse_reply_buf terom@7: */ terom@7: int dirbuf_done (fuse_req_t req, struct dirbuf *buf); terom@7: terom@7: #endif /* DIRBUF_H */