~ubuntu-branches/ubuntu/trusty/util-linux/trusty-proposed

« back to all changes in this revision

Viewing changes to disk-utils/minix_programs.h

  • Committer: Package Import Robot
  • Author(s): LaMont Jones
  • Date: 2011-11-03 15:38:23 UTC
  • mto: (4.5.5 sid) (1.6.4)
  • mto: This revision was merged to the branch mainline in revision 85.
  • Revision ID: package-import@ubuntu.com-20111103153823-10sx16jprzxlhkqf
ImportĀ upstreamĀ versionĀ 2.20.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef UTIL_LINUX_MINIX_PROGRAMS_H
 
2
#define UTIL_LINUX_MINIX_PROGRAMS_H
 
3
 
 
4
#include "minix.h"
 
5
 
 
6
/*
 
7
 * Global variables.
 
8
 */
 
9
extern int fs_version;
 
10
extern char *super_block_buffer;
 
11
 
 
12
#define Super (*(struct minix_super_block *) super_block_buffer)
 
13
#define Super3 (*(struct minix3_super_block *) super_block_buffer)
 
14
 
 
15
#define INODE_SIZE (sizeof(struct minix_inode))
 
16
#define INODE2_SIZE (sizeof(struct minix2_inode))
 
17
 
 
18
#define BITS_PER_BLOCK (MINIX_BLOCK_SIZE << 3)
 
19
 
 
20
#define UPPER(size,n) ((size+((n)-1))/(n))
 
21
 
 
22
/*
 
23
 * Inline functions.
 
24
 */
 
25
static inline unsigned long get_ninodes(void)
 
26
{
 
27
        switch (fs_version) {
 
28
        case 3:
 
29
                return Super3.s_ninodes;
 
30
        default:
 
31
                return (unsigned long)Super.s_ninodes;
 
32
        }
 
33
}
 
34
 
 
35
static inline unsigned long get_nzones(void)
 
36
{
 
37
        switch (fs_version) {
 
38
        case 3:
 
39
                return (unsigned long)Super3.s_zones;
 
40
        case 2:
 
41
                return (unsigned long)Super.s_zones;
 
42
        default:
 
43
                return (unsigned long)Super.s_nzones;
 
44
        }
 
45
}
 
46
 
 
47
static inline unsigned long get_nimaps(void)
 
48
{
 
49
        switch (fs_version) {
 
50
        case 3:
 
51
                return (unsigned long)Super3.s_imap_blocks;
 
52
        default:
 
53
                return (unsigned long)Super.s_imap_blocks;
 
54
        }
 
55
}
 
56
 
 
57
static inline unsigned long get_nzmaps(void)
 
58
{
 
59
        switch (fs_version) {
 
60
        case 3:
 
61
                return (unsigned long)Super3.s_zmap_blocks;
 
62
        default:
 
63
                return (unsigned long)Super.s_zmap_blocks;
 
64
        }
 
65
}
 
66
 
 
67
static inline unsigned long get_first_zone(void)
 
68
{
 
69
        switch (fs_version) {
 
70
        case 3:
 
71
                return (unsigned long)Super3.s_firstdatazone;
 
72
        default:
 
73
                return (unsigned long)Super.s_firstdatazone;
 
74
        }
 
75
}
 
76
 
 
77
static inline unsigned long get_zone_size(void)
 
78
{
 
79
        switch (fs_version) {
 
80
        case 3:
 
81
                return (unsigned long)Super3.s_log_zone_size;
 
82
        default:
 
83
                return (unsigned long)Super.s_log_zone_size;
 
84
        }
 
85
}
 
86
 
 
87
static inline unsigned long get_max_size(void)
 
88
{
 
89
        switch (fs_version) {
 
90
        case 3:
 
91
                return (unsigned long)Super3.s_max_size;
 
92
        default:
 
93
                return (unsigned long)Super.s_max_size;
 
94
        }
 
95
}
 
96
 
 
97
static unsigned long inode_blocks(void)
 
98
{
 
99
        switch (fs_version) {
 
100
        case 3:
 
101
        case 2:
 
102
                return UPPER(get_ninodes(), MINIX2_INODES_PER_BLOCK);
 
103
        default:
 
104
                return UPPER(get_ninodes(), MINIX_INODES_PER_BLOCK);
 
105
        }
 
106
}
 
107
 
 
108
static inline unsigned long first_zone_data(void)
 
109
{
 
110
        return 2 + get_nimaps() + get_nzmaps() + inode_blocks();
 
111
}
 
112
 
 
113
static inline unsigned long get_inode_buffer_size(void)
 
114
{
 
115
        return inode_blocks() * MINIX_BLOCK_SIZE;
 
116
}
 
117
 
 
118
#endif                          /* UTIL_LINUX_MINIX_PROGRAMS_H */