ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libeio/eio.c
(Generate patch)

Comparing libeio/eio.c (file contents):
Revision 1.96 by root, Tue Jul 19 05:20:36 2011 UTC vs.
Revision 1.97 by root, Sun Jul 24 03:32:54 2011 UTC

216# else 216# else
217# error sendfile support requested but not available 217# error sendfile support requested but not available
218# endif 218# endif
219#endif 219#endif
220 220
221#if HAVE_SYS_SYSCALL_H
222# include <sys/syscall.h>
223#endif
224
221#ifndef D_TYPE 225#ifndef D_TYPE
222# define D_TYPE(de) 0 226# define D_TYPE(de) 0
223#endif 227#endif
224#ifndef D_INO 228#ifndef D_INO
225# define D_INO(de) 0 229# define D_INO(de) 0
936 940
937#if !HAVE_FDATASYNC 941#if !HAVE_FDATASYNC
938# undef fdatasync 942# undef fdatasync
939# define fdatasync(fd) fsync (fd) 943# define fdatasync(fd) fsync (fd)
940#endif 944#endif
945
946static int
947eio__syncfs (int fd)
948{
949 int res;
950
951#if HAVE_SYS_SYNCFS
952 res = (int)syscall (__NR_syncfs, (int)(fd));
953#else
954 res = -1;
955 errno = ENOSYS;
956#endif
957
958 if (res < 0 && errno == ENOSYS && fd >= 0)
959 sync ();
960
961 return res;
962}
941 963
942/* sync_file_range always needs emulation */ 964/* sync_file_range always needs emulation */
943static int 965static int
944eio__sync_file_range (int fd, off_t offset, size_t nbytes, unsigned int flags) 966eio__sync_file_range (int fd, off_t offset, size_t nbytes, unsigned int flags)
945{ 967{
2067 req->result = readlink (req->ptr1, req->ptr2, PATH_MAX); break; 2089 req->result = readlink (req->ptr1, req->ptr2, PATH_MAX); break;
2068 2090
2069 case EIO_SYNC: req->result = 0; sync (); break; 2091 case EIO_SYNC: req->result = 0; sync (); break;
2070 case EIO_FSYNC: req->result = fsync (req->int1); break; 2092 case EIO_FSYNC: req->result = fsync (req->int1); break;
2071 case EIO_FDATASYNC: req->result = fdatasync (req->int1); break; 2093 case EIO_FDATASYNC: req->result = fdatasync (req->int1); break;
2094 case EIO_SYNCFS: req->result = eio__syncfs (req->int1); break;
2095 case EIO_SYNC_FILE_RANGE: req->result = eio__sync_file_range (req->int1, req->offs, req->size, req->int2); break;
2072 case EIO_MSYNC: req->result = eio__msync (req->ptr2, req->size, req->int1); break; 2096 case EIO_MSYNC: req->result = eio__msync (req->ptr2, req->size, req->int1); break;
2073 case EIO_MTOUCH: req->result = eio__mtouch (req); break; 2097 case EIO_MTOUCH: req->result = eio__mtouch (req); break;
2074 case EIO_MLOCK: req->result = eio__mlock (req->ptr2, req->size); break; 2098 case EIO_MLOCK: req->result = eio__mlock (req->ptr2, req->size); break;
2075 case EIO_MLOCKALL: req->result = eio__mlockall (req->int1); break; 2099 case EIO_MLOCKALL: req->result = eio__mlockall (req->int1); break;
2076 case EIO_SYNC_FILE_RANGE: req->result = eio__sync_file_range (req->int1, req->offs, req->size, req->int2); break;
2077 case EIO_FALLOCATE: req->result = eio__fallocate (req->int1, req->int2, req->offs, req->size); break; 2100 case EIO_FALLOCATE: req->result = eio__fallocate (req->int1, req->int2, req->offs, req->size); break;
2078 2101
2079 case EIO_READDIR: eio__scandir (req, self); break; 2102 case EIO_READDIR: eio__scandir (req, self); break;
2080 2103
2081 case EIO_BUSY: 2104 case EIO_BUSY:
2162eio_req *eio_msync (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data) 2185eio_req *eio_msync (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data)
2163{ 2186{
2164 REQ (EIO_MSYNC); req->ptr2 = addr; req->size = length; req->int1 = flags; SEND; 2187 REQ (EIO_MSYNC); req->ptr2 = addr; req->size = length; req->int1 = flags; SEND;
2165} 2188}
2166 2189
2190eio_req *eio_fdatasync (int fd, int pri, eio_cb cb, void *data)
2191{
2192 REQ (EIO_FDATASYNC); req->int1 = fd; SEND;
2193}
2194
2195eio_req *eio_syncfs (int fd, int pri, eio_cb cb, void *data)
2196{
2197 REQ (EIO_SYNCFS); req->int1 = fd; SEND;
2198}
2199
2200eio_req *eio_sync_file_range (int fd, off_t offset, size_t nbytes, unsigned int flags, int pri, eio_cb cb, void *data)
2201{
2202 REQ (EIO_SYNC_FILE_RANGE); req->int1 = fd; req->offs = offset; req->size = nbytes; req->int2 = flags; SEND;
2203}
2204
2167eio_req *eio_mtouch (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data) 2205eio_req *eio_mtouch (void *addr, size_t length, int flags, int pri, eio_cb cb, void *data)
2168{ 2206{
2169 REQ (EIO_MTOUCH); req->ptr2 = addr; req->size = length; req->int1 = flags; SEND; 2207 REQ (EIO_MTOUCH); req->ptr2 = addr; req->size = length; req->int1 = flags; SEND;
2170} 2208}
2171 2209
2177eio_req *eio_mlockall (int flags, int pri, eio_cb cb, void *data) 2215eio_req *eio_mlockall (int flags, int pri, eio_cb cb, void *data)
2178{ 2216{
2179 REQ (EIO_MLOCKALL); req->int1 = flags; SEND; 2217 REQ (EIO_MLOCKALL); req->int1 = flags; SEND;
2180} 2218}
2181 2219
2182eio_req *eio_sync_file_range (int fd, off_t offset, size_t nbytes, unsigned int flags, int pri, eio_cb cb, void *data)
2183{
2184 REQ (EIO_SYNC_FILE_RANGE); req->int1 = fd; req->offs = offset; req->size = nbytes; req->int2 = flags; SEND;
2185}
2186
2187eio_req *eio_fallocate (int fd, int mode, off_t offset, size_t len, int pri, eio_cb cb, void *data) 2220eio_req *eio_fallocate (int fd, int mode, off_t offset, size_t len, int pri, eio_cb cb, void *data)
2188{ 2221{
2189 REQ (EIO_FALLOCATE); req->int1 = fd; req->int2 = mode; req->offs = offset; req->size = len; SEND; 2222 REQ (EIO_FALLOCATE); req->int1 = fd; req->int2 = mode; req->offs = offset; req->size = len; SEND;
2190}
2191
2192eio_req *eio_fdatasync (int fd, int pri, eio_cb cb, void *data)
2193{
2194 REQ (EIO_FDATASYNC); req->int1 = fd; SEND;
2195} 2223}
2196 2224
2197eio_req *eio_close (int fd, int pri, eio_cb cb, void *data) 2225eio_req *eio_close (int fd, int pri, eio_cb cb, void *data)
2198{ 2226{
2199 REQ (EIO_CLOSE); req->int1 = fd; SEND; 2227 REQ (EIO_CLOSE); req->int1 = fd; SEND;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines