-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisk_params.py
More file actions
39 lines (29 loc) · 1.09 KB
/
Copy pathdisk_params.py
File metadata and controls
39 lines (29 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import constants as C
## 以下是需要计算得出的参数
## 初始为默认值
# 硬盘的参数(用于格式化硬盘)
DISK_START = 0
INODE_BLOCKS = 4096
DISK_BLOCKS = 65536
# 总字节数
TOTAL_BYTES = DISK_BLOCKS * C.BLOCK_BYTES
# 超级块
SUPERBLOCK_START = DISK_START
# Inode
INODE_START = SUPERBLOCK_START + C.SUPERBLOCK_BLOCKS
INODE_COUNT = INODE_BLOCKS * C.INODE_PER_BLOCK
# 数据区
DATA_START = INODE_START + INODE_BLOCKS
DATA_BLOCK_COUNT = DISK_BLOCKS - DATA_START
def init_constants(disk_start: int = 0, inode_blocks: int = 4096, disk_blocks: int = 65536) -> None:
global DISK_START, INODE_BLOCKS, DISK_BLOCKS
DISK_START = disk_start
INODE_BLOCKS = inode_blocks
DISK_BLOCKS = disk_blocks
global TOTAL_BYTES, SUPERBLOCK_START, INODE_START, INODE_COUNT, DATA_START, DATA_BLOCK_COUNT
TOTAL_BYTES = DISK_BLOCKS * C.BLOCK_BYTES
SUPERBLOCK_START = DISK_START
INODE_START = SUPERBLOCK_START + C.SUPERBLOCK_BLOCKS
INODE_COUNT = INODE_BLOCKS * C.INODE_PER_BLOCK
DATA_START = INODE_START + INODE_BLOCKS
DATA_BLOCK_COUNT = DISK_BLOCKS - DATA_START