SFUSE_Documentation
로딩중...
검색중...
일치하는것 없음
main.c 파일 참조

SFUSE FUSE 파일 시스템 메인 엔트리 포인트 더 자세히 ...

#include "fs.h"
#include <errno.h>
#include <fuse3/fuse.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
main.c에 대한 include 의존 그래프

이 파일의 소스 코드 페이지로 가기

함수

struct fuse_operations * sfuse_get_operations (void)
 SFUSE FUSE 연산 테이블을 반환
int main (int argc, char *argv[])
 프로그램 진입점

변수

bool g_force_format = false
 VSFS 강제 포맷 옵션 플래그 외부 선언

상세한 설명

SFUSE FUSE 파일 시스템 메인 엔트리 포인트

이 파일은 SFUSE의 초기화, FUSE 인자 처리, FUSE 메인 루프 실행 및 정리 작업을 담당합니다.

main.c 파일에서 정의되었습니다.

함수 문서화

◆ main()

int main ( int argc,
char * argv[] )

프로그램 진입점

매개변수
argc명령행 인자 개수
argv명령행 인자 리스트
반환값
FUSE 메인 루프 반환값

사용법: s [-F] <device> <mountpoint> [FUSE options]

옵션: -F VSFS가 아닌 장치일 경우 강제 포맷

마운트할 블록 장치 파일 경로

마운트할 디렉토리 경로

< 프로그램 이름

< 마운트 포인트

< 추가 FUSE 옵션

FUSE 파싱된 인자 구조체

main.c 파일의 54 번째 라인에서 정의되었습니다.

54 {
55 int err = 0;
56 int idx = 1;
57
58 /* 옵션 처리: -F (강제 포맷) */
59 if (argc > 1 && strcmp(argv[1], "-F") == 0) {
60 g_force_format = true;
61 idx++;
62 }
63
64 /* 인수 체크: 블록 장치 경로, 마운트 포인트 필요 */
65 if (argc - idx < 2) {
66 fprintf(stderr, "Usage: %s [-F] <device> <mountpoint> [FUSE options]\n",
67 argv[0]);
68 return EXIT_FAILURE;
69 }
70
72 const char *device_path = argv[idx];
74 const char *mountpoint = argv[idx + 1];
75
76 /* SFUSE 초기화 */
77 struct sfuse_fs *fs = fs_initialize(device_path, &err);
78 if (!fs) {
79 if (err == EINVAL) {
80 fprintf(stderr,
81 "SFUSE: 해당 장치가 VSFS 형식이 아닙니다. "
82 "포맷하려면 -F 옵션을 사용하세요. (err=%d)\n",
83 err);
84 } else {
85 fprintf(stderr, "SFUSE: 파일시스템 초기화 실패 (err=%d)\n", err);
86 }
87 return EXIT_FAILURE;
88 }
89
90 /* 추가 FUSE 인자 계산 */
91 int remaining = argc - (idx + 2);
92 int fuse_argc = 2 + remaining;
93 char **fuse_argv = malloc(sizeof(char *) * fuse_argc);
94 if (!fuse_argv) {
95 perror("malloc");
96 fs_teardown(fs);
97 return EXIT_FAILURE;
98 }
99
100 int f = 0;
101 fuse_argv[f++] = strdup(argv[0]);
102 fuse_argv[f++] = strdup(mountpoint);
103 for (int i = 0; i < remaining; ++i) {
104 fuse_argv[f++] = strdup(argv[idx + 2 + i]);
105 }
106
108 struct fuse_args fuse_args = FUSE_ARGS_INIT(fuse_argc, fuse_argv);
109
110 /* FUSE 메인 루프 실행 */
111 int ret =
112 fuse_main(fuse_args.argc, fuse_args.argv, sfuse_get_operations(), fs);
113
114 /* 정리 작업: FS 해제 및 메모리 반환 */
115 fs_teardown(fs);
116 for (int i = 0; i < fuse_argc; ++i)
117 free(fuse_argv[i]);
118 free(fuse_argv);
119 fuse_opt_free_args(&fuse_args);
120
121 return ret;
122}
bool g_force_format
강제 포맷 옵션 플래그
Definition main.c:32
struct sfuse_fs * fs_initialize(const char *path, int *error_out)
파일 시스템 초기화
Definition fs.c:105
void fs_teardown(struct sfuse_fs *fs)
파일 시스템 정리
Definition fs.c:165
struct fuse_operations * sfuse_get_operations(void)
SFUSE용 FUSE operations 구조체 반환
Definition ops.c:232
SFUSE 파일 시스템 컨텍스트 구조체
Definition fs.h:21
이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

◆ sfuse_get_operations()

struct fuse_operations * sfuse_get_operations ( void )

SFUSE FUSE 연산 테이블을 반환

반환값
SFUSE에서 정의한 FUSE callbacks(struct fuse_operations)

SFUSE FUSE 연산 테이블을 반환

SFUSE용 FUSE operations 구조체 반환

생성된 콜백 함수들을 ops 구조체에 등록하여 반환한다.

반환값
설정된 fuse_operations 구조체 포인터

ops.c 파일의 232 번째 라인에서 정의되었습니다.

232 {
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}
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
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

변수 문서화

◆ g_force_format

bool g_force_format = false

VSFS 강제 포맷 옵션 플래그 외부 선언

전역: 포맷 강제 여부 (-F 옵션)

강제 포맷 옵션 플래그

이 플래그는 main.c에서 정의되며, FS 초기화 시 포맷을 강제할 때 사용됩니다.

< fs_initialize, fs_teardown, g_force_format extern

main.c에서 정의되며, fs_initialize에서 VSFS 포맷을 강제할 때 사용됩니다.

main.c 파일의 32 번째 라인에서 정의되었습니다.