forked from dayne/zunkfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
file.h
31 lines (23 loc) · 799 Bytes
/
file.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef __ZUNKFS_FILE_H__
#define __ZUNKFS_FILE_H__
#include "zunkfs.h"
struct dentry;
struct chunk_node;
#define MIN_FILE_CHUNK_CACHE_SIZE 16
#if CHUNK_SIZE > 4096
#define FILE_CHUNK_CACHE_SIZE (MIN_FILE_CHUNK_CACHE_SIZE * CHUNK_SIZE / 4096)
#else
#define FILE_CHUNK_CACHE_SIZE MIN_FILE_CHUNK_CACHE_SIZE
#endif
struct open_file {
struct dentry *dentry;
struct chunk_node *ccache[FILE_CHUNK_CACHE_SIZE];
unsigned ccache_index;
};
struct open_file *open_file(const char *path);
struct open_file *create_file(const char *path, mode_t mode);
int close_file(struct open_file *ofile);
int flush_file(struct open_file *ofile);
int read_file(struct open_file *ofile, char *buf, size_t bufsz, off_t offset);
int write_file(struct open_file *ofile, const char *buf, size_t len, off_t off);
#endif