StupidOS/kernel/fs/fat.inc

174 lines
2.8 KiB
PHP
Raw Normal View History

2024-07-13 17:02:35 +00:00
;; File: fat.inc
2024-07-16 06:29:16 +00:00
;;
2024-07-18 09:28:07 +00:00
;;
2024-07-16 06:29:16 +00:00
;; Usefull links:
2024-07-18 09:28:07 +00:00
;; - <Microsoft FAT Specification at https://academy.cba.mit.edu/classes/networking_communications/SD/FAT.pdf>
2024-07-14 20:39:48 +00:00
FAT_SECTOR_SIZE = 512
FAT_MDIR_SIZE = 32
2024-07-16 06:29:16 +00:00
struc FATFS_BootSectorBase {
.jump db 3 dup(?)
.oemName db 8 dup(?)
.byts_per_sec dw ?
.sec_per_clus db ?
.rsvd_sec_cnt dw ?
.num_fats db ?
.root_ent_cnt dw ?
.tot_sec16 dw ?
.media db ?
.fat_sz16 dw ?
.sec_per_trk dw ?
.num_heads dw ?
.hidd_sec dd ?
.tot_sec32 dd ?
2024-07-14 20:39:48 +00:00
}
2024-07-16 06:29:16 +00:00
struc FATFS_BootSector16 {
.base FATFS_BootSectorBase
;; Extended BPB Structure
.drv_num db ?
.reserved1 db 0
.boot_sig db ?
.volume_id dd ?
.volume_label db 11 dup(?)
.filsys_type db 8 dup(?)
.code db 448 dup(?)
.signature dw ?
}
2024-07-17 07:41:36 +00:00
DEFN FATFS_BootSector16
2024-07-16 06:29:16 +00:00
struc FATFS_BootSector32 {
.base FATFS_BootSectorBase
.fat_sz32 dd ?
.ext_flags dw ?
.fs_ver dw ?
.root_clus dd ?
.fs_info dw ?
.bk_boot_sec dw ?
.reserved0 db 12 dup(?)
.drv_num db ?
.reserved1 db ?
.boot_sig db ?
.volume_id dd ?
.volume_label db 11 dup(?)
.filsys_type db 8 dup(?)
.code db 420 dup(?)
.signature dw ?
}
2024-07-17 07:41:36 +00:00
DEFN FATFS_BootSector32
2024-07-16 06:29:16 +00:00
2024-07-19 07:53:03 +00:00
;; Struc: FATFS_Dirent
;; FAT Filesystem directory entry
;;
;; .name - Filename
;; .ext - File extension
;; .attr - See <FATFS file attributes>
2024-07-18 09:28:07 +00:00
struc FATFS_Dirent {
.name db 8 dup(?)
.ext db 3 dup(?)
.attr db ?
.reserved db 0
.crt_time_tenth db ?
.crt_time dw ?
.crt_date dw ?
.lst_acc_date dw ?
.fst_clus_hi dw ?
.wrt_time dw ?
.wrt_date dw ?
.fst_clus_lo dw ?
.file_size dd ?
}
DEFN FATFS_Dirent
2024-07-19 07:53:03 +00:00
;; Enum: FATFS file attributes
;;
;; FATFS_ATTR_READ_ONLY - Mark file as read-only
;; FATFS_ATTR_HIDDEN - TODO
;; FATFS_ATTR_SYSTEM - TODO
;; FATFS_ATTR_VOLUME_ID - The corresponding entry contains the volume label.
;; FATFS_ATTR_DIRECTORY - The corresponding entry represents a directory
;; FATFS_ATTR_ARCHIVE - TODO
FATFS_ATTR_READ_ONLY = 0x01
FATFS_ATTR_HIDDEN = 0x02
FATFS_ATTR_SYSTEM = 0x04
FATFS_ATTR_VOLUME_ID = 0x08
FATFS_ATTR_DIRECTORY = 0x10
FATFS_ATTR_ARCHIVE = 0x20
2024-07-18 09:28:07 +00:00
; ------------------------------------------------------------------------
;; Section: Implementation
2024-07-16 06:29:16 +00:00
szVfsFatName db 'FATFS', 0
vfs_fatfs:
dd szVfsFatName
dd 0
dd vops_fatfs
vops_fatfs:
dd 0
fatfs_init:
mov eax, vfs_fatfs
call vfs_register
ret
2024-07-16 07:52:08 +00:00
fatfs_mount:
ret
fatfs_start:
ret
fatfs_unmount:
ret
fatfs_root:
ret
fatfs_statvfs:
ret
fatfs_loadvnode:
ret
fatfs_newvnode:
ret
fatfs_mountroot:
ret
2024-07-17 07:41:36 +00:00
;; vnode ops
fatfs_open:
ret
fatfs_close:
ret
fatfs_rdwr:
ret
fatfs_ioctl:
ret
fatfs_select:
ret
fatfs_getattr:
ret
fatfs_setattr:
ret
fatfs_access:
ret
fatfs_lookup:
ret
fatfs_create:
ret