2 * Copyright (C) 1994-1999, Index Data
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Id: mfile.h,v 1.12 1999-12-08 15:03:11 adam Exp $
15 #include <sys/param.h>
16 #define FILENAME_MAX MAXPATHLEN
23 #define MF_MIN_BLOCKS_CREAT 1 /* minimum free blocks in new dir */
24 #define MF_MAX_PARTS 28 /* max # of part-files per metafile */
26 #define mf_blocksize(mf) ((mf)->blocksize)
30 char name[FILENAME_MAX+1];
31 int max_bytes; /* allocated bytes in this dir. */
32 int avail_bytes; /* bytes left */
36 typedef struct part_file
47 struct MFile_area_struct;
48 typedef struct MFile_area_struct *MFile_area;
50 typedef struct meta_file
52 char name[FILENAME_MAX+1];
53 part_file files[MF_MAX_PARTS];
56 int open; /* is this file open? */
58 int min_bytes_creat; /* minimum bytes required to enter directory */
62 struct meta_file *next;
65 typedef struct MFile_area_struct
67 char name[FILENAME_MAX+1];
69 struct meta_file *mfiles;
70 struct MFile_area_struct *next; /* global list of active areas */
74 * Open an area, cotaining metafiles in directories.
76 MFile_area mf_init(const char *name, const char *spec);
81 void mf_destroy(MFile_area ma);
86 MFile mf_open(MFile_area ma, const char *name, int block_size, int wflag);
91 int mf_close(MFile mf);
94 * Read one block from a metafile. Interface mirrors bfile.
96 int mf_read(MFile mf, int no, int offset, int nbytes, void *buf);
101 int mf_write(MFile mf, int no, int offset, int nbytes, const void *buf);
104 * Destroy a metafile, unlinking component files. File must be open.
106 int mf_unlink(MFile mf);
110 * Destroy all metafiles. No files may be opened.
112 void mf_reset(MFile_area ma);
115 * Unlink the file by name, rather than MFile-handle.
117 int mf_unlink_name(MFile_area, const char *name);