Get rid of E_OSL_STAT.
authorAndre Noll <maan@systemlinux.org>
Fri, 6 Jun 2008 09:43:43 +0000 (11:43 +0200)
committerAndre Noll <maan@systemlinux.org>
Fri, 6 Jun 2008 09:43:43 +0000 (11:43 +0200)
Use system error code instead.

errlist
fd.c
fd.h
osl.c

diff --git a/errlist b/errlist
index eb7f282..0870bca 100644 (file)
--- a/errlist
+++ b/errlist
@@ -23,7 +23,6 @@ RB_KEY_NOT_FOUND              "key not found in rbtree"
 BAD_ROW_NUM                    "invalid row number"
 INDEX_CORRUPTION               "index corruption detected"
 INVALID_OBJECT                 "reference to invalid object"
-STAT                           "can not stat file"
 LSEEK                          "lseek error"
 BUSY                           "table is busy"
 SHORT_TABLE                    "table too short"
diff --git a/fd.c b/fd.c
index 1519ac5..cd5232c 100644 (file)
--- a/fd.c
+++ b/fd.c
@@ -15,6 +15,7 @@
 #include "log.h"
 #include "osl.h"
 #include "error.h"
+#include "fd.h"
 
 /**
  * Wrapper for the write system call.
@@ -339,8 +340,8 @@ int truncate_file(const char *path, off_t size)
        int ret;
        struct stat statbuf;
 
-       ret = -E_OSL_STAT;
-       if (stat(path, &statbuf) < 0)
+       ret = osl_stat(path, &statbuf);
+       if (ret < 0)
                goto out;
        ret = -E_OSL_BAD_SIZE;
        if (statbuf.st_size < size)
diff --git a/fd.h b/fd.h
index c660bab..7fdff91 100644 (file)
--- a/fd.h
+++ b/fd.h
@@ -47,3 +47,10 @@ _static_inline_ int osl_rename(const char *old_path, const char *new_path)
                return -ERRNO_TO_ERROR(errno);
        return 1;
 }
+
+_static_inline_ int osl_stat(const char *path, struct stat *buf)
+{
+       if (stat(path, buf) >= 0)
+               return 1;
+       return -ERRNO_TO_ERROR(errno);
+}
diff --git a/osl.c b/osl.c
index af448b4..44e09d0 100644 (file)
--- a/osl.c
+++ b/osl.c
@@ -658,11 +658,12 @@ static int map_column(struct osl_table *t, unsigned col_num)
 {
        struct stat statbuf;
        char *filename = column_filename(t, col_num);
-       int ret = -E_OSL_STAT;
+       int ret;
 
        if (!filename)
                return -ERRNO_TO_ERROR(ENOMEM);
-       if (stat(filename, &statbuf) < 0) {
+       ret = osl_stat(filename, &statbuf);
+       if (ret < 0) {
                free(filename);
                return ret;
        }