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

Comparing libeio/eio.c (file contents):
Revision 1.86 by root, Thu Jul 14 18:30:10 2011 UTC vs.
Revision 1.88 by root, Thu Jul 14 19:31:43 2011 UTC

98 98
99#ifdef _WIN32 99#ifdef _WIN32
100 100
101 #define PAGESIZE 4096 /* GetSystemInfo? */ 101 #define PAGESIZE 4096 /* GetSystemInfo? */
102 102
103 #ifdef EIO_STRUCT_STATI64
103 #define stat(path,buf) _stati64 (path,buf) 104 #define stat(path,buf) _stati64 (path,buf)
105 #define fstat(fd,buf) _fstati64 (path,buf)
106 #endif
104 #define lstat(path,buf) stat (path,buf) 107 #define lstat(path,buf) stat (path,buf)
105 #define fstat(fd,buf) _fstati64 (path,buf)
106 #define fsync(fd) (FlushFileBuffers (EIO_FD_TO_WIN32_HANDLE (fd)) ? 0 : EIO_ERRNO (EBADF, -1)) 108 #define fsync(fd) (FlushFileBuffers (EIO_FD_TO_WIN32_HANDLE (fd)) ? 0 : EIO_ERRNO (EBADF, -1))
107 #define mkdir(path,mode) _mkdir (path) 109 #define mkdir(path,mode) _mkdir (path)
108 #define link(old,neu) (CreateHardLink (neu, old, 0) ? 0 : EIO_ERRNO (ENOENT, -1)) 110 #define link(old,neu) (CreateHardLink (neu, old, 0) ? 0 : EIO_ERRNO (ENOENT, -1))
109 111
110 #define chown(path,uid,gid) EIO_ENOSYS () 112 #define chown(path,uid,gid) EIO_ENOSYS ()
876# undef pread 878# undef pread
877# undef pwrite 879# undef pwrite
878# define pread eio__pread 880# define pread eio__pread
879# define pwrite eio__pwrite 881# define pwrite eio__pwrite
880 882
881static ssize_t 883static eio_ssize_t
882eio__pread (int fd, void *buf, size_t count, off_t offset) 884eio__pread (int fd, void *buf, size_t count, off_t offset)
883{ 885{
884 ssize_t res; 886 eio_ssize_t res;
885 off_t ooffset; 887 off_t ooffset;
886 888
887 X_LOCK (preadwritelock); 889 X_LOCK (preadwritelock);
888 ooffset = lseek (fd, 0, SEEK_CUR); 890 ooffset = lseek (fd, 0, SEEK_CUR);
889 lseek (fd, offset, SEEK_SET); 891 lseek (fd, offset, SEEK_SET);
892 X_UNLOCK (preadwritelock); 894 X_UNLOCK (preadwritelock);
893 895
894 return res; 896 return res;
895} 897}
896 898
897static ssize_t 899static eio_ssize_t
898eio__pwrite (int fd, void *buf, size_t count, off_t offset) 900eio__pwrite (int fd, void *buf, size_t count, off_t offset)
899{ 901{
900 ssize_t res; 902 eio_ssize_t res;
901 off_t ooffset; 903 off_t ooffset;
902 904
903 X_LOCK (preadwritelock); 905 X_LOCK (preadwritelock);
904 ooffset = lseek (fd, 0, SEEK_CUR); 906 ooffset = lseek (fd, 0, SEEK_CUR);
905 lseek (fd, offset, SEEK_SET); 907 lseek (fd, offset, SEEK_SET);
994 996
995#if !HAVE_READAHEAD 997#if !HAVE_READAHEAD
996# undef readahead 998# undef readahead
997# define readahead(fd,offset,count) eio__readahead (fd, offset, count, self) 999# define readahead(fd,offset,count) eio__readahead (fd, offset, count, self)
998 1000
999static ssize_t 1001static eio_ssize_t
1000eio__readahead (int fd, off_t offset, size_t count, etp_worker *self) 1002eio__readahead (int fd, off_t offset, size_t count, etp_worker *self)
1001{ 1003{
1002 size_t todo = count; 1004 size_t todo = count;
1003 dBUF; 1005 dBUF;
1004 1006
1016} 1018}
1017 1019
1018#endif 1020#endif
1019 1021
1020/* sendfile always needs emulation */ 1022/* sendfile always needs emulation */
1021static ssize_t 1023static eio_ssize_t
1022eio__sendfile (int ofd, int ifd, off_t offset, size_t count, etp_worker *self) 1024eio__sendfile (int ofd, int ifd, off_t offset, size_t count, etp_worker *self)
1023{ 1025{
1024 ssize_t written = 0; 1026 eio_ssize_t written = 0;
1025 ssize_t res; 1027 eio_ssize_t res;
1026 1028
1027 if (!count) 1029 if (!count)
1028 return 0; 1030 return 0;
1029 1031
1030 for (;;) 1032 for (;;)
1139 1141
1140 res = 0; 1142 res = 0;
1141 1143
1142 while (count) 1144 while (count)
1143 { 1145 {
1144 ssize_t cnt; 1146 eio_ssize_t cnt;
1145 1147
1146 cnt = pread (ifd, eio_buf, count > EIO_BUFSIZE ? EIO_BUFSIZE : count, offset); 1148 cnt = pread (ifd, eio_buf, count > EIO_BUFSIZE ? EIO_BUFSIZE : count, offset);
1147 1149
1148 if (cnt <= 0) 1150 if (cnt <= 0)
1149 { 1151 {
1357 res += strlen (res); 1359 res += strlen (res);
1358 } 1360 }
1359 1361
1360 while (*rel) 1362 while (*rel)
1361 { 1363 {
1362 ssize_t len, linklen; 1364 eio_ssize_t len, linklen;
1363 char *beg = rel; 1365 char *beg = rel;
1364 1366
1365 while (*rel && *rel != '/') 1367 while (*rel && *rel != '/')
1366 ++rel; 1368 ++rel;
1367 1369
2178eio_req *eio_fchmod (int fd, mode_t mode, int pri, eio_cb cb, void *data) 2180eio_req *eio_fchmod (int fd, mode_t mode, int pri, eio_cb cb, void *data)
2179{ 2181{
2180 REQ (EIO_FCHMOD); req->int1 = fd; req->int2 = (long)mode; SEND; 2182 REQ (EIO_FCHMOD); req->int1 = fd; req->int2 = (long)mode; SEND;
2181} 2183}
2182 2184
2183eio_req *eio_fchown (int fd, uid_t uid, gid_t gid, int pri, eio_cb cb, void *data) 2185eio_req *eio_fchown (int fd, eio_uid_t uid, eio_gid_t gid, int pri, eio_cb cb, void *data)
2184{ 2186{
2185 REQ (EIO_FCHOWN); req->int1 = fd; req->int2 = (long)uid; req->int3 = (long)gid; SEND; 2187 REQ (EIO_FCHOWN); req->int1 = fd; req->int2 = (long)uid; req->int3 = (long)gid; SEND;
2186} 2188}
2187 2189
2188eio_req *eio_dup2 (int fd, int fd2, int pri, eio_cb cb, void *data) 2190eio_req *eio_dup2 (int fd, int fd2, int pri, eio_cb cb, void *data)
2208eio_req *eio_truncate (const char *path, off_t offset, int pri, eio_cb cb, void *data) 2210eio_req *eio_truncate (const char *path, off_t offset, int pri, eio_cb cb, void *data)
2209{ 2211{
2210 REQ (EIO_TRUNCATE); PATH; req->offs = offset; SEND; 2212 REQ (EIO_TRUNCATE); PATH; req->offs = offset; SEND;
2211} 2213}
2212 2214
2213eio_req *eio_chown (const char *path, uid_t uid, gid_t gid, int pri, eio_cb cb, void *data) 2215eio_req *eio_chown (const char *path, eio_uid_t uid, eio_gid_t gid, int pri, eio_cb cb, void *data)
2214{ 2216{
2215 REQ (EIO_CHOWN); PATH; req->int2 = (long)uid; req->int3 = (long)gid; SEND; 2217 REQ (EIO_CHOWN); PATH; req->int2 = (long)uid; req->int3 = (long)gid; SEND;
2216} 2218}
2217 2219
2218eio_req *eio_chmod (const char *path, mode_t mode, int pri, eio_cb cb, void *data) 2220eio_req *eio_chmod (const char *path, mode_t mode, int pri, eio_cb cb, void *data)
2365} 2367}
2366 2368
2367/*****************************************************************************/ 2369/*****************************************************************************/
2368/* misc garbage */ 2370/* misc garbage */
2369 2371
2370ssize_t 2372eio_ssize_t
2371eio_sendfile_sync (int ofd, int ifd, off_t offset, size_t count) 2373eio_sendfile_sync (int ofd, int ifd, off_t offset, size_t count)
2372{ 2374{
2373 etp_worker wrk; 2375 etp_worker wrk;
2374 ssize_t ret; 2376 eio_ssize_t ret;
2375 2377
2376 wrk.dbuf = 0; 2378 wrk.dbuf = 0;
2377 2379
2378 ret = eio__sendfile (ofd, ifd, offset, count, &wrk); 2380 ret = eio__sendfile (ofd, ifd, offset, count, &wrk);
2379 2381

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines