SFUSE_Documentation
로딩중...
검색중...
일치하는것 없음
dir.h 파일 참조
#include "fs.h"
#include <fuse3/fuse.h>
#include <stdint.h>
dir.h에 대한 include 의존 그래프
이 그래프는 이 파일을 직/간접적으로 include 하는 파일들을 보여줍니다.:

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

데이터 구조

struct  sfuse_dirent
 디스크에 저장되는 디렉터리 엔트리 구조체 더 자세히 ...

매크로

#define SFUSE_NAME_MAX   256
#define DENTS_PER_BLOCK   (SFUSE_BLOCK_SIZE / sizeof(struct sfuse_dirent))
 한 블록당 디렉터리 엔트리 수

함수

int dir_lookup (const struct sfuse_fs *fs, uint32_t dir_ino, const char *name, uint32_t *out_ino)
 디렉터리에서 이름으로 inode 번호를 검색
int dir_list (const struct sfuse_fs *fs, uint32_t dir_ino, void *buf, fuse_fill_dir_t filler, off_t offset)
 FUSE용 디렉터리 목록 채우기 콜백 호출

매크로 문서화

◆ DENTS_PER_BLOCK

#define DENTS_PER_BLOCK   (SFUSE_BLOCK_SIZE / sizeof(struct sfuse_dirent))

한 블록당 디렉터리 엔트리 수

dir.h 파일의 14 번째 라인에서 정의되었습니다.

◆ SFUSE_NAME_MAX

#define SFUSE_NAME_MAX   256

파일/디렉터리 이름의 최대 길이

dir.h 파일의 10 번째 라인에서 정의되었습니다.

함수 문서화

◆ dir_list()

int dir_list ( const struct sfuse_fs * fs,
uint32_t dir_ino,
void * buf,
fuse_fill_dir_t filler,
off_t offset )

FUSE용 디렉터리 목록 채우기 콜백 호출

매개변수
fsSFUSE 파일시스템 컨텍스트
dir_ino디렉터리의 inode 번호
bufFUSE가 전달하는 버퍼 포인터
fillerFUSE의 디렉터리 엔트리 추가 함수
offset디렉터리 읽기 오프셋
반환값
성공 시 0, 실패 시 음수 오류 코드

FUSE용 디렉터리 목록 채우기 콜백 호출

매개변수
fsSFUSE 파일 시스템 컨텍스트
dir_ino목록을 읽을 디렉터리의 inode 번호
bufFUSE가 제공하는 버퍼 포인터
fillerFUSE의 디렉터리 엔트리 추가 콜백
offset읽기 시작 오프셋 (사용되지 않음)
반환값
성공 시 0, 실패 시 -ENOENT 또는 -EIO

< 더 이상 블록이 없으면 종료

< 블록 데이터를 읽어올 버퍼

< 빈 엔트리 건너뜀

< 이름이 비어있으면 건너뜀

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

59 {
60 struct sfuse_inode dir_inode;
61 if (inode_load(fs->backing_fd, &fs->sb, dir_ino, &dir_inode) < 0) {
62 return -ENOENT;
63 }
64
65 /* "." 및 ".." 기본 엔트리 추가 */
66 filler(buf, ".", NULL, 0, 0);
67 filler(buf, "..", NULL, 0, 0);
68
69 /* 저장된 디렉터리 엔트리 나열 */
70 for (uint32_t i = 0; i < 12; i++) {
71 uint32_t blk = dir_inode.direct[i];
72 if (blk == 0)
73 break;
74
75 uint8_t block[SFUSE_BLOCK_SIZE];
76 if (read_block(fs->backing_fd, blk, block) < 0) {
77 return -EIO;
78 }
79
80 struct sfuse_dirent *entries = (struct sfuse_dirent *)block;
81 for (uint32_t j = 0; j < DENTS_PER_BLOCK; ++j) {
82 if (entries[j].inode == 0)
83 continue;
84 if (entries[j].name[0] == '\0')
85 continue;
86 filler(buf, entries[j].name, NULL, 0, 0);
87 }
88 }
89 return 0;
90}
ssize_t read_block(int fd, uint32_t blk, void *out_buf)
지정한 블록 번호의 데이터를 읽어 버퍼에 저장
Definition block.c:15
#define DENTS_PER_BLOCK
한 블록당 디렉터리 엔트리 수
Definition dir.h:14
int inode_load(int fd, const struct sfuse_superblock *sb, uint32_t ino, struct sfuse_inode *out)
디스크 이미지에서 아이노드를 읽어 구조체에 로드
Definition inode.c:32
디스크에 저장되는 디렉터리 엔트리 구조체
Definition dir.h:19
uint32_t inode
Definition dir.h:20
char name[256]
Definition dir.h:21
struct sfuse_superblock sb
Definition fs.h:23
int backing_fd
Definition fs.h:22
디스크에 저장되는 아이노드 구조체
Definition inode.h:22
#define SFUSE_BLOCK_SIZE
블록 크기 (바이트 단위)
Definition super.h:20
이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ dir_lookup()

int dir_lookup ( const struct sfuse_fs * fs,
uint32_t dir_ino,
const char * name,
uint32_t * out_ino )

디렉터리에서 이름으로 inode 번호를 검색

매개변수
fsSFUSE 파일시스템 컨텍스트
dir_ino디렉터리의 inode 번호
name찾을 파일/디렉터리 이름 (null-terminated)
out_ino검색된 inode 번호 저장 위치
반환값
성공 시 0, 실패 시 음수 오류 코드

디렉터리에서 이름으로 inode 번호를 검색

매개변수
fsSFUSE 파일 시스템 컨텍스트
dir_ino검색 대상 디렉터리의 inode 번호
name찾을 파일/디렉터리 이름 (null-terminated)
out_ino검색된 inode 번호를 저장할 포인터
반환값
성공 시 0, 실패 시 -ENOENT 또는 -EIO

< 할당된 블록이 없으면 건너뜀

< 블록 데이터를 읽어올 버퍼

< 빈 엔트리 건너뜀

< 파일/디렉터리 이름의 최대 길이

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

19 {
20 struct sfuse_inode dir_inode;
21 if (inode_load(fs->backing_fd, &fs->sb, dir_ino, &dir_inode) < 0) {
22 return -ENOENT;
23 }
24
25 /* 모든 direct 블록 순회 */
26 for (uint32_t i = 0; i < 12; i++) {
27 uint32_t blk = dir_inode.direct[i];
28 if (blk == 0)
29 continue;
30
31 uint8_t block[SFUSE_BLOCK_SIZE];
32 if (read_block(fs->backing_fd, blk, block) < 0) {
33 return -EIO;
34 }
35
36 struct sfuse_dirent *entries = (struct sfuse_dirent *)block;
37 for (uint32_t j = 0; j < DENTS_PER_BLOCK; ++j) {
38 if (entries[j].inode == 0)
39 continue;
40 if (strncmp(entries[j].name, name, SFUSE_NAME_MAX) == 0) {
41 *out_ino = entries[j].inode;
42 return 0;
43 }
44 }
45 }
46 return -ENOENT;
47}
#define SFUSE_NAME_MAX
Definition dir.h:10
이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.: