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

Comparing libeio/eio.c (file contents):
Revision 1.72 by root, Fri Jun 10 12:45:20 2011 UTC vs.
Revision 1.76 by root, Tue Jul 5 09:24:12 2011 UTC

200/*****************************************************************************/ 200/*****************************************************************************/
201 201
202#define ETP_NUM_PRI (ETP_PRI_MAX - ETP_PRI_MIN + 1) 202#define ETP_NUM_PRI (ETP_PRI_MAX - ETP_PRI_MIN + 1)
203 203
204/* calculate time difference in ~1/EIO_TICKS of a second */ 204/* calculate time difference in ~1/EIO_TICKS of a second */
205ECB_INLINE int 205ecb_inline int
206tvdiff (struct timeval *tv1, struct timeval *tv2) 206tvdiff (struct timeval *tv1, struct timeval *tv2)
207{ 207{
208 return (tv2->tv_sec - tv1->tv_sec ) * EIO_TICKS 208 return (tv2->tv_sec - tv1->tv_sec ) * EIO_TICKS
209 + ((tv2->tv_usec - tv1->tv_usec) >> 10); 209 + ((tv2->tv_usec - tv1->tv_usec) >> 10);
210} 210}
835} 835}
836 836
837/*****************************************************************************/ 837/*****************************************************************************/
838/* work around various missing functions */ 838/* work around various missing functions */
839 839
840#if _POSIX_VERSION < 200809L
841# define realpath(path,resolved_path) (errno = ENOSYS, 0)
842#endif
843
840#if !HAVE_PREADWRITE 844#if !HAVE_PREADWRITE
841# undef pread 845# undef pread
842# undef pwrite 846# undef pwrite
843# define pread eio__pread 847# define pread eio__pread
844# define pwrite eio__pwrite 848# define pwrite eio__pwrite
1006 1010
1007 /* according to source inspection, this is correct, and useful behaviour */ 1011 /* according to source inspection, this is correct, and useful behaviour */
1008 if (sbytes) 1012 if (sbytes)
1009 res = sbytes; 1013 res = sbytes;
1010 1014
1011# elif defined (__APPLE__) 1015# elif defined (__APPLE__) && 0 /* broken, as everything on os x */
1012 off_t sbytes = count; 1016 off_t sbytes = count;
1013 res = sendfile (ifd, ofd, offset, &sbytes, 0, 0); 1017 res = sendfile (ifd, ofd, offset, &sbytes, 0, 0);
1014 1018
1015 /* according to the manpage, sbytes is always valid */ 1019 /* according to the manpage, sbytes is always valid */
1016 if (sbytes) 1020 if (sbytes)
1305 flags &= ~(EIO_READDIR_DIRS_FIRST | EIO_READDIR_STAT_ORDER); 1309 flags &= ~(EIO_READDIR_DIRS_FIRST | EIO_READDIR_STAT_ORDER);
1306 1310
1307 X_LOCK (wrklock); 1311 X_LOCK (wrklock);
1308 /* the corresponding closedir is in ETP_WORKER_CLEAR */ 1312 /* the corresponding closedir is in ETP_WORKER_CLEAR */
1309 self->dirp = dirp = opendir (req->ptr1); 1313 self->dirp = dirp = opendir (req->ptr1);
1314
1315 if (req->flags & EIO_FLAG_PTR1_FREE)
1316 free (req->ptr1);
1310 1317
1311 req->flags |= EIO_FLAG_PTR1_FREE | EIO_FLAG_PTR2_FREE; 1318 req->flags |= EIO_FLAG_PTR1_FREE | EIO_FLAG_PTR2_FREE;
1312 req->ptr1 = dents = flags ? malloc (dentalloc * sizeof (eio_dirent)) : 0; 1319 req->ptr1 = dents = flags ? malloc (dentalloc * sizeof (eio_dirent)) : 0;
1313 req->ptr2 = names = malloc (namesalloc); 1320 req->ptr2 = names = malloc (namesalloc);
1314 X_UNLOCK (wrklock); 1321 X_UNLOCK (wrklock);
1695eio_init (void (*want_poll)(void), void (*done_poll)(void)) 1702eio_init (void (*want_poll)(void), void (*done_poll)(void))
1696{ 1703{
1697 return etp_init (want_poll, done_poll); 1704 return etp_init (want_poll, done_poll);
1698} 1705}
1699 1706
1700ECB_INLINE void 1707ecb_inline void
1701eio_api_destroy (eio_req *req) 1708eio_api_destroy (eio_req *req)
1702{ 1709{
1703 free (req); 1710 free (req);
1704} 1711}
1705 1712
1771 case EIO_RENAME: req->result = rename (req->ptr1, req->ptr2); break; 1778 case EIO_RENAME: req->result = rename (req->ptr1, req->ptr2); break;
1772 case EIO_LINK: req->result = link (req->ptr1, req->ptr2); break; 1779 case EIO_LINK: req->result = link (req->ptr1, req->ptr2); break;
1773 case EIO_SYMLINK: req->result = symlink (req->ptr1, req->ptr2); break; 1780 case EIO_SYMLINK: req->result = symlink (req->ptr1, req->ptr2); break;
1774 case EIO_MKNOD: req->result = mknod (req->ptr1, (mode_t)req->int2, (dev_t)req->offs); break; 1781 case EIO_MKNOD: req->result = mknod (req->ptr1, (mode_t)req->int2, (dev_t)req->offs); break;
1775 1782
1783 case EIO_REALPATH: req->flags |= EIO_FLAG_PTR2_FREE;
1784 req->ptr2 = realpath (req->ptr1, 0);
1785 req->result = req->ptr2 ? strlen (req->ptr2) : -1;
1786 break;
1787
1776 case EIO_READLINK: ALLOC (PATH_MAX); 1788 case EIO_READLINK: ALLOC (PATH_MAX);
1777 req->result = readlink (req->ptr1, req->ptr2, PATH_MAX); break; 1789 req->result = readlink (req->ptr1, req->ptr2, PATH_MAX); break;
1778 1790
1779 case EIO_SYNC: req->result = 0; sync (); break; 1791 case EIO_SYNC: req->result = 0; sync (); break;
1780 case EIO_FSYNC: req->result = fsync (req->int1); break; 1792 case EIO_FSYNC: req->result = fsync (req->int1); break;
1997eio_req *eio_readlink (const char *path, int pri, eio_cb cb, void *data) 2009eio_req *eio_readlink (const char *path, int pri, eio_cb cb, void *data)
1998{ 2010{
1999 return eio__1path (EIO_READLINK, path, pri, cb, data); 2011 return eio__1path (EIO_READLINK, path, pri, cb, data);
2000} 2012}
2001 2013
2014eio_req *eio_realpath (const char *path, int pri, eio_cb cb, void *data)
2015{
2016 return eio__1path (EIO_REALPATH, path, pri, cb, data);
2017}
2018
2002eio_req *eio_stat (const char *path, int pri, eio_cb cb, void *data) 2019eio_req *eio_stat (const char *path, int pri, eio_cb cb, void *data)
2003{ 2020{
2004 return eio__1path (EIO_STAT, path, pri, cb, data); 2021 return eio__1path (EIO_STAT, path, pri, cb, data);
2005} 2022}
2006 2023

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines