SFUSE_Documentation
로딩중...
검색중...
일치하는것 없음
inode.c
이 파일의 문서화 페이지로 가기
1// File: src/inode.c
2
3#include "inode.h"
4#include <errno.h>
5#include <unistd.h>
6
14static off_t inode_offset(const struct sfuse_superblock *sb, uint32_t ino) {
15 uint32_t inode_index = ino;
16 off_t block_index =
17 sb->inode_table_start + inode_index / SFUSE_INODES_PER_BLOCK;
18 off_t offset_within_block =
19 (inode_index % SFUSE_INODES_PER_BLOCK) * sizeof(struct sfuse_inode);
20 return block_index * SFUSE_BLOCK_SIZE + offset_within_block;
21}
22
32int inode_load(int fd, const struct sfuse_superblock *sb, uint32_t ino,
33 struct sfuse_inode *out) {
34 off_t offs = inode_offset(sb, ino);
35 ssize_t n = pread(fd, out, sizeof(struct sfuse_inode), offs);
36 if (n < 0) {
37 return -errno;
38 }
39 return (n == sizeof(struct sfuse_inode) ? 0 : -EIO);
40}
41
51int inode_sync(int fd, const struct sfuse_superblock *sb, uint32_t ino,
52 const struct sfuse_inode *in) {
53 off_t offs = inode_offset(sb, ino);
54 ssize_t n = pwrite(fd, in, sizeof(struct sfuse_inode), offs);
55 if (n < 0) {
56 return -errno;
57 }
58 return (n == sizeof(struct sfuse_inode) ? 0 : -EIO);
59}
int inode_load(int fd, const struct sfuse_superblock *sb, uint32_t ino, struct sfuse_inode *out)
디스크에서 지정한 아이노드 번호의 아이노드 구조체를 읽어 옴
Definition inode.c:32
int inode_sync(int fd, const struct sfuse_superblock *sb, uint32_t ino, const struct sfuse_inode *in)
아이노드 구조체를 디스크에 동기화(쓰기)함
Definition inode.c:51
static off_t inode_offset(const struct sfuse_superblock *sb, uint32_t ino)
아이노드 테이블 내 특정 아이노드의 디스크 내 바이트 오프셋을 계산
Definition inode.c:14
#define SFUSE_INODES_PER_BLOCK
한 블록에 담을 수 있는 아이노드 수
Definition inode.h:12
디스크에 저장되는 아이노드 구조체
Definition inode.h:22
슈퍼블록 구조체
Definition super.h:51
uint32_t inode_table_start
Definition super.h:59
#define SFUSE_BLOCK_SIZE
블록 크기 (바이트 단위)
Definition super.h:20