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 eb7f2826d93be646a5304fb7c81ba1c7b98dc220..0870bcad4b08300544044141ea802efec10942e3 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"
 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"
 LSEEK                          "lseek error"
 BUSY                           "table is busy"
 SHORT_TABLE                    "table too short"
diff --git a/fd.c b/fd.c
index 1519ac5552dbf106d7edbec5faf2776066c7e0f1..cd5232caf1339a61ae8d9a397395fe07214b6892 100644 (file)
--- a/fd.c
+++ b/fd.c
@@ -15,6 +15,7 @@
 #include "log.h"
 #include "osl.h"
 #include "error.h"
 #include "log.h"
 #include "osl.h"
 #include "error.h"
+#include "fd.h"
 
 /**
  * Wrapper for the write system call.
 
 /**
  * Wrapper for the write system call.
@@ -339,8 +340,8 @@ int truncate_file(const char *path, off_t size)
        int ret;
        struct stat statbuf;
 
        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)
                goto out;
        ret = -E_OSL_BAD_SIZE;
        if (statbuf.st_size < size)
diff --git a/fd.h b/fd.h
index c660babb31547ca821013ce4dbbd557641bea36a..7fdff916cec60425719772e55bc44027f1d54f86 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;
 }
                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 af448b4410890afda7a29fb446d63a6e43f46110..44e09d07ad20a179c111f06503ec4415c534e61e 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);
 {
        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 (!filename)
                return -ERRNO_TO_ERROR(ENOMEM);
-       if (stat(filename, &statbuf) < 0) {
+       ret = osl_stat(filename, &statbuf);
+       if (ret < 0) {
                free(filename);
                return ret;
        }
                free(filename);
                return ret;
        }