diff options
author | root <root> | 2011-07-05 09:24:11 +0000 |
---|---|---|
committer | root <root> | 2011-07-05 09:24:11 +0000 |
commit | c386664b94e2392f2d2cca35d7f8e9c6cb3c85c2 (patch) | |
tree | 5e82b156b8395dd502ff1028fb4cb1e2528030f4 | |
parent | f40f89e5846a01dba0a726a5f30fde548ad63c0c (diff) |
realpath
-rw-r--r-- | Changes | 1 | ||||
-rw-r--r-- | eio.c | 14 | ||||
-rw-r--r-- | eio.h | 3 | ||||
-rw-r--r-- | eio.pod | 6 |
4 files changed, 23 insertions, 1 deletions
@@ -49,4 +49,5 @@ TODO: fadvise request large transfers, using a heuristic. - use libecb, and apply lots of minor space optimisations. - disable sendfile on darwin, broken as everything else. + - add realpath function. @@ -837,6 +837,10 @@ int eio_poll (void) /*****************************************************************************/ /* 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 @@ -1776,6 +1780,11 @@ eio_execute (etp_worker *self, eio_req *req) 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; @@ -2002,6 +2011,11 @@ eio_req *eio_readlink (const char *path, int pri, eio_cb cb, void *data) 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); @@ -154,7 +154,7 @@ enum EIO_MLOCK, EIO_MLOCKALL, EIO_UNLINK, EIO_RMDIR, EIO_MKDIR, EIO_RENAME, EIO_MKNOD, EIO_READDIR, - EIO_LINK, EIO_SYMLINK, EIO_READLINK, + EIO_LINK, EIO_SYMLINK, EIO_READLINK, EIO_REALPATH, EIO_GROUP, EIO_NOP, EIO_BUSY }; @@ -284,6 +284,7 @@ eio_req *eio_readdir (const char *path, int flags, int pri, eio_cb cb, void *d eio_req *eio_rmdir (const char *path, int pri, eio_cb cb, void *data); eio_req *eio_unlink (const char *path, int pri, eio_cb cb, void *data); eio_req *eio_readlink (const char *path, int pri, eio_cb cb, void *data); /* result=ptr2 allocated dynamically */ +eio_req *eio_realpath (const char *path, int pri, eio_cb cb, void *data); /* result=ptr2 allocated dynamically */ eio_req *eio_stat (const char *path, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */ eio_req *eio_lstat (const char *path, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */ eio_req *eio_statvfs (const char *path, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */ @@ -322,6 +322,12 @@ C<< req->result >>. free (target); } +=item eio_realpath (const char *path, int pri, eio_cb cb, void *data) + +Similar to the realpath libc function, but unlike that one, result is +C<0> on failure and the length of the returned path in C<ptr2> - this is +similar to readlink. + =item eio_stat (const char *path, int pri, eio_cb cb, void *data) =item eio_lstat (const char *path, int pri, eio_cb cb, void *data) |