StupidOS/kernel/fs/xv6fs.inc

100 lines
2.4 KiB
PHP
Raw Normal View History

2024-07-16 06:29:16 +00:00
;; File: xv6fs.inc
;;
2024-07-20 06:59:37 +00:00
;; Usefull links:
;; - <https://github.com/mit-pdos/xv6-riscv/blob/riscv/kernel/fs.h>
;; - <xv6 book at https://pdos.csail.mit.edu/6.1810/2023/xv6/book-riscv-rev3.pdf>
;;
;; Section: xv6 Filesystem
;;
2024-07-18 09:28:07 +00:00
;; > ┌──────────┬───────────┬───┬───┬───┬──────┬───┬──────┬──────┬───┬──────┬────┬───┬────┐
;; > │Boot block│Super block│Log│...│Log│Inodes│...│Inodes│Bitmap│...│Bitmap│Data│...│Data│
;; > └──────────┴───────────┴───┴───┴───┴──────┴───┴──────┴──────┴───┴──────┴────┴───┴────┘
;;
2024-07-16 06:29:16 +00:00
2024-07-18 09:28:07 +00:00
;; Constant: XV6FS_BSIZE
;; xv6 Filesystem block size (1024)
2024-07-16 06:29:16 +00:00
XV6FS_BSIZE = 1024
2024-07-20 06:59:37 +00:00
;; Constant: XV6FS_ROOTINO
;; root inode number
2024-07-16 06:29:16 +00:00
XV6FS_ROOTINO = 1
2024-07-20 06:59:37 +00:00
;; Constant: XV6FS_MAGIC
;; Superblock magic number, MUST BE `0x10203040`
2024-07-16 06:29:16 +00:00
XV6FS_MAGIC = 0x10203040
2024-07-20 06:59:37 +00:00
;; Constant: XV6FS_NDIRECT
;; Number of direct block (12)
2024-07-16 06:29:16 +00:00
XV6FS_NDIRECT = 12
XV6FS_NINDIRECT = (XV6FS_BSIZE / 4)
XV6FS_MAXFILE = (XV6FS_NDIRECT + XV6FS_NINDIRECT)
XV6FS_IPB = (XV6FS_BSIZE / 64)
XV6FS_DIRSIZE = 14
2024-07-18 09:28:07 +00:00
;; Struc: Xv6FS_Sb
2024-07-20 06:59:37 +00:00
;; xv6FS superblock
;;
;; .magic - See <XV6FS_MAGIC>
;; .size - TODO
;; .nblock - TODO
;; .ninodes - TODO
;; .nlog - TODO
;; .nlogstart - TODO
;; .inodestart - TODO
;; .bmapstart - TODO
2024-07-16 06:29:16 +00:00
struc Xv6FS_Sb {
.magic dd ?
.size dd ?
.nblock dd ?
.ninodes dd ?
.nlog dd ?
.nlogstart dd ?
.inodestart dd ?
.bmapstart dd ?
}
DEFN Xv6FS_Sb
2024-07-18 09:28:07 +00:00
;; Struc: Xv6FS_Inode
2024-07-20 06:59:37 +00:00
;; xv6FS on disk i-node
;;
;; .type - TODO
;; .major - TODO
;; .minor - TODO
;; .nlink - TODO
;; .size - TODO
;; .addrs - TODO
2024-07-16 06:29:16 +00:00
struc Xv6FS_Inode {
.type dw ?
.major dw ?
.minor dw ?
.nlink dw ?
.size dd ?
.addrs dd (XV6FS_NDIRECT + 1) dup(?)
}
DEFN Xv6FS_Inode
2024-07-18 09:28:07 +00:00
;; Struc: Xv6FS_Dirent
2024-07-20 06:59:37 +00:00
;; xv6FS directory entry
2024-07-16 06:29:16 +00:00
struc Xv6FS_Dirent {
.inum dw ?
.name db XV6FS_DIRSIZE dup(?)
}
2024-07-18 09:28:07 +00:00
; ------------------------------------------------------------------------
;; Section: Implementation
2024-07-16 06:29:16 +00:00
szVfsXv6FSName db 'xv6FS', 0
vops_xv6fs:
dd 0
vfs_xv6fs:
dd szVfsXv6FSName
dd 0
dd vops_xv6fs
xv6fs_init:
mov eax, vfs_xv6fs
call vfs_register
ret