X-Git-Url: http://git.indexdata.com/?p=idzebra-moved-to-github.git;a=blobdiff_plain;f=bfile%2Fmfile.c;h=f05a0fcc8e2cfea73884ead4018b6489e828ec5a;hp=b55dc2e5fdc0b0cd023df3004ed4f8000b42d71b;hb=c3ff843e467932c6027a8b3b2ebda7b44612447e;hpb=0f78f3fe78e859d9f0d3f0d3e13fcd28085dd427 diff --git a/bfile/mfile.c b/bfile/mfile.c index b55dc2e..f05a0fc 100644 --- a/bfile/mfile.c +++ b/bfile/mfile.c @@ -1,8 +1,5 @@ -/* $Id: mfile.c,v 1.71 2006-11-14 08:12:06 adam Exp $ - Copyright (C) 1995-2006 - Index Data ApS - -This file is part of the Zebra server. +/* This file is part of the Zebra server. + Copyright (C) Index Data Zebra is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free @@ -20,6 +17,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#if HAVE_CONFIG_H +#include +#endif #include #include #ifdef WIN32 @@ -45,7 +45,7 @@ static int scan_areadef(MFile_area ma, const char *ad, const char *base) /* * If no definition is given, use current directory, unlimited. */ - char dirname[FILENAME_MAX+1]; + char dirname[FILENAME_MAX+1]; mf_dir **dp = &ma->dirs, *dir = *dp; if (!ad) @@ -134,7 +134,7 @@ static int scan_areadef(MFile_area ma, const char *ad, const char *base) \retval -1 ERROR \retval -2 OK, but file does not created (read-only) */ - + static zint file_position(MFile mf, zint pos, int offset) { zint off = 0, ps; @@ -192,7 +192,8 @@ static int cmp_part_file(const void *p1, const void *p2) return 0; } -MFile_area mf_init(const char *name, const char *spec, const char *base) +MFile_area mf_init(const char *name, const char *spec, const char *base, + int only_shadow_files) { MFile_area ma = (MFile_area) xmalloc(sizeof(*ma)); mf_dir *dirp; @@ -202,7 +203,7 @@ MFile_area mf_init(const char *name, const char *spec, const char *base) struct dirent *dent; int fd, number; char metaname[FILENAME_MAX+1], tmpnam[FILENAME_MAX+1]; - + yaz_log(YLOG_DEBUG, "mf_init(%s)", name); strcpy(ma->name, name); ma->mfiles = 0; @@ -236,6 +237,11 @@ MFile_area mf_init(const char *name, const char *spec, const char *base) memcpy(metaname, dent->d_name, cp - dent->d_name); metaname[ cp - dent->d_name] = '\0'; + /* only files such as file-i-0.mf and file-i-b-0.mf, bug #739 */ + if (only_shadow_files && cp[-2] != '-') + continue; + if (!only_shadow_files && cp[-2] == '-') + continue; for (meta_f = ma->mfiles; meta_f; meta_f = meta_f->next) { /* known metafile */ @@ -282,9 +288,6 @@ MFile_area mf_init(const char *name, const char *spec, const char *base) mf_destroy(ma); return 0; } -#ifndef WIN32 - fsync(fd); -#endif close(fd); if (dirp->max_bytes >= 0) dirp->avail_bytes -= part_f->bytes; @@ -363,6 +366,7 @@ MFile mf_open(MFile_area ma, const char *name, int block_size, int wflag) yaz_log(YLOG_WARN, "metafile %s already open", name); return 0; } + break; } if (!mnew) { @@ -433,7 +437,8 @@ int mf_close(MFile mf) if (mf->files[i].fd >= 0) { #ifndef WIN32 - fsync(mf->files[i].fd); + if (mf->wr) + fsync(mf->files[i].fd); #endif close(mf->files[i].fd); mf->files[i].fd = -1; @@ -538,6 +543,13 @@ int mf_write(MFile mf, zint no, int offset, int nbytes, const void *buf) { yaz_log(YLOG_FATAL, "mf_write: %s error (4) no more space", mf->name); + for (dp = mf->ma->dirs; dp ; dp = dp->next) { + yaz_log(YLOG_FATAL,"%s: max=" ZINT_FORMAT + " used=" ZINT_FORMAT " available=" ZINT_FORMAT, + dp->name, (zint)dp->max_bytes, + (zint)(dp->max_bytes - dp->avail_bytes), (zint)dp->avail_bytes ); + } + yaz_log(YLOG_FATAL,"Adjust the limits in your zebra.cfg"); ret = -1; goto out; } @@ -561,7 +573,7 @@ int mf_write(MFile mf, zint no, int offset, int nbytes, const void *buf) yaz_log(YLOG_FATAL, "mf_write: %s error (5)", mf->name); ret = -1; goto out; - } + } } else { @@ -585,7 +597,7 @@ int mf_write(MFile mf, zint no, int offset, int nbytes, const void *buf) return ret; } -/** \brief metafile area statistics +/** \brief metafile area statistics \param ma metafile area handle \param no area number (0=first, 1=second, ..) \param directory holds directory upon completion (if non-NULL) @@ -620,6 +632,7 @@ int mf_area_directory_stat(MFile_area ma, int no, const char **directory, /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil * End: * vim: shiftwidth=4 tabstop=8 expandtab