]> mj.ucw.cz Git - libucw.git/blob - ucw/io.h
Packages: install-ucw-sorter-api make target moved into install-libucw-api.
[libucw.git] / ucw / io.h
1 /*
2  *      UCW Library -- Large File Support
3  *
4  *      (c) 1999--2002 Martin Mares <mj@ucw.cz>
5  *
6  *      This software may be freely distributed and used according to the terms
7  *      of the GNU Lesser General Public License.
8  */
9
10 #ifndef _UCW_IO_H
11 #define _UCW_IO_H
12
13 #include <fcntl.h>
14 #include <unistd.h>
15
16 #ifdef CONFIG_UCW_CLEAN_ABI
17 #define careful_read ucw_careful_read
18 #define careful_write ucw_careful_write
19 #define mmap_file ucw_mmap_file
20 #define munmap_file ucw_munmap_file
21 #define sync_dir ucw_sync_dir
22 #endif
23
24 #ifdef CONFIG_UCW_LARGE_FILES
25
26 #define ucw_open open64
27 #define ucw_seek lseek64
28 #define ucw_pread pread64
29 #define ucw_pwrite pwrite64
30 #define ucw_ftruncate ftruncate64
31 #define ucw_mmap(a,l,p,f,d,o) mmap64(a,l,p,f,d,o)
32 #define ucw_pread pread64
33 #define ucw_pwrite pwrite64
34 #define ucw_stat stat64
35 #define ucw_fstat fstat64
36 typedef struct stat64 ucw_stat_t;
37
38 #else   /* !CONFIG_UCW_LARGE_FILES */
39
40 #define ucw_open open
41 #define ucw_seek(f,o,w) lseek(f,o,w)
42 #define ucw_ftruncate(f,o) ftruncate(f,o)
43 #define ucw_mmap(a,l,p,f,d,o) mmap(a,l,p,f,d,o)
44 #define ucw_pread pread
45 #define ucw_pwrite pwrite
46 #define ucw_stat stat
47 #define ucw_fstat fstat
48 typedef struct stat ucw_stat_t;
49
50 #endif  /* !CONFIG_UCW_LARGE_FILES */
51
52 #if defined(_POSIX_SYNCHRONIZED_IO) && (_POSIX_SYNCHRONIZED_IO > 0)
53 #define ucw_fdatasync fdatasync
54 #else
55 #define ucw_fdatasync fsync
56 #endif
57
58 #define HAVE_PREAD
59
60 /* io-size.c */
61
62 ucw_off_t ucw_file_size(const char *name);
63
64 /* io-mmap.c */
65
66 void *mmap_file(const char *name, unsigned *len, int writeable);
67 void munmap_file(void *start, unsigned len);
68
69 /* io-careful.c */
70
71 int careful_read(int fd, void *buf, int len);
72 int careful_write(int fd, const void *buf, int len);
73
74 /* io-sync.c */
75
76 void sync_dir(const char *name);
77
78 #endif  /* !_UCW_IO_H */