1 /* $Id: mfile.h,v 1.18 2002-08-02 19:26:55 adam Exp $
2 Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
5 This file is part of the Zebra server.
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with Zebra; see the file LICENSE.zebra. If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
29 #include <yaz/yconfig.h>
34 #include <sys/types.h>
38 #include <sys/param.h>
39 #define FILENAME_MAX MAXPATHLEN
42 #include <zebra-lock.h>
46 #define MF_MIN_BLOCKS_CREAT 1 /* minimum free blocks in new dir */
47 #define MF_MAX_PARTS 28 /* max # of part-files per metafile */
49 #define mf_blocksize(mf) ((mf)->blocksize)
54 char name[FILENAME_MAX+1];
55 off_t max_bytes; /* allocated bytes in this dir. */
56 off_t avail_bytes; /* bytes left */
60 typedef struct part_file
71 struct MFile_area_struct;
72 typedef struct MFile_area_struct *MFile_area;
74 typedef struct meta_file
76 char name[FILENAME_MAX+1];
77 part_file files[MF_MAX_PARTS];
80 int open; /* is this file open? */
82 off_t min_bytes_creat; /* minimum bytes required to enter directory */
87 struct meta_file *next;
90 typedef struct MFile_area_struct
92 char name[FILENAME_MAX+1];
94 struct meta_file *mfiles;
95 struct MFile_area_struct *next; /* global list of active areas */
100 * Open an area, cotaining metafiles in directories.
102 MFile_area mf_init(const char *name, const char *spec, const char *base);
107 void mf_destroy(MFile_area ma);
112 MFile mf_open(MFile_area ma, const char *name, int block_size, int wflag);
117 int mf_close(MFile mf);
120 * Read one block from a metafile. Interface mirrors bfile.
122 int mf_read(MFile mf, int no, int offset, int nbytes, void *buf);
127 int mf_write(MFile mf, int no, int offset, int nbytes, const void *buf);
130 * Destroy a metafile, unlinking component files. File must be open.
132 int mf_unlink(MFile mf);
136 * Destroy all metafiles. No files may be opened.
138 void mf_reset(MFile_area ma);
141 * Unlink the file by name, rather than MFile-handle.
143 int mf_unlink_name(MFile_area, const char *name);