#include "osl.h"
#include "error.h"
#include "fd.h"
-#include "list.h"
#include "osl_core.h"
/* Taken from Drepper: How to write shared libraries, Appendix B. */
return msgstr.str + errmsgidx[num];
}
-int loglevel;
+int loglevel = 0;
static void __attribute ((constructor)) init_loglevel(void)
{
{
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;
}
return ret;
}
-/**
- * A wrapper for truncate(2)
- *
- * \param path Name of the regular file to truncate
- * \param size Number of bytes to \b shave \b off
- *
- * Truncate the regular file named by \a path by \a size bytes.
- *
- * \return Standard.
- *
- * \sa truncate(2)
- */
-int para_truncate(const char *path, off_t size)
-{
- int ret;
- struct stat statbuf;
-
- ret = -E_OSL_STAT;
- if (stat(path, &statbuf) < 0)
- goto out;
- ret = -E_OSL_BAD_SIZE;
- if (statbuf.st_size < size)
- goto out;
- ret = -E_OSL_TRUNC;
- if (truncate(path, statbuf.st_size - size) < 0)
- goto out;
- ret = 1;
-out:
- return ret;
-}
-
static int truncate_mapped_file(const struct osl_table *t, unsigned col_num,
off_t size)
{
if (!filename)
return -ERRNO_TO_ERROR(ENOMEM);
- ret = para_truncate(filename, size);
+ ret = truncate_file(filename, size);
free(filename);
return ret;
}
if (ret < 0) { /* truncate index and rollback changes */
char *filename = index_filename(t->desc);
if (filename)
- para_truncate(filename, t->row_index_size);
+ truncate_file(filename, t->row_index_size);
free(filename);
goto rollback;
}