SFUSE_Documentation
로딩중...
검색중...
일치하는것 없음
ops.c
이 파일의 문서화 페이지로 가기
1// File: src/ops.c
2
3#include "fs.h"
4#include <dirent.h>
5#include <errno.h>
6#include <fuse3/fuse.h>
7#include <stdio.h>
8#include <string.h>
9#include <sys/stat.h>
10#include <sys/types.h>
11#include <unistd.h>
12
21static int sfuse_getattr_cb(const char *path, struct stat *stbuf,
22 struct fuse_file_info *fi) {
23 (void)fi;
24 struct sfuse_fs *fs = (struct sfuse_fs *)fuse_get_context()->private_data;
25 return fs_getattr(fs, path, stbuf);
26}
27
35static int sfuse_access_cb(const char *path, int mask) {
36 struct sfuse_fs *fs = fuse_get_context()->private_data;
37 return fs_access(fs, path, mask);
38}
39
51static int sfuse_readdir_cb(const char *path, void *buf, fuse_fill_dir_t filler,
52 off_t offset, struct fuse_file_info *fi,
53 enum fuse_readdir_flags flags) {
54 (void)fi;
55 (void)flags;
56 struct sfuse_fs *fs = (struct sfuse_fs *)fuse_get_context()->private_data;
57 return fs_readdir(fs, path, buf, filler, offset);
58}
59
67static int sfuse_open_cb(const char *path, struct fuse_file_info *fi) {
68 struct sfuse_fs *fs = (struct sfuse_fs *)fuse_get_context()->private_data;
69 return fs_open(fs, path, fi);
70}
71
82static int sfuse_read_cb(const char *path, char *buf, size_t size, off_t offset,
83 struct fuse_file_info *fi) {
84 struct sfuse_fs *fs = (struct sfuse_fs *)fuse_get_context()->private_data;
85 return fs_read(fs, path, buf, size, offset);
86}
87
98static int sfuse_write_cb(const char *path, const char *buf, size_t size,
99 off_t offset, struct fuse_file_info *fi) {
100 struct sfuse_fs *fs = (struct sfuse_fs *)fuse_get_context()->private_data;
101 return fs_write(fs, path, buf, size, offset);
102}
103
112static int sfuse_create_cb(const char *path, mode_t mode,
113 struct fuse_file_info *fi) {
114 struct sfuse_fs *fs = (struct sfuse_fs *)fuse_get_context()->private_data;
115 return fs_create(fs, path, mode, fi);
116}
117
125static int sfuse_mkdir_cb(const char *path, mode_t mode) {
126 struct sfuse_fs *fs = (struct sfuse_fs *)fuse_get_context()->private_data;
127 return fs_mkdir(fs, path, mode);
128}
129
136static int sfuse_unlink_cb(const char *path) {
137 struct sfuse_fs *fs = (struct sfuse_fs *)fuse_get_context()->private_data;
138 return fs_unlink(fs, path);
139}
140
147static int sfuse_rmdir_cb(const char *path) {
148 struct sfuse_fs *fs = (struct sfuse_fs *)fuse_get_context()->private_data;
149 return fs_rmdir(fs, path);
150}
151
160static int sfuse_rename_cb(const char *from, const char *to,
161 unsigned int flags) {
162 (void)flags;
163 struct sfuse_fs *fs = (struct sfuse_fs *)fuse_get_context()->private_data;
164 return fs_rename(fs, from, to);
165}
166
175static int sfuse_truncate_cb(const char *path, off_t size,
176 struct fuse_file_info *fi) {
177 (void)fi;
178 struct sfuse_fs *fs = (struct sfuse_fs *)fuse_get_context()->private_data;
179 return fs_truncate(fs, path, size);
180}
181
190static int sfuse_utimens_cb(const char *path, const struct timespec tv[2],
191 struct fuse_file_info *fi) {
192 (void)fi;
193 struct sfuse_fs *fs = (struct sfuse_fs *)fuse_get_context()->private_data;
194 return fs_utimens(fs, path, tv);
195}
196
204static int sfuse_flush_cb(const char *path, struct fuse_file_info *fi) {
205 (void)path;
206 struct sfuse_fs *fs = (struct sfuse_fs *)fuse_get_context()->private_data;
207 return fs_flush(fs, path, fi);
208}
209
218static int sfuse_fsync_cb(const char *path, int datasync,
219 struct fuse_file_info *fi) {
220 (void)path;
221 struct sfuse_fs *fs = (struct sfuse_fs *)fuse_get_context()->private_data;
222 return fs_fsync(fs, path, datasync, fi);
223}
224
232struct fuse_operations *sfuse_get_operations(void) {
233 static struct fuse_operations ops;
234 memset(&ops, 0, sizeof(ops));
235 ops.getattr = sfuse_getattr_cb;
236 ops.access = sfuse_access_cb;
237 ops.readdir = sfuse_readdir_cb;
238 ops.open = sfuse_open_cb;
239 ops.read = sfuse_read_cb;
240 ops.write = sfuse_write_cb;
241 ops.create = sfuse_create_cb;
242 ops.mkdir = sfuse_mkdir_cb;
243 ops.unlink = sfuse_unlink_cb;
244 ops.rmdir = sfuse_rmdir_cb;
245 ops.rename = sfuse_rename_cb;
246 ops.truncate = sfuse_truncate_cb;
247 ops.flush = sfuse_flush_cb;
248 ops.fsync = sfuse_fsync_cb;
249 ops.utimens = sfuse_utimens_cb;
250 return &ops;
251}
int fs_getattr(struct sfuse_fs *fs, const char *path, struct stat *stbuf)
파일/디렉터리 속성 조회
Definition fs.c:237
int fs_mkdir(struct sfuse_fs *fs, const char *path, mode_t mode)
디렉터리 생성
Definition fs.c:702
int fs_read(struct sfuse_fs *fs, const char *path, char *buf, size_t size, off_t offset)
파일 읽기
Definition fs.c:310
int fs_create(struct sfuse_fs *fs, const char *path, mode_t mode, struct fuse_file_info *fi)
파일 생성
Definition fs.c:570
int fs_truncate(struct sfuse_fs *fs, const char *path, off_t size)
파일 크기 조정 (truncate)
Definition fs.c:1138
int fs_utimens(struct sfuse_fs *fs, const char *path, const struct timespec tv[2])
파일의 시간 속성 변경 (utimens)
Definition fs.c:1318
int fs_rmdir(struct sfuse_fs *fs, const char *path)
디렉터리 삭제
Definition fs.c:963
int fs_open(struct sfuse_fs *fs, const char *path, struct fuse_file_info *fi)
파일 열기
Definition fs.c:290
int fs_fsync(struct sfuse_fs *fs, const char *path, int datasync, struct fuse_file_info *fi)
FUSE에서 fsync 요청 처리
Definition fs.c:1280
int fs_unlink(struct sfuse_fs *fs, const char *path)
파일 삭제
Definition fs.c:829
int fs_readdir(struct sfuse_fs *fs, const char *path, void *buf, fuse_fill_dir_t filler, off_t offset)
디렉터리 내용 읽기
Definition fs.c:272
int fs_access(struct sfuse_fs *fs, const char *path, int mask)
접근 권한 검사
Definition fs.c:1343
int fs_write(struct sfuse_fs *fs, const char *path, const char *buf, size_t size, off_t offset)
파일 쓰기
Definition fs.c:407
int fs_rename(struct sfuse_fs *fs, const char *from, const char *to)
파일 또는 디렉터리 이름 변경
Definition fs.c:1011
int fs_flush(struct sfuse_fs *fs, const char *path, struct fuse_file_info *fi)
FUSE에서 플러시 요청 처리
Definition fs.c:1302
static int sfuse_truncate_cb(const char *path, off_t size, struct fuse_file_info *fi)
파일 크기 변경 콜백
Definition ops.c:175
static int sfuse_fsync_cb(const char *path, int datasync, struct fuse_file_info *fi)
fsync 콜백
Definition ops.c:218
static int sfuse_read_cb(const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi)
파일 읽기 콜백
Definition ops.c:82
static int sfuse_open_cb(const char *path, struct fuse_file_info *fi)
파일 열기 콜백
Definition ops.c:67
static int sfuse_rename_cb(const char *from, const char *to, unsigned int flags)
이름 변경 콜백
Definition ops.c:160
static int sfuse_getattr_cb(const char *path, struct stat *stbuf, struct fuse_file_info *fi)
파일/디렉터리 속성 조회 콜백
Definition ops.c:21
static int sfuse_create_cb(const char *path, mode_t mode, struct fuse_file_info *fi)
파일 생성 콜백
Definition ops.c:112
static int sfuse_utimens_cb(const char *path, const struct timespec tv[2], struct fuse_file_info *fi)
파일/디렉터리 타임스탬프 갱신 콜백
Definition ops.c:190
struct fuse_operations * sfuse_get_operations(void)
FUSE operations 테이블 반환
Definition ops.c:232
static int sfuse_unlink_cb(const char *path)
파일 삭제 콜백
Definition ops.c:136
static int sfuse_write_cb(const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi)
파일 쓰기 콜백
Definition ops.c:98
static int sfuse_mkdir_cb(const char *path, mode_t mode)
디렉터리 생성 콜백
Definition ops.c:125
static int sfuse_readdir_cb(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi, enum fuse_readdir_flags flags)
디렉터리 목록 조회 콜백
Definition ops.c:51
static int sfuse_access_cb(const char *path, int mask)
access 콜백
Definition ops.c:35
static int sfuse_rmdir_cb(const char *path)
디렉터리 삭제 콜백
Definition ops.c:147
static int sfuse_flush_cb(const char *path, struct fuse_file_info *fi)
flush 콜백
Definition ops.c:204
SFUSE 파일 시스템 컨텍스트 구조체
Definition fs.h:21