2 * Copyright (C) 1994-1999, Index Data
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Id: mfile.h,v 1.17 2002-04-04 14:14:13 adam Exp $
13 #include <yaz/yconfig.h>
18 #include <sys/types.h>
22 #include <sys/param.h>
23 #define FILENAME_MAX MAXPATHLEN
26 #include <zebra-lock.h>
30 #define MF_MIN_BLOCKS_CREAT 1 /* minimum free blocks in new dir */
31 #define MF_MAX_PARTS 28 /* max # of part-files per metafile */
33 #define mf_blocksize(mf) ((mf)->blocksize)
38 char name[FILENAME_MAX+1];
39 off_t max_bytes; /* allocated bytes in this dir. */
40 off_t avail_bytes; /* bytes left */
44 typedef struct part_file
55 struct MFile_area_struct;
56 typedef struct MFile_area_struct *MFile_area;
58 typedef struct meta_file
60 char name[FILENAME_MAX+1];
61 part_file files[MF_MAX_PARTS];
64 int open; /* is this file open? */
66 off_t min_bytes_creat; /* minimum bytes required to enter directory */
71 struct meta_file *next;
74 typedef struct MFile_area_struct
76 char name[FILENAME_MAX+1];
78 struct meta_file *mfiles;
79 struct MFile_area_struct *next; /* global list of active areas */
84 * Open an area, cotaining metafiles in directories.
86 MFile_area mf_init(const char *name, const char *spec, const char *base);
91 void mf_destroy(MFile_area ma);
96 MFile mf_open(MFile_area ma, const char *name, int block_size, int wflag);
101 int mf_close(MFile mf);
104 * Read one block from a metafile. Interface mirrors bfile.
106 int mf_read(MFile mf, int no, int offset, int nbytes, void *buf);
111 int mf_write(MFile mf, int no, int offset, int nbytes, const void *buf);
114 * Destroy a metafile, unlinking component files. File must be open.
116 int mf_unlink(MFile mf);
120 * Destroy all metafiles. No files may be opened.
122 void mf_reset(MFile_area ma);
125 * Unlink the file by name, rather than MFile-handle.
127 int mf_unlink_name(MFile_area, const char *name);