X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=ucw%2Fio.h;h=ac8c7ec67df834670e0f32293d564b3cbe5a3b26;hb=0eb6d8317cdbdb28663ff779d31684b3c7a47274;hp=593dcf7d727c196e8587ae7162263061fd610d9a;hpb=315d65b74168b23e820b9dde6166ec19bd048228;p=libucw.git diff --git a/ucw/io.h b/ucw/io.h index 593dcf7d..ac8c7ec6 100644 --- a/ucw/io.h +++ b/ucw/io.h @@ -7,13 +7,23 @@ * of the GNU Lesser General Public License. */ -#ifndef _UCW_LFS_H -#define _UCW_LFS_H +#ifndef _UCW_IO_H +#define _UCW_IO_H #include #include +#include +#include -#ifdef CONFIG_LFS +#ifdef CONFIG_UCW_CLEAN_ABI +#define careful_read ucw_careful_read +#define careful_write ucw_careful_write +#define mmap_file ucw_mmap_file +#define munmap_file ucw_munmap_file +#define sync_dir ucw_sync_dir +#endif + +#ifdef CONFIG_UCW_LARGE_FILES #define ucw_open open64 #define ucw_seek lseek64 @@ -27,7 +37,7 @@ #define ucw_fstat fstat64 typedef struct stat64 ucw_stat_t; -#else /* !CONFIG_LFS */ +#else /* !CONFIG_UCW_LARGE_FILES */ #define ucw_open open #define ucw_seek(f,o,w) lseek(f,o,w) @@ -39,7 +49,7 @@ typedef struct stat64 ucw_stat_t; #define ucw_fstat fstat typedef struct stat ucw_stat_t; -#endif /* !CONFIG_LFS */ +#endif /* !CONFIG_UCW_LARGE_FILES */ #if defined(_POSIX_SYNCHRONIZED_IO) && (_POSIX_SYNCHRONIZED_IO > 0) #define ucw_fdatasync fdatasync @@ -49,15 +59,22 @@ typedef struct stat ucw_stat_t; #define HAVE_PREAD -static inline ucw_off_t -ucw_file_size(const char *name) -{ - int fd = ucw_open(name, O_RDONLY); - if (fd < 0) - die("Cannot open %s: %m", name); - ucw_off_t len = ucw_seek(fd, 0, SEEK_END); - close(fd); - return len; -} - -#endif /* !_UCW_LFS_H */ +/* io-size.c */ + +ucw_off_t ucw_file_size(const char *name); + +/* io-mmap.c */ + +void *mmap_file(const char *name, size_t *len, int writeable); +void munmap_file(void *start, size_t len); + +/* io-careful.c */ + +int careful_read(int fd, void *buf, size_t len); +int careful_write(int fd, const void *buf, size_t len); + +/* io-sync.c */ + +void sync_dir(const char *name); + +#endif /* !_UCW_IO_H */