]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/fb-param.c
Heap: Interface cleanup
[libucw.git] / ucw / fb-param.c
index 514f987bb719729046a5fc16e1f1ba38a228233e..e0f9a73f49be87ba8d755dac490e6c824cc6b3d0 100644 (file)
@@ -8,10 +8,11 @@
  *     of the GNU Lesser General Public License.
  */
 
  *     of the GNU Lesser General Public License.
  */
 
-#include "ucw/lib.h"
-#include "ucw/conf.h"
-#include "ucw/lfs.h"
-#include "ucw/fastbuf.h"
+#include <ucw/lib.h>
+#include <ucw/conf.h>
+#include <ucw/io.h>
+#include <ucw/fastbuf.h>
+#include <ucw/trans.h>
 
 #include <fcntl.h>
 #include <stdio.h>
 
 #include <fcntl.h>
 #include <stdio.h>
@@ -25,14 +26,21 @@ struct fb_params fbpar_def = {
 static char *
 fbpar_cf_commit(struct fb_params *p UNUSED)
 {
 static char *
 fbpar_cf_commit(struct fb_params *p UNUSED)
 {
-#ifndef CONFIG_UCW_THREADS
   if (p->type == FB_DIRECT)
   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
 #endif
-#ifndef CONFIG_DIRECT
-  if (p->type == FB_DIRECT)
-    return "Direct I/O is disabled";
+#ifdef CONFIG_DARWIN
+      return "Direct I/O is not supported on darwin";
 #endif
 #endif
+#ifndef CONFIG_UCW_DIRECT_IO
+      return "Direct I/O disabled by configure switch -CONFIG_UCW_DIRECT_IO";
+#endif
+#ifndef CONFIG_UCW_FB_DIRECT
+      return "Direct I/O disabled by configure switch -CONFIG_UCW_FB_DIRECT";
+#endif
+    }
   return NULL;
 }
 
   return NULL;
 }
 
@@ -76,7 +84,7 @@ bopen_fd_internal(int fd, struct fb_params *params, uns mode, const char *name)
   struct fastbuf *fb;
   switch (params->type)
     {
   struct fastbuf *fb;
   switch (params->type)
     {
-#ifdef CONFIG_DIRECT
+#ifdef CONFIG_UCW_FB_DIRECT
       case FB_DIRECT:
        fb = fbdir_open_fd_internal(fd, name, params->asio,
            params->buffer_size ? : fbpar_def.buffer_size,
       case FB_DIRECT:
        fb = fbdir_open_fd_internal(fd, name, params->asio,
            params->buffer_size ? : fbpar_def.buffer_size,
@@ -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)
        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);
        return bfmmopen_internal(fd, name, mode);
       default:
        ASSERT(0);
@@ -106,7 +114,7 @@ bopen_file_internal(const char *name, int mode, struct fb_params *params, int tr
 {
   if (!params)
     params = &fbpar_def;
 {
   if (!params)
     params = &fbpar_def;
-#ifdef CONFIG_DIRECT
+#ifdef CONFIG_UCW_FB_DIRECT
   if (params->type == FB_DIRECT && !fbdir_cheat)
     mode |= O_DIRECT;
 #endif
   if (params->type == FB_DIRECT && !fbdir_cheat)
     mode |= O_DIRECT;
 #endif
@@ -117,7 +125,7 @@ bopen_file_internal(const char *name, int mode, struct fb_params *params, int tr
     if (try)
       return NULL;
     else
     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)
   struct fastbuf *fb = bopen_fd_internal(fd, params, mode, name);
   ASSERT(fb);
   if (mode & O_APPEND)
@@ -155,7 +163,7 @@ 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))
        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);
     }
 }
 
     }
 }