]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - disk-utils/minix_programs.h
2 * SPDX-License-Identifier: GPL-2.0-or-later
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * Copyright (C) 2011 Sami Kerola <kerolasa@iki.fi>
11 #ifndef UTIL_LINUX_MINIX_PROGRAMS_H
12 #define UTIL_LINUX_MINIX_PROGRAMS_H
19 extern int fs_version
;
20 extern char *super_block_buffer
;
22 #define Super (*(struct minix_super_block *) super_block_buffer)
23 #define Super3 (*(struct minix3_super_block *) super_block_buffer)
25 #define INODE_SIZE (sizeof(struct minix_inode))
26 #define INODE2_SIZE (sizeof(struct minix2_inode))
28 #define BITS_PER_BLOCK (MINIX_BLOCK_SIZE << 3)
30 #define UPPER(size,n) ((size+((n)-1))/(n))
35 static inline unsigned long get_ninodes(void)
39 return Super3
.s_ninodes
;
41 return Super
.s_ninodes
;
45 static inline unsigned long get_nzones(void)
49 return Super3
.s_zones
;
53 return Super
.s_nzones
;
57 static inline unsigned long get_nimaps(void)
61 return Super3
.s_imap_blocks
;
63 return Super
.s_imap_blocks
;
67 static inline unsigned long get_nzmaps(void)
71 return Super3
.s_zmap_blocks
;
73 return Super
.s_zmap_blocks
;
77 static inline off_t
get_first_zone(void)
81 return Super3
.s_firstdatazone
;
83 return Super
.s_firstdatazone
;
87 static inline size_t get_zone_size(void)
91 return Super3
.s_log_zone_size
;
93 return Super
.s_log_zone_size
;
97 static inline size_t get_max_size(void)
101 return Super3
.s_max_size
;
103 return Super
.s_max_size
;
107 static inline unsigned long inode_blocks(void)
109 switch (fs_version
) {
112 return UPPER(get_ninodes(), MINIX2_INODES_PER_BLOCK
);
114 return UPPER(get_ninodes(), MINIX_INODES_PER_BLOCK
);
118 static inline off_t
first_zone_data(void)
120 return 2 + get_nimaps() + get_nzmaps() + inode_blocks();
123 static inline size_t get_inode_buffer_size(void)
125 return inode_blocks() * MINIX_BLOCK_SIZE
;
128 #endif /* UTIL_LINUX_MINIX_PROGRAMS_H */