From: Martin Mares Date: Thu, 9 Feb 2012 22:02:17 +0000 (+0100) Subject: Moved ucw/lfs.h to ucw/io.h X-Git-Tag: v5.0~89 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=315d65b74168b23e820b9dde6166ec19bd048228;p=libucw.git Moved ucw/lfs.h to ucw/io.h More I/O functions will follow. --- diff --git a/ucw/Makefile b/ucw/Makefile index bf123268..6c44266b 100644 --- a/ucw/Makefile +++ b/ucw/Makefile @@ -48,7 +48,7 @@ LIBUCW_MAIN_INCLUDES= \ prime.h \ bitops.h \ conf.h getopt.h ipaccess.h \ - fastbuf.h lfs.h ff-unicode.h ff-binary.h \ + fastbuf.h io.h ff-unicode.h ff-binary.h \ url.h \ mainloop.h \ lizard.h \ diff --git a/ucw/doc/index.txt b/ucw/doc/index.txt index 4a14d521..30e3a182 100644 --- a/ucw/doc/index.txt +++ b/ucw/doc/index.txt @@ -65,7 +65,7 @@ Yet undocumented modules * `wildmatch.h` - File manipulation * `asio.h` - * `lfs.h` + * `io.h` * `partmap.h` - Address manipulation * `url.h` diff --git a/ucw/fb-atomic.c b/ucw/fb-atomic.c index 32c9ca9b..8b454485 100644 --- a/ucw/fb-atomic.c +++ b/ucw/fb-atomic.c @@ -9,7 +9,7 @@ #include "ucw/lib.h" #include "ucw/fastbuf.h" -#include "ucw/lfs.h" +#include "ucw/io.h" #include "ucw/conf.h" #include diff --git a/ucw/fb-direct.c b/ucw/fb-direct.c index 1e2dfd89..af49f8ce 100644 --- a/ucw/fb-direct.c +++ b/ucw/fb-direct.c @@ -27,7 +27,7 @@ #include "ucw/lib.h" #include "ucw/fastbuf.h" -#include "ucw/lfs.h" +#include "ucw/io.h" #include "ucw/asio.h" #include "ucw/conf.h" #include "ucw/threads.h" diff --git a/ucw/fb-file.c b/ucw/fb-file.c index 3eb2996f..77bf03cb 100644 --- a/ucw/fb-file.c +++ b/ucw/fb-file.c @@ -10,7 +10,7 @@ #include "ucw/lib.h" #include "ucw/fastbuf.h" -#include "ucw/lfs.h" +#include "ucw/io.h" #include #include diff --git a/ucw/fb-mmap.c b/ucw/fb-mmap.c index 747b4286..2a8b5372 100644 --- a/ucw/fb-mmap.c +++ b/ucw/fb-mmap.c @@ -11,7 +11,7 @@ #include "ucw/lib.h" #include "ucw/fastbuf.h" -#include "ucw/lfs.h" +#include "ucw/io.h" #include "ucw/conf.h" #include diff --git a/ucw/fb-param.c b/ucw/fb-param.c index 22f988c6..528765cb 100644 --- a/ucw/fb-param.c +++ b/ucw/fb-param.c @@ -10,7 +10,7 @@ #include "ucw/lib.h" #include "ucw/conf.h" -#include "ucw/lfs.h" +#include "ucw/io.h" #include "ucw/fastbuf.h" #include diff --git a/ucw/io.h b/ucw/io.h new file mode 100644 index 00000000..593dcf7d --- /dev/null +++ b/ucw/io.h @@ -0,0 +1,63 @@ +/* + * UCW Library -- Large File Support + * + * (c) 1999--2002 Martin Mares + * + * This software may be freely distributed and used according to the terms + * of the GNU Lesser General Public License. + */ + +#ifndef _UCW_LFS_H +#define _UCW_LFS_H + +#include +#include + +#ifdef CONFIG_LFS + +#define ucw_open open64 +#define ucw_seek lseek64 +#define ucw_pread pread64 +#define ucw_pwrite pwrite64 +#define ucw_ftruncate ftruncate64 +#define ucw_mmap(a,l,p,f,d,o) mmap64(a,l,p,f,d,o) +#define ucw_pread pread64 +#define ucw_pwrite pwrite64 +#define ucw_stat stat64 +#define ucw_fstat fstat64 +typedef struct stat64 ucw_stat_t; + +#else /* !CONFIG_LFS */ + +#define ucw_open open +#define ucw_seek(f,o,w) lseek(f,o,w) +#define ucw_ftruncate(f,o) ftruncate(f,o) +#define ucw_mmap(a,l,p,f,d,o) mmap(a,l,p,f,d,o) +#define ucw_pread pread +#define ucw_pwrite pwrite +#define ucw_stat stat +#define ucw_fstat fstat +typedef struct stat ucw_stat_t; + +#endif /* !CONFIG_LFS */ + +#if defined(_POSIX_SYNCHRONIZED_IO) && (_POSIX_SYNCHRONIZED_IO > 0) +#define ucw_fdatasync fdatasync +#else +#define ucw_fdatasync fsync +#endif + +#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 */ diff --git a/ucw/lfs.h b/ucw/lfs.h deleted file mode 100644 index 593dcf7d..00000000 --- a/ucw/lfs.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * UCW Library -- Large File Support - * - * (c) 1999--2002 Martin Mares - * - * This software may be freely distributed and used according to the terms - * of the GNU Lesser General Public License. - */ - -#ifndef _UCW_LFS_H -#define _UCW_LFS_H - -#include -#include - -#ifdef CONFIG_LFS - -#define ucw_open open64 -#define ucw_seek lseek64 -#define ucw_pread pread64 -#define ucw_pwrite pwrite64 -#define ucw_ftruncate ftruncate64 -#define ucw_mmap(a,l,p,f,d,o) mmap64(a,l,p,f,d,o) -#define ucw_pread pread64 -#define ucw_pwrite pwrite64 -#define ucw_stat stat64 -#define ucw_fstat fstat64 -typedef struct stat64 ucw_stat_t; - -#else /* !CONFIG_LFS */ - -#define ucw_open open -#define ucw_seek(f,o,w) lseek(f,o,w) -#define ucw_ftruncate(f,o) ftruncate(f,o) -#define ucw_mmap(a,l,p,f,d,o) mmap(a,l,p,f,d,o) -#define ucw_pread pread -#define ucw_pwrite pwrite -#define ucw_stat stat -#define ucw_fstat fstat -typedef struct stat ucw_stat_t; - -#endif /* !CONFIG_LFS */ - -#if defined(_POSIX_SYNCHRONIZED_IO) && (_POSIX_SYNCHRONIZED_IO > 0) -#define ucw_fdatasync fdatasync -#else -#define ucw_fdatasync fsync -#endif - -#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 */ diff --git a/ucw/log-file.c b/ucw/log-file.c index 862b94c1..231344bd 100644 --- a/ucw/log-file.c +++ b/ucw/log-file.c @@ -11,7 +11,7 @@ #include "ucw/lib.h" #include "ucw/log.h" #include "ucw/log-internal.h" -#include "ucw/lfs.h" +#include "ucw/io.h" #include "ucw/threads.h" #include "ucw/simple-lists.h" diff --git a/ucw/partmap.c b/ucw/partmap.c index a823d3d1..fd9d9124 100644 --- a/ucw/partmap.c +++ b/ucw/partmap.c @@ -9,7 +9,7 @@ */ #include "ucw/lib.h" -#include "ucw/lfs.h" +#include "ucw/io.h" #include "ucw/partmap.h" #include diff --git a/ucw/sorter/debug/radix-asio-test.c b/ucw/sorter/debug/radix-asio-test.c index 168f6ff6..8e3368b0 100644 --- a/ucw/sorter/debug/radix-asio-test.c +++ b/ucw/sorter/debug/radix-asio-test.c @@ -6,7 +6,7 @@ #include "ucw/lib.h" #include "ucw/conf.h" -#include "ucw/lfs.h" +#include "ucw/io.h" #include "ucw/asio.h" #include diff --git a/ucw/sorter/debug/radix-file-test.c b/ucw/sorter/debug/radix-file-test.c index 46d1bb4c..11f32dd6 100644 --- a/ucw/sorter/debug/radix-file-test.c +++ b/ucw/sorter/debug/radix-file-test.c @@ -6,7 +6,7 @@ #include "ucw/lib.h" #include "ucw/conf.h" -#include "ucw/lfs.h" +#include "ucw/io.h" #include #include diff --git a/ucw/tempfile.c b/ucw/tempfile.c index 76d9cd38..f616990a 100644 --- a/ucw/tempfile.c +++ b/ucw/tempfile.c @@ -11,7 +11,7 @@ #include "ucw/lib.h" #include "ucw/conf.h" #include "ucw/threads.h" -#include "ucw/lfs.h" +#include "ucw/io.h" #include "ucw/fastbuf.h" #include