Prepare Makefile and README for release 0.5.0
[omfs_fuse.git] / omfs.h
blob13ac25cbfc608b1eb3e0b380dbf394babc77d7f5
1 #ifndef _OMFS_H
2 #define _OMFS_H
4 #include "config.h"
5 #include <stdio.h>
7 #define OMFS_MAGIC 0xC2993D87
8 #define OMFS_IMAGIC 0xD2
10 #define OMFS_DIR 'D'
11 #define OMFS_FILE 'F'
12 #define OMFS_INODE_NORMAL 'e'
13 #define OMFS_INODE_CONTINUATION 'c'
14 #define OMFS_INODE_SYSTEM 's'
15 #define OMFS_SUPER_NAMELEN 64
16 #define OMFS_NAMELEN 256
17 #define OMFS_DIR_START 0x1b8
18 #define OMFS_EXTENT_START 0x1d0
19 #define OMFS_EXTENT_CONT 0x40
20 #define OMFS_XOR_COUNT 19
23 struct omfs_info {
24 FILE *dev;
25 struct omfs_super_block *super;
26 struct omfs_root_block *root;
27 struct omfs_bitmap *bitmap;
28 int swap;
29 pthread_mutex_t dev_mutex;
32 struct omfs_super_block {
33 char fill1[192];
34 char name[OMFS_SUPER_NAMELEN];
35 u64 root_block;
36 u64 num_blocks;
37 u32 magic;
38 u32 blocksize;
39 u32 mirrors;
40 u32 sys_blocksize;
43 struct omfs_header {
44 u64 self;
45 u32 body_size;
46 u16 crc;
47 char fill1[2];
48 u8 version;
49 char type;
50 u8 magic;
51 u8 check_xor;
52 u32 fill2;
55 struct omfs_root_block {
56 struct omfs_header head;
57 u64 fill1;
58 u64 num_blocks;
59 u64 root_dir;
60 u64 bitmap;
61 u32 blocksize;
62 u32 clustersize;
63 u64 mirrors;
64 char name[OMFS_NAMELEN];
65 u64 fill2;
68 struct omfs_inode {
69 struct omfs_header head;
70 u64 parent;
71 u64 sibling;
72 u64 ctime;
73 char fill1[35];
74 char type;
75 u32 one_goes_here;
76 char fill3[64];
77 char name[OMFS_NAMELEN];
78 u64 size;
81 struct omfs_extent_entry {
82 u64 cluster;
83 u64 blocks;
86 struct omfs_extent {
87 u64 next;
88 u32 extent_count;
89 u32 fill;
90 struct omfs_extent_entry entry;
93 struct omfs_bitmap {
94 u8 *dirty;
95 u8 *bmap;
98 typedef struct omfs_info omfs_info_t;
99 typedef struct omfs_header omfs_header_t;
100 typedef struct omfs_super_block omfs_super_t;
101 typedef struct omfs_root_block omfs_root_t;
102 typedef struct omfs_inode omfs_inode_t;
104 int omfs_read_super(omfs_info_t *info);
105 int omfs_write_super(omfs_info_t *info);
106 int omfs_read_root_block(omfs_info_t *info);
107 int omfs_write_root_block(omfs_info_t *info);
108 u8 *omfs_get_block(omfs_info_t *info, u64 block);
109 int omfs_write_block(omfs_info_t *info, u64 block, u8* buf);
110 void omfs_release_block(u8 *buf);
111 int omfs_check_crc(u8 *blk);
112 omfs_inode_t *omfs_get_inode(omfs_info_t *info, u64 block);
113 int omfs_write_inode(omfs_info_t *info, omfs_inode_t *inode);
114 void omfs_release_inode(omfs_inode_t *inode);
115 void omfs_sync(omfs_info_t *info);
116 int omfs_load_bitmap(omfs_info_t *info);
117 int omfs_flush_bitmap(omfs_info_t *info);
118 int omfs_compute_hash(omfs_info_t *info, char *filename);
119 omfs_inode_t *omfs_new_inode(omfs_info_t *info, u64 block, char *name,
120 char type);
121 void omfs_clear_data(omfs_info_t *info, u64 block, int count);
123 /* bitmap.c */
124 int omfs_allocate_one_block(omfs_info_t *info, u64 block);
125 int omfs_allocate_block(omfs_info_t *info, int size, u64 *return_block);
126 int omfs_clear_range(omfs_info_t *info, u64 start, int count);
127 unsigned long omfs_count_free(omfs_info_t *info);
129 #endif