blob: 3e6c649ac984e525bb1823d0f2ee67dd5a3e021f (
plain) (
blame)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
#ifndef UTIL_LINUX_MINIX_PROGRAMS_H
#define UTIL_LINUX_MINIX_PROGRAMS_H
#include "minix.h"
/*
* Global variables.
*/
static int fs_version = 1; /* this default value needs to change in a near future */
static char *super_block_buffer;
static char *inode_buffer = NULL;
static char *inode_map;
static char *zone_map;
/*
* Inline functions.
*/
static inline unsigned long get_ninodes(void)
{
switch (fs_version) {
case 3:
return Super3.s_ninodes;
default:
return (unsigned long)Super.s_ninodes;
}
}
static inline unsigned long get_nzones(void)
{
switch (fs_version) {
case 3:
return (unsigned long)Super3.s_zones;
case 2:
return (unsigned long)Super.s_zones;
default:
return (unsigned long)Super.s_nzones;
}
}
static inline unsigned long get_nimaps(void)
{
switch (fs_version) {
case 3:
return (unsigned long)Super3.s_imap_blocks;
default:
return (unsigned long)Super.s_imap_blocks;
}
}
static inline unsigned long get_nzmaps(void)
{
switch (fs_version) {
case 3:
return (unsigned long)Super3.s_zmap_blocks;
default:
return (unsigned long)Super.s_zmap_blocks;
}
}
static inline unsigned long get_first_zone(void)
{
switch (fs_version) {
case 3:
return (unsigned long)Super3.s_firstdatazone;
default:
return (unsigned long)Super.s_firstdatazone;
}
}
static inline unsigned long get_zone_size(void)
{
switch (fs_version) {
case 3:
return (unsigned long)Super3.s_log_zone_size;
default:
return (unsigned long)Super.s_log_zone_size;
}
}
static inline unsigned long get_max_size(void)
{
switch (fs_version) {
case 3:
return (unsigned long)Super3.s_max_size;
default:
return (unsigned long)Super.s_max_size;
}
}
static unsigned long inode_blocks(void)
{
switch (fs_version) {
case 3:
case 2:
return UPPER(get_ninodes(), MINIX2_INODES_PER_BLOCK);
default:
return UPPER(get_ninodes(), MINIX_INODES_PER_BLOCK);
}
}
static inline unsigned long first_zone_data(void)
{
return 2 + get_nimaps() + get_nzmaps() + inode_blocks();
}
static inline unsigned long get_inode_buffer_size(void)
{
return inode_blocks() * MINIX_BLOCK_SIZE;
}
#endif /* UTIL_LINUX_MINIX_PROGRAMS_H */
|