]> mj.ucw.cz Git - eval.git/blob - lib/pagecache.h
Handle exit code translation failures gracefully.
[eval.git] / lib / pagecache.h
1 /*
2  *      UCW Library -- File Page Cache
3  *
4  *      (c) 1999--2002 Martin Mares <mj@ucw.cz>
5  *
6  *      This software may be freely distributed and used according to the terms
7  *      of the GNU Lesser General Public License.
8  */
9
10 #ifndef _UCW_PAGECACHE_H
11 #define _UCW_PAGECACHE_H
12
13 #include "lib/lists.h"
14
15 struct page_cache;
16
17 struct page {
18   node n;                               /* Node in page list */
19   node hn;                              /* Node in hash table */
20   sh_off_t pos;
21   uns fd;
22   uns flags;
23   uns lock_count;
24   byte data[0];
25 };
26
27 #define PG_FLAG_DIRTY           1
28 #define PG_FLAG_VALID           2
29
30 struct page_cache *pgc_open(uns page_size, uns max_pages);
31 void pgc_close(struct page_cache *);
32 void pgc_debug(struct page_cache *, int mode);
33 void pgc_flush(struct page_cache *);                            /* Write all unwritten pages */
34 void pgc_cleanup(struct page_cache *);                          /* Deallocate all unused buffers */
35 struct page *pgc_read(struct page_cache *, int fd, sh_off_t);   /* Read page and lock it */
36 struct page *pgc_get(struct page_cache *, int fd, sh_off_t);    /* Get page for writing */
37 struct page *pgc_get_zero(struct page_cache *, int fd, sh_off_t); /* ... and clear it */
38 void pgc_put(struct page_cache *, struct page *);               /* Release page */
39 void pgc_mark_dirty(struct page_cache *, struct page *);        /* Mark locked page as dirty */
40 byte *pgc_read_data(struct page_cache *, int fd, sh_off_t, uns *);      /* Partial reading */
41
42 #endif