Kill all users of is_errno().
authorAndre Noll <maan@systemlinux.org>
Thu, 11 Jun 2009 21:47:53 +0000 (23:47 +0200)
committerAndre Noll <maan@systemlinux.org>
Thu, 11 Jun 2009 21:47:53 +0000 (23:47 +0200)
errlist
fsck.c
osl.c
util.h

diff --git a/errlist b/errlist
index 728e3f8..b80c1ca 100644 (file)
--- a/errlist
+++ b/errlist
@@ -43,3 +43,5 @@ MKDIR                         "failed to create directory"
 RENAME                         "could not rename file"
 MUNMAP                         "munmap error"
 FSTAT                          "fstat error"
+DIR_EXISTS                     "directory exists"
+NOENT                          "no such file"
diff --git a/fsck.c b/fsck.c
index 357fbe7..e623b37 100644 (file)
--- a/fsck.c
+++ b/fsck.c
@@ -1062,12 +1062,12 @@ static int dump_rows(char *dump_dir, struct osl_table *t)
                        current_dir = make_message("%s/rows_%u-%u", dump_dir, i, i + 999);
                        NOTICE_LOG("dumping rows %u - %u\n", i, i + 999);
                        ret = osl_mkdir(current_dir, 0777);
-                       if (ret < 0 && !is_errno(-ret, EEXIST))
+                       if (ret < 0 && ret != -E_OSL_DIR_EXISTS)
                                goto out;
                }
                row_dir = make_message("%s/row_%03u", current_dir, i);
                ret = osl_mkdir(row_dir, 0777);
-               if (ret < 0 && !is_errno(-ret, EEXIST)) {
+               if (ret < 0 && ret != -E_OSL_DIR_EXISTS) {
                        free(row_dir);
                        goto out;
                }
@@ -1091,11 +1091,11 @@ static int dump_table(char *dump_dir, struct osl_table_description *desc)
        if (ret < 0)
                goto out;
        ret = osl_mkdir(dump_dir, 0777);
-       if (ret < 0 && !is_errno(-ret, EEXIST))
+       if (ret < 0 && ret != -E_OSL_DIR_EXISTS)
                goto out;
        table_dump_dir = make_message("%s/%s", dump_dir, desc->name);
        ret = osl_mkdir(table_dump_dir, 0777);
-       if (ret < 0 && !is_errno(-ret, EEXIST))
+       if (ret < 0 && ret != -E_OSL_DIR_EXISTS)
                goto out;
        desc_file = make_message("%s/table_description.c", table_dump_dir);
        ret = osl_open(desc_file, O_WRONLY | O_CREAT | O_EXCL, 0644);
diff --git a/osl.c b/osl.c
index 3f55ed4..eb1d24f 100644 (file)
--- a/osl.c
+++ b/osl.c
@@ -534,7 +534,7 @@ __export int osl_create_table(const struct osl_table_description *desc)
                        continue;
                if (!table_dir) {
                        ret = osl_mkdir(desc->dir, 0777);
-                       if (ret < 0 && !is_errno(-ret, EEXIST))
+                       if (ret < 0 && ret != -E_OSL_DIR_EXISTS)
                                goto out;
                        table_dir = make_message("%s/%s", desc->dir,
                                desc->name);
@@ -1111,7 +1111,7 @@ static int create_disk_storage_object_dir(const struct osl_table *t,
                return -E_OSL_NOMEM;
        ret = osl_mkdir(dirname, 0777);
        free(dirname);
-       if (ret < 0 && !is_errno(-ret, EEXIST))
+       if (ret < 0 && ret != -E_OSL_DIR_EXISTS)
                return ret;
        return 1;
 }
@@ -1178,15 +1178,15 @@ static int delete_disk_storage_file(const struct osl_table *t, unsigned col_num,
                const char *ds_name)
 {
        char *dirname, *filename = disk_storage_path(t, col_num, ds_name);
-       int ret, err;
+       int ret = 1;
 
        if (!filename)
                return -E_OSL_NOMEM;
-       ret = unlink(filename);
-       err = errno;
+       if (unlink(filename) < 0)
+               ret = errno == ENOENT? -E_OSL_NOENT : -E_OSL_UNLINK;
        free(filename);
        if (ret < 0)
-               return -E_OSL_UNLINK;
+               return ret;
        if (!(t->desc->flags & OSL_LARGE_TABLE))
                return 1;
        dirname = disk_storage_dirname(t, col_num, ds_name);
@@ -1563,7 +1563,7 @@ __export int osl_update_object(struct osl_table *t, const struct osl_row *r,
                if (ret < 0)
                        return ret;
                ret = delete_disk_storage_file(t, col_num, ds_name);
-               if (ret < 0 && !is_errno(-ret, ENOENT)) {
+               if (ret < 0 && ret != -E_OSL_NOENT) {
                        free(ds_name);
                        return ret;
                }
diff --git a/util.h b/util.h
index 53221c9..f4c26ad 100644 (file)
--- a/util.h
+++ b/util.h
@@ -26,7 +26,7 @@ static inline int osl_mkdir(const char *path, mode_t mode)
 {
        if (!mkdir(path, mode))
                return 1;
-       return -E_OSL_MKDIR;
+       return errno == EEXIST? -E_OSL_DIR_EXISTS : -E_OSL_MKDIR;
 }
 
 /**