Extract common OMFS code into a library
[omfsprogs.git] / libomfs / omfs.h
blob1e854c4f59d9b252bf7c35f7dab6aac8bb08d5bb
1 #ifndef _OMFS_H
2 #define _OMFS_H
4 #include <stdio.h>
5 #include "config.h"
6 #include "omfs_fs.h"
7 #include "crc.h"
9 struct omfs_info {
10 FILE *dev;
11 struct omfs_super_block *super;
12 struct omfs_root_block *root;
13 struct omfs_bitmap *bitmap;
14 int swap;
15 pthread_mutex_t dev_mutex;
18 struct omfs_bitmap {
19 u8 *dirty;
20 u8 *bmap;
23 typedef struct omfs_info omfs_info_t;
24 typedef struct omfs_header omfs_header_t;
25 typedef struct omfs_super_block omfs_super_t;
26 typedef struct omfs_bitmap omfs_bitmap_t;
27 typedef struct omfs_root_block omfs_root_t;
28 typedef struct omfs_inode omfs_inode_t;
30 int omfs_read_super(omfs_info_t *info);
31 int omfs_write_super(omfs_info_t *info);
32 int omfs_read_root_block(omfs_info_t *info);
33 int omfs_write_root_block(omfs_info_t *info);
34 u8 *omfs_get_block(omfs_info_t *info, u64 block);
35 int omfs_write_block(omfs_info_t *info, u64 block, u8* buf);
36 void omfs_release_block(u8 *buf);
37 int omfs_check_crc(u8 *blk);
38 omfs_inode_t *omfs_get_inode(omfs_info_t *info, u64 block);
39 int omfs_write_inode(omfs_info_t *info, omfs_inode_t *inode);
40 void omfs_release_inode(omfs_inode_t *inode);
41 void omfs_sync(omfs_info_t *info);
42 int omfs_load_bitmap(omfs_info_t *info);
43 int omfs_flush_bitmap(omfs_info_t *info);
44 int omfs_compute_hash(omfs_info_t *info, char *filename);
45 omfs_inode_t *omfs_new_inode(omfs_info_t *info, u64 block, char *name,
46 char type);
47 void omfs_clear_data(omfs_info_t *info, u64 block, int count);
49 /* bitmap.c */
50 int omfs_allocate_one_block(omfs_info_t *info, u64 block);
51 int omfs_allocate_block(omfs_info_t *info, int size, u64 *return_block);
52 int omfs_clear_range(omfs_info_t *info, u64 start, int count);
53 unsigned long omfs_count_free(omfs_info_t *info);
55 #endif