File: format40.h

package info (click to toggle)
reiser4progs 1.0.7-6
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 5,352 kB
  • ctags: 3,699
  • sloc: ansic: 33,483; sh: 8,489; makefile: 1,001
file content (125 lines) | stat: -rw-r--r-- 3,387 bytes parent folder | download | duplicates (4)
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
114
115
116
117
118
119
120
121
122
123
124
125
/* Copyright (C) 2001-2005 by Hans Reiser, licensing governed by
   reiser4progs/COPYING.
   
   format40.h -- reiser4 disk-format plugin. */

#ifndef FORMAT40_H
#define FORMAT40_H

#include <aal/libaal.h>
#include <reiser4/plugin.h>

#define FORMAT40_MAGIC "ReIsEr40FoRmAt"

#define FORMAT40_BLOCKNR(blksize) \
        (REISER4_MASTER_BLOCKNR(blksize) + 1)

#define SUPER(entity) (&((format40_t *)entity)->super)

#define MAGIC_SIZE 16

/* The greatest supported format40 version number */
#define FORMAT40_VERSION PLUGIN_LIBRARY_VERSION

/* This flag indicates that backup should be updated
   (the update is performed by fsck) */
#define FORMAT40_UPDATE_BACKUP  (1 << 31)

typedef struct format40_super {
	d64_t sb_block_count;
	d64_t sb_free_blocks;
	d64_t sb_root_block;
	
	/* These 2 fields are for oid data. */
	d64_t sb_oid[2];
	
	d64_t sb_flushes;
    
	d32_t sb_mkfs_id;
	char sb_magic[MAGIC_SIZE];

	d16_t sb_tree_height;
	d16_t sb_policy;
	d64_t sb_flags;
	
	d32_t sb_version;
	
	char sb_unused[428];
} __attribute__((packed)) format40_super_t;

typedef struct format40 {
	reiser4_format_plug_t *plug;

	uint32_t state;
	uint32_t blksize;
	
	aal_device_t *device;
	format40_super_t super;
} format40_t;

#ifndef ENABLE_MINIMAL
typedef struct format40_backup {
	char sb_magic[MAGIC_SIZE];
	d64_t sb_block_count;
	d32_t sb_mkfs_id;
	d16_t sb_policy;
	d64_t sb_flags;
	d32_t sb_version;
	d64_t sb_reserved;
} __attribute__((packed)) format40_backup_t;
#endif


extern reiser4_format_plug_t format40_plug;
extern reiser4_core_t *format40_core;

#define get_sb_mkfs_id(sb)		aal_get_le32(sb, sb_mkfs_id)
#define set_sb_mkfs_id(sb, val)		aal_set_le32(sb, sb_mkfs_id, val)

#define get_sb_block_count(sb)		aal_get_le64(sb, sb_block_count)
#define set_sb_block_count(sb, val)	aal_set_le64(sb, sb_block_count, val)

#define get_sb_free_blocks(sb)		aal_get_le64(sb, sb_free_blocks)
#define set_sb_free_blocks(sb, val)	aal_set_le64(sb, sb_free_blocks, val)

#define get_sb_root_block(sb)		aal_get_le64(sb, sb_root_block)
#define set_sb_root_block(sb, val)	aal_set_le64(sb, sb_root_block, val)

#define get_sb_policy(sb)		aal_get_le16(sb, sb_policy)
#define set_sb_policy(sb, val)		aal_set_le16(sb, sb_policy, val)

/* FIXME: Should not be here, oid's stuff. */
#define get_sb_oid(sb)			aal_get_le64(sb, sb_oid[0])
#define get_sb_file_count(sb)		aal_get_le64(sb, sb_oid[1])

#define get_sb_flushes(sb)		aal_get_le64(sb, sb_flushes)
#define set_sb_flushes(sb, val)		aal_set_le64(sb, sb_flushes, val)

#define get_sb_tree_height(sb)		aal_get_le16(sb, sb_tree_height)
#define set_sb_tree_height(sb, val)	aal_set_le16(sb, sb_tree_height, val)

#define get_sb_flags(sb)		aal_get_le64(sb, sb_flags)
#define set_sb_flags(sb, val)		aal_set_le64(sb, sb_flags, val)

#define get_sb_version(sb)	\
	(aal_get_le32(sb, sb_version) & ~FORMAT40_UPDATE_BACKUP)

#define set_sb_version(sb, val)		aal_set_le32(sb, sb_version, val)

#define sb_update_backup(sb)	\
	(aal_get_le32(sb, sb_version) & FORMAT40_UPDATE_BACKUP)

#define FORMAT40_KEY_LARGE		0

#define format40_mkdirty(entity) \
	(((format40_t *)entity)->state |= (1 << ENTITY_DIRTY))

#define format40_mkclean(entity) \
	(((format40_t *)entity)->state &= ~(1 << ENTITY_DIRTY))

#ifndef ENABLE_MINIMAL
extern void format40_set_key(reiser4_format_ent_t *entity, rid_t key);
extern rid_t format40_get_key(reiser4_format_ent_t *entity);
#endif

#endif