HelenOS sources
#ifndef _MFS_H_
#define _MFS_H_
#include <minix.h>
#include <macros.h>
#include <block.h>
#include <libfs.h>
#include <adt/list.h>
#include <mem.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <assert.h>
#include <stdbool.h>
#include <macros.h>
#include "../../vfs/vfs.h"
#define NAME "mfs"
#ifdef DEBUG_MODE
#define mfsdebug(...) printf(__VA_ARGS__)
#else
#define mfsdebug(...)
#endif
#define MFS_BMAP_START_BLOCK(sbi, bid) \
((bid) == BMAP_ZONE ? 2 + (sbi)->ibmap_blocks : 2)
#define MFS_BMAP_SIZE_BITS(sbi, bid) \
((bid) == BMAP_ZONE ? (sbi)->nzones - (sbi)->firstdatazone - 1 : \
(sbi)->ninodes - 1)
#define MFS_BMAP_SIZE_BLOCKS(sbi, bid) \
((bid) == BMAP_ZONE ? (sbi)->zbmap_blocks : (sbi)->ibmap_blocks)
typedef uint32_t bitchunk_t;
typedef enum {
BMAP_ZONE,
BMAP_INODE
} bmap_id_t;
typedef enum {
MFS_VERSION_V1 = 1,
MFS_VERSION_V2,
MFS_VERSION_V3
} mfs_version_t;
struct mfs_sb_info {
uint32_t ninodes;
uint32_t nzones;
unsigned long ibmap_blocks;
unsigned long zbmap_blocks;
unsigned long firstdatazone;
int log2_zone_size;
int block_size;
uint32_t max_file_size;
uint16_t magic;
uint16_t state;
unsigned long itable_size;
mfs_version_t fs_version;
int ino_per_block;
size_t dirsize;
int itable_off;
unsigned max_name_len;
bool long_names;
bool native;
unsigned isearch;
unsigned zsearch;
bool nfree_zones_valid;
unsigned nfree_zones;
};
struct mfs_ino_info {
uint16_t i_mode;
uint16_t i_nlinks;
int16_t i_uid;
uint16_t i_gid;
size_t i_size;
int32_t i_atime;
int32_t i_mtime;
int32_t i_ctime;
uint32_t i_dzone[V2_NR_DIRECT_ZONES];
uint32_t i_izone[V2_NR_INDIRECT_ZONES];
bool dirty;
fs_index_t index;
};
struct mfs_dentry_info {
uint32_t d_inum;
char d_name[MFS3_MAX_NAME_LEN + 1];
unsigned index;
struct mfs_node *node;
};
struct mfs_instance {
service_id_t service_id;
struct mfs_sb_info *sbi;
unsigned open_nodes_cnt;
};
struct mfs_node {
struct mfs_ino_info *ino_i;
struct mfs_instance *instance;
unsigned refcnt;
fs_node_t *fsnode;
ht_link_t link;
};
extern vfs_out_ops_t mfs_ops;
extern libfs_ops_t mfs_libfs_ops;
extern errno_t
mfs_global_init(void);
extern errno_t
mfs_get_inode(struct mfs_instance *inst, struct mfs_ino_info **ino_i,
fs_index_t index);
extern errno_t
mfs_put_inode(struct mfs_node *mnode);
extern errno_t
mfs_inode_shrink(struct mfs_node *mnode, size_t size_shrink);
extern errno_t
mfs_read_map(uint32_t *b, const struct mfs_node *mnode, const uint32_t pos);
extern errno_t
mfs_write_map(struct mfs_node *mnode, uint32_t pos, uint32_t new_zone,
uint32_t *old_zone);
extern errno_t
mfs_prune_ind_zones(struct mfs_node *mnode, size_t new_size);
extern errno_t
mfs_read_dentry(struct mfs_node *mnode,
struct mfs_dentry_info *d_info, unsigned index);
extern errno_t
mfs_write_dentry(struct mfs_dentry_info *d_info);
extern errno_t
mfs_remove_dentry(struct mfs_node *mnode, const char *d_name);
extern errno_t
mfs_insert_dentry(struct mfs_node *mnode, const char *d_name, fs_index_t d_inum);
extern errno_t
mfs_alloc_inode(struct mfs_instance *inst, uint32_t *inum);
extern errno_t
mfs_free_inode(struct mfs_instance *inst, uint32_t inum);
extern errno_t
mfs_alloc_zone(struct mfs_instance *inst, uint32_t *zone);
extern errno_t
mfs_free_zone(struct mfs_instance *inst, uint32_t zone);
extern errno_t
mfs_count_free_zones(struct mfs_instance *inst, uint32_t *zones);
extern errno_t
mfs_count_free_inodes(struct mfs_instance *inst, uint32_t *inodes);
extern uint16_t
conv16(bool native, uint16_t n);
extern uint32_t
conv32(bool native, uint32_t n);
extern uint64_t
conv64(bool native, uint64_t n);
#endif
HelenOS homepage, sources at GitHub