--- libeio/eio.c 2011/06/10 12:45:20 1.72 +++ libeio/eio.c 2011/07/05 09:24:12 1.76 @@ -202,7 +202,7 @@ #define ETP_NUM_PRI (ETP_PRI_MAX - ETP_PRI_MIN + 1) /* calculate time difference in ~1/EIO_TICKS of a second */ -ECB_INLINE int +ecb_inline int tvdiff (struct timeval *tv1, struct timeval *tv2) { return (tv2->tv_sec - tv1->tv_sec ) * EIO_TICKS @@ -837,6 +837,10 @@ /*****************************************************************************/ /* work around various missing functions */ +#if _POSIX_VERSION < 200809L +# define realpath(path,resolved_path) (errno = ENOSYS, 0) +#endif + #if !HAVE_PREADWRITE # undef pread # undef pwrite @@ -1008,7 +1012,7 @@ if (sbytes) res = sbytes; -# elif defined (__APPLE__) +# elif defined (__APPLE__) && 0 /* broken, as everything on os x */ off_t sbytes = count; res = sendfile (ifd, ofd, offset, &sbytes, 0, 0); @@ -1308,6 +1312,9 @@ /* the corresponding closedir is in ETP_WORKER_CLEAR */ self->dirp = dirp = opendir (req->ptr1); + if (req->flags & EIO_FLAG_PTR1_FREE) + free (req->ptr1); + req->flags |= EIO_FLAG_PTR1_FREE | EIO_FLAG_PTR2_FREE; req->ptr1 = dents = flags ? malloc (dentalloc * sizeof (eio_dirent)) : 0; req->ptr2 = names = malloc (namesalloc); @@ -1697,7 +1704,7 @@ return etp_init (want_poll, done_poll); } -ECB_INLINE void +ecb_inline void eio_api_destroy (eio_req *req) { free (req); @@ -1773,6 +1780,11 @@ case EIO_SYMLINK: req->result = symlink (req->ptr1, req->ptr2); break; case EIO_MKNOD: req->result = mknod (req->ptr1, (mode_t)req->int2, (dev_t)req->offs); break; + case EIO_REALPATH: req->flags |= EIO_FLAG_PTR2_FREE; + req->ptr2 = realpath (req->ptr1, 0); + req->result = req->ptr2 ? strlen (req->ptr2) : -1; + break; + case EIO_READLINK: ALLOC (PATH_MAX); req->result = readlink (req->ptr1, req->ptr2, PATH_MAX); break; @@ -1999,6 +2011,11 @@ return eio__1path (EIO_READLINK, path, pri, cb, data); } +eio_req *eio_realpath (const char *path, int pri, eio_cb cb, void *data) +{ + return eio__1path (EIO_REALPATH, path, pri, cb, data); +} + eio_req *eio_stat (const char *path, int pri, eio_cb cb, void *data) { return eio__1path (EIO_STAT, path, pri, cb, data);