iallo.c implemented
[tfsprogs.git] / tfs.h
blob09fb5f92f2b8690b8b332968af806b67eaddbaac
1 #ifndef TFS_H
2 #define TFS_H
4 #include <stdint.h>
6 /* It's really enought for a test file system */
7 #define TFS_N_BLOCKS 8
9 struct tfs_inode {
10 uint16_t i_mode; /* File mode */
11 uint16_t i_uid; /* Owner UID */
12 uint32_t i_size; /* File size */
13 uint32_t i_atime; /* Access time */
14 uint32_t i_ctime; /* Create time */
15 uint32_t i_mtime; /* modify time */
16 uint32_t i_dtime; /* delete time */
17 uint32_t i_block[TFS_N_BLOCKS]; /* block address of file's count */
18 uint32_t i_flags; /* flags */
19 uint32_t i_reserved[1];
22 /*
23 * The inode structure in memory, including the detail file information
25 struct inode {
26 int i_mode; /* FILE or DIR */
27 uint32_t i_size;
28 uint32_t i_ino; /* Inode number */
29 uint32_t i_atime; /* Access time */
30 uint32_t i_mtime; /* Modify time */
31 uint32_t i_ctime; /* Create time */
32 uint32_t i_dtime; /* Delete time */
33 uint32_t * i_data; /* The block address array where the file stores */
34 uint32_t i_flags;
37 /* The max lenght of each file name */
38 #define TFS_NAME_LEN 28
39 struct tfs_dir_entry {
40 uint32_t d_inode; /* inode number */
41 char d_name[TFS_NAME_LEN]; /* entry name */
44 #define TFS_MAGIC 0x4c534654 /* TFSL */
46 /* TFS super block */
47 struct tfs_super_block {
48 uint32_t s_inodes_count; /* Max file count */
49 uint32_t s_blocks_count;
50 uint32_t s_free_blocks_count;
51 uint32_t s_free_inodes_count;
52 uint32_t s_magic; /* TFS's magic signature */
53 uint32_t s_block_shift; /* Block size */
55 uint32_t s_inode_bitmap;
56 uint32_t s_block_bitmap;
57 uint32_t s_inode_table;
58 uint32_t s_data_area; /* where the data starts */
61 uint32_t s_offset; /* In which sector the fs stored */
62 uint32_t s_reserved[117];
65 /* TFS super block info */
66 struct tfs_sb_info {
67 uint32_t s_inodes_count; /* Max file count */
68 uint32_t s_blocks_count;
69 uint32_t s_free_blocks_count;
70 uint32_t s_free_inodes_count;
71 uint32_t s_block_shift; /* Block size in bits */
72 uint32_t s_block_size; /* Block size in bytes */
74 uint32_t s_inode_bitmap;
75 uint32_t s_inode_bitmap_count;
76 uint32_t s_block_bitmap;
77 uint32_t s_block_bitmap_count;
78 uint32_t s_inode_table;
79 uint32_t s_inode_table_count;
80 uint32_t s_data_area; /* where the data starts */
83 uint32_t s_offset; /* In which sector the fs stored */
86 /* utils.c */
87 extern int set_bit(void *, unsigned int);
88 extern int clear_bit(void *, unsigned int);
89 extern int test_bit(const void *, unsigned int);
90 extern uint32_t find_first_zero(void *, void *);
92 extern int write_sector(uint32_t, void *, int);
93 extern int read_sector(uint32_t, void *, int);
94 extern int tfs_bread(struct tfs_sb_info *, uint32_t , void *);
95 extern int tfs_bwrite(struct tfs_sb_info *, uint32_t, void *);
97 /* super.c */
98 struct tfs_sb_info * tfs_mount(void);
99 struct tfs_sb_info * tfs_mount_by_fsname(const char *);
100 #endif /* tfs.h */