From: Andre Noll Date: Fri, 6 Jun 2008 09:43:43 +0000 (+0200) Subject: Get rid of E_OSL_STAT. X-Git-Tag: v0.1.0~60 X-Git-Url: http://git.tuebingen.mpg.de/?p=osl.git;a=commitdiff_plain;h=3c96f3b4f7bb1be1c630085981e83eb0260b99a7;hp=68aa66b6f051083b8f9fe9cf65b0a20fed4363f9 Get rid of E_OSL_STAT. Use system error code instead. --- diff --git a/errlist b/errlist index eb7f282..0870bca 100644 --- 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 --- 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 --- 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 --- 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; }