2 * Copyright (C) 1994-1999, Index Data
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Id: mfile.h,v 1.15 2000-04-17 14:22:00 adam Exp $
13 #include <yaz/yconfig.h>
16 #include <sys/param.h>
17 #define FILENAME_MAX MAXPATHLEN
20 #include <zebra-lock.h>
24 #define MF_MIN_BLOCKS_CREAT 1 /* minimum free blocks in new dir */
25 #define MF_MAX_PARTS 28 /* max # of part-files per metafile */
27 #define mf_blocksize(mf) ((mf)->blocksize)
35 char name[FILENAME_MAX+1];
36 off_t max_bytes; /* allocated bytes in this dir. */
37 off_t avail_bytes; /* bytes left */
41 typedef struct part_file
52 struct MFile_area_struct;
53 typedef struct MFile_area_struct *MFile_area;
55 typedef struct meta_file
57 char name[FILENAME_MAX+1];
58 part_file files[MF_MAX_PARTS];
61 int open; /* is this file open? */
63 off_t min_bytes_creat; /* minimum bytes required to enter directory */
68 struct meta_file *next;
71 typedef struct MFile_area_struct
73 char name[FILENAME_MAX+1];
75 struct meta_file *mfiles;
76 struct MFile_area_struct *next; /* global list of active areas */
81 * Open an area, cotaining metafiles in directories.
83 MFile_area mf_init(const char *name, const char *spec);
88 void mf_destroy(MFile_area ma);
93 MFile mf_open(MFile_area ma, const char *name, int block_size, int wflag);
98 int mf_close(MFile mf);
101 * Read one block from a metafile. Interface mirrors bfile.
103 int mf_read(MFile mf, int no, int offset, int nbytes, void *buf);
108 int mf_write(MFile mf, int no, int offset, int nbytes, const void *buf);
111 * Destroy a metafile, unlinking component files. File must be open.
113 int mf_unlink(MFile mf);
117 * Destroy all metafiles. No files may be opened.
119 void mf_reset(MFile_area ma);
122 * Unlink the file by name, rather than MFile-handle.
124 int mf_unlink_name(MFile_area, const char *name);