affs_read/constants.rs
1//! Constants for AFFS filesystem.
2
3/// Logical block size in bytes.
4pub const BLOCK_SIZE: usize = 512;
5
6/// Boot block size (2 blocks).
7pub const BOOT_BLOCK_SIZE: usize = 1024;
8
9/// Hash table size (entries per directory).
10pub const HASH_TABLE_SIZE: usize = 72;
11
12/// Maximum data block pointers per file header or extension block.
13pub const MAX_DATABLK: usize = 72;
14
15/// Maximum filename length.
16pub const MAX_NAME_LEN: usize = 30;
17
18/// Maximum comment length.
19pub const MAX_COMMENT_LEN: usize = 79;
20
21/// Bitmap pages in root block.
22pub const BM_PAGES_ROOT_SIZE: usize = 25;
23
24/// Bitmap pages in extension block.
25pub const BM_PAGES_EXT_SIZE: usize = 127;
26
27/// Bitmap map entries.
28pub const BM_MAP_SIZE: usize = 127;
29
30/// Standard floppy disk sector count (DD: 880KB).
31pub const FLOPPY_DD_SECTORS: u32 = 1760;
32
33/// Standard floppy disk sector count (HD: 1.76MB).
34pub const FLOPPY_HD_SECTORS: u32 = 3520;
35
36/// Sectors per track (DD).
37pub const SECTORS_PER_TRACK_DD: u32 = 11;
38
39/// Sectors per track (HD).
40pub const SECTORS_PER_TRACK_HD: u32 = 22;
41
42/// Number of heads.
43pub const HEADS: u32 = 2;
44
45/// Number of cylinders (tracks).
46pub const CYLINDERS: u32 = 80;
47
48// Filesystem type flags (in dosType[3])
49/// Original File System.
50pub const DOSFS_OFS: u8 = 0;
51/// Fast File System.
52pub const DOSFS_FFS: u8 = 1;
53/// International mode (case-insensitive for international characters).
54pub const DOSFS_INTL: u8 = 2;
55/// Directory cache mode.
56pub const DOSFS_DIRCACHE: u8 = 4;
57
58// Block types
59/// Header block type.
60pub const T_HEADER: i32 = 2;
61/// Data block type (OFS only).
62pub const T_DATA: i32 = 8;
63/// List/extension block type.
64pub const T_LIST: i32 = 16;
65/// Directory cache block type.
66pub const T_DIRC: i32 = 33;
67
68// Secondary types
69/// Root block secondary type.
70pub const ST_ROOT: i32 = 1;
71/// Directory secondary type.
72pub const ST_DIR: i32 = 2;
73/// Soft link secondary type.
74pub const ST_LSOFT: i32 = 3;
75/// Hard link to directory secondary type.
76pub const ST_LDIR: i32 = 4;
77/// File secondary type.
78pub const ST_FILE: i32 = -3;
79/// Hard link to file secondary type.
80pub const ST_LFILE: i32 = -4;
81
82// Access flags
83/// Delete protected.
84pub const ACC_DELETE: u32 = 1 << 0;
85/// Execute protected.
86pub const ACC_EXECUTE: u32 = 1 << 1;
87/// Write protected.
88pub const ACC_WRITE: u32 = 1 << 2;
89/// Read protected.
90pub const ACC_READ: u32 = 1 << 3;
91/// Archived.
92pub const ACC_ARCHIVE: u32 = 1 << 4;
93/// Pure (re-entrant).
94pub const ACC_PURE: u32 = 1 << 5;
95/// Script.
96pub const ACC_SCRIPT: u32 = 1 << 6;
97/// Hidden.
98pub const ACC_HOLD: u32 = 1 << 7;
99
100/// Valid bitmap flag value.
101pub const BM_VALID: i32 = -1;
102
103/// OFS data block payload size.
104pub const OFS_DATA_SIZE: usize = 488;
105
106/// FFS data block payload size (full block).
107pub const FFS_DATA_SIZE: usize = 512;
108
109// Variable block size constants (GRUB parity)
110/// Maximum log2 block size (512 << 4 = 8192 bytes).
111pub const MAX_LOG_BLOCK_SIZE: u8 = 4;
112
113/// Maximum boot block location to probe (sector 0 and 1).
114pub const MAX_BOOT_BLOCK: u32 = 1;
115
116/// Symlink target offset in block (same as hash table offset).
117pub const SYMLINK_OFFSET: usize = 24;
118
119/// File header structure offset from end of block.
120pub const FILE_LOCATION: usize = 200;
121
122/// Amiga epoch: January 1, 1978 00:00:00 UTC.
123/// Offset from Unix epoch (January 1, 1970) in seconds.
124/// 8 years = 2922 days (including leap years 1972, 1976).
125pub const AMIGA_EPOCH_OFFSET: i64 = 252288000;
126
127/// Supported block sizes for probing.
128pub const BLOCK_SIZES: [usize; 5] = [512, 1024, 2048, 4096, 8192];