2 * Copyright (C) 1994-1999, Index Data
4 * Sebastian Hammer, Adam Dickmeiss
6 * $Id: mfile.h,v 1.13 2000-03-15 15:00:30 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)
31 char name[FILENAME_MAX+1];
32 off_t max_bytes; /* allocated bytes in this dir. */
33 off_t avail_bytes; /* bytes left */
37 typedef struct part_file
48 struct MFile_area_struct;
49 typedef struct MFile_area_struct *MFile_area;
51 typedef struct meta_file
53 char name[FILENAME_MAX+1];
54 part_file files[MF_MAX_PARTS];
57 int open; /* is this file open? */
59 int min_bytes_creat; /* minimum bytes required to enter directory */
64 struct meta_file *next;
67 typedef struct MFile_area_struct
69 char name[FILENAME_MAX+1];
71 struct meta_file *mfiles;
72 struct MFile_area_struct *next; /* global list of active areas */
77 * Open an area, cotaining metafiles in directories.
79 MFile_area mf_init(const char *name, const char *spec);
84 void mf_destroy(MFile_area ma);
89 MFile mf_open(MFile_area ma, const char *name, int block_size, int wflag);
94 int mf_close(MFile mf);
97 * Read one block from a metafile. Interface mirrors bfile.
99 int mf_read(MFile mf, int no, int offset, int nbytes, void *buf);
104 int mf_write(MFile mf, int no, int offset, int nbytes, const void *buf);
107 * Destroy a metafile, unlinking component files. File must be open.
109 int mf_unlink(MFile mf);
113 * Destroy all metafiles. No files may be opened.
115 void mf_reset(MFile_area ma);
118 * Unlink the file by name, rather than MFile-handle.
120 int mf_unlink_name(MFile_area, const char *name);