X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=ucw%2Ffb-param.c;h=21bbeb63d5756e07b8a928250c37940676957d75;hb=b8667492cf36a609939ee35ac42900ff0b0cc80f;hp=0d9d690418fb89be3c745fbd875574fe3c93e06f;hpb=44697ea9c408bbbd5b359e716c6dc8283b471423;p=libucw.git diff --git a/ucw/fb-param.c b/ucw/fb-param.c index 0d9d6904..21bbeb63 100644 --- a/ucw/fb-param.c +++ b/ucw/fb-param.c @@ -8,10 +8,11 @@ * of the GNU Lesser General Public License. */ -#include "ucw/lib.h" -#include "ucw/conf.h" -#include "ucw/lfs.h" -#include "ucw/fastbuf.h" +#include +#include +#include +#include +#include #include #include @@ -25,14 +26,21 @@ struct fb_params fbpar_def = { static char * fbpar_cf_commit(struct fb_params *p UNUSED) { -#ifndef CONFIG_UCW_THREADS if (p->type == FB_DIRECT) - return "Direct I/O is supported only with CONFIG_UCW_THREADS"; + { +#ifndef CONFIG_UCW_THREADS + return "Direct I/O is supported only with CONFIG_UCW_THREADS"; +#endif +#ifdef CONFIG_DARWIN + return "Direct I/O is not supported on darwin"; +#endif +#ifndef CONFIG_UCW_DIRECT_IO + return "Direct I/O disabled by configure switch -CONFIG_UCW_DIRECT_IO"; #endif #ifndef CONFIG_UCW_FB_DIRECT - if (p->type == FB_DIRECT) - return "Direct I/O is disabled"; + return "Direct I/O disabled by configure switch -CONFIG_UCW_FB_DIRECT"; #endif + } return NULL; } @@ -42,10 +50,10 @@ struct cf_section fbpar_cf = { CF_COMMIT(fbpar_cf_commit), CF_ITEMS { CF_LOOKUP("Type", (int *)F(type), ((const char * const []){"std", "direct", "mmap", NULL})), - CF_UNS("BufSize", F(buffer_size)), - CF_UNS("KeepBackBuf", F(keep_back_buf)), - CF_UNS("ReadAhead", F(read_ahead)), - CF_UNS("WriteBack", F(write_back)), + CF_UINT("BufSize", F(buffer_size)), + CF_UINT("KeepBackBuf", F(keep_back_buf)), + CF_UINT("ReadAhead", F(read_ahead)), + CF_UINT("WriteBack", F(write_back)), CF_END } # undef F @@ -65,7 +73,7 @@ fbpar_global_init(void) } static struct fastbuf * -bopen_fd_internal(int fd, struct fb_params *params, uns mode, const char *name) +bopen_fd_internal(int fd, struct fb_params *params, uint mode, const char *name) { char buf[32]; if (!name) @@ -94,7 +102,7 @@ bopen_fd_internal(int fd, struct fb_params *params, uns mode, const char *name) return fb; case FB_MMAP: if (!~mode && (int)(mode = fcntl(fd, F_GETFL)) < 0) - die("Cannot get flags of fd %d: %m", fd); + trans_throw("ucw.fb.open", NULL, "Cannot get flags of fd %d: %m", fd); return bfmmopen_internal(fd, name, mode); default: ASSERT(0); @@ -117,7 +125,7 @@ bopen_file_internal(const char *name, int mode, struct fb_params *params, int tr if (try) return NULL; else - die("Unable to %s file %s: %m", (mode & O_CREAT) ? "create" : "open", name); + trans_throw("ucw.fb.open", NULL, "Unable to %s file %s: %m", (mode & O_CREAT) ? "create" : "open", name); struct fastbuf *fb = bopen_fd_internal(fd, params, mode, name); ASSERT(fb); if (mode & O_APPEND) @@ -155,32 +163,32 @@ bclose_file_helper(struct fastbuf *f, int fd, int is_temp_file) msg(L_ERROR, "unlink(%s): %m", f->name); case 0: if (close(fd)) - die("close(%s): %m", f->name); + msg(L_ERROR, "close(%s): %m", f->name); } } /* Compatibility wrappers */ struct fastbuf * -bopen_try(const char *name, uns mode, uns buflen) +bopen_try(const char *name, uint mode, uint buflen) { return bopen_file_try(name, mode, &(struct fb_params){ .type = FB_STD, .buffer_size = buflen }); } struct fastbuf * -bopen(const char *name, uns mode, uns buflen) +bopen(const char *name, uint mode, uint buflen) { return bopen_file(name, mode, &(struct fb_params){ .type = FB_STD, .buffer_size = buflen }); } struct fastbuf * -bfdopen(int fd, uns buflen) +bfdopen(int fd, uint buflen) { return bopen_fd(fd, &(struct fb_params){ .type = FB_STD, .buffer_size = buflen }); } struct fastbuf * -bfdopen_shared(int fd, uns buflen) +bfdopen_shared(int fd, uint buflen) { struct fastbuf *f = bfdopen(fd, buflen); bconfig(f, BCONFIG_IS_TEMP_FILE, 2);