-
Notifications
You must be signed in to change notification settings - Fork 0
/
fs_util.c
43 lines (33 loc) · 1001 Bytes
/
fs_util.c
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
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <fuse.h>
#include <unistd.h>
#include "file_log.h"
#include "log.h"
/* Utils common to more than one FS such as reading
* from a file handle stored in f_info */
int file_info_read (struct fuse_file_info *f_info, char *buffer, size_t size, off_t offset)
{
/* This also works for the file search since we've opened the file */
log_fi(f_info);
return pread(f_info->fh, buffer, size, offset);
}
int file_info_write (struct fuse_file_info *f_info, const char *buf, size_t size, off_t offset)
{
log_fi(f_info);
return pwrite(f_info->fh, buf, size, offset);
}
int file_info_fsync (struct fuse_file_info *f_info, int datasync)
{
int retstat = 0;
log_fi(f_info);
if (datasync)
retstat = fdatasync(f_info->fh);
else
retstat = fsync(f_info->fh);
if (retstat < 0)
log_error("tagfs_fsync fsync");
return retstat;
}
int file_info_truncate (struct fuse_file_info *f_info, off_t size)
{
return ftruncate(f_info->fh, size);
}