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

Comparing libeio/eio.c (file contents):
Revision 1.143 by root, Sat Dec 3 16:33:46 2016 UTC vs.
Revision 1.148 by root, Tue Feb 20 06:05:19 2018 UTC

1/* 1/*
2 * libeio implementation 2 * libeio implementation
3 * 3 *
4 * Copyright (c) 2007,2008,2009,2010,2011,2012,2013,2016 Marc Alexander Lehmann <libeio@schmorp.de> 4 * Copyright (c) 2007,2008,2009,2010,2011,2012,2013,2016,2017 Marc Alexander Lehmann <libeio@schmorp.de>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without modifica- 7 * Redistribution and use in source and binary forms, with or without modifica-
8 * tion, are permitted provided that the following conditions are met: 8 * tion, are permitted provided that the following conditions are met:
9 * 9 *
100#ifdef _WIN32 100#ifdef _WIN32
101 101
102 #undef PAGESIZE 102 #undef PAGESIZE
103 #define PAGESIZE 4096 /* GetSystemInfo? */ 103 #define PAGESIZE 4096 /* GetSystemInfo? */
104 104
105 #define O_CLOEXEC 0
106
105 /* TODO: look at how perl does stat (non-sloppy), unlink (ro-files), utime, link */ 107 /* TODO: look at how perl does stat (non-sloppy), unlink (ro-files), utime, link */
106 108
107 #ifdef EIO_STRUCT_STATI64 109 #ifdef EIO_STRUCT_STATI64
108 /* look at perl's non-sloppy stat */ 110 /* look at perl's non-sloppy stat */
109 #define stat(path,buf) _stati64 (path,buf) 111 #define stat(path,buf) _stati64 (path,buf)
231 #define D_NAME(entp) entp.cFileName 233 #define D_NAME(entp) entp.cFileName
232 #define D_TYPE(entp) (entp.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? DT_DIR : DT_REG) 234 #define D_TYPE(entp) (entp.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? DT_DIR : DT_REG)
233 235
234#else 236#else
235 237
238 #include <sys/ioctl.h>
236 #include <sys/time.h> 239 #include <sys/time.h>
237 #include <sys/select.h> 240 #include <sys/select.h>
238 #include <unistd.h> 241 #include <unistd.h>
239 #include <signal.h> 242 #include <signal.h>
240 #include <dirent.h> 243 #include <dirent.h>
299# else 302# else
300# error sendfile support requested but not available 303# error sendfile support requested but not available
301# endif 304# endif
302#endif 305#endif
303 306
307#if HAVE_RENAMEAT2
308# include <sys/syscall.h>
309# include <linux/fs.h>
310#endif
311
304#ifndef D_TYPE 312#ifndef D_TYPE
305# define D_TYPE(de) 0 313# define D_TYPE(de) 0
306#endif 314#endif
307#ifndef D_INO 315#ifndef D_INO
308# define D_INO(de) 0 316# define D_INO(de) 0
316# define NAME_MAX 4096 324# define NAME_MAX 4096
317#endif 325#endif
318 326
319/* used for readlink etc. */ 327/* used for readlink etc. */
320#ifndef PATH_MAX 328#ifndef PATH_MAX
321# define PATH_MAX 4096 329# define PATH_MAX 0
322#endif 330#endif
331
332#ifndef EIO_PATH_MIN
333# define EIO_PATH_MIN 8160
334#endif
335
336#define EIO_PATH_MAX (PATH_MAX <= EIO_PATH_MIN ? EIO_PATH_MIN : PATH_MAX)
323 337
324/* buffer size for various temporary buffers */ 338/* buffer size for various temporary buffers */
325#define EIO_BUFSIZE 65536 339#define EIO_BUFSIZE 65536
326 340
327#define dBUF \ 341#define dBUF \
541} 555}
542 556
543/*****************************************************************************/ 557/*****************************************************************************/
544/* work around various missing functions */ 558/* work around various missing functions */
545 559
560#if HAVE_POSIX_CLOSE && !__linux
561# define eio__close(fd) posix_close (fd, 0)
562#else
563# define eio__close(fd) close (fd)
564#endif
565
566/* close() without disturbing errno */
567static void
568silent_close (int fd)
569{
570 int saved_errno = errno;
571 eio__close (fd);
572 errno = saved_errno;
573}
574
546#ifndef HAVE_UTIMES 575#ifndef HAVE_UTIMES
547 576
548# undef utimes 577# undef utimes
549# define utimes(path,times) eio__utimes (path, times) 578# define utimes(path,times) eio__utimes (path, times)
550 579
974 1003
975 errno = ENOENT; 1004 errno = ENOENT;
976 if (!*rel) 1005 if (!*rel)
977 return -1; 1006 return -1;
978 1007
979 res = etp_tmpbuf_get (tmpbuf, PATH_MAX * 3); 1008 res = etp_tmpbuf_get (tmpbuf, EIO_PATH_MAX * 3);
980#ifdef _WIN32 1009#ifdef _WIN32
981 if (_access (rel, 4) != 0) 1010 if (_access (rel, 4) != 0)
982 return -1; 1011 return -1;
983 1012
984 symlinks = GetFullPathName (rel, PATH_MAX * 3, res, 0); 1013 symlinks = GetFullPathName (rel, EIO_PATH_MAX * 3, res, 0);
985 1014
986 errno = ENAMETOOLONG; 1015 errno = ENAMETOOLONG;
987 if (symlinks >= PATH_MAX * 3) 1016 if (symlinks >= EIO_PATH_MAX * 3)
988 return -1; 1017 return -1;
989 1018
990 errno = EIO; 1019 errno = EIO;
991 if (symlinks <= 0) 1020 if (symlinks <= 0)
992 return -1; 1021 return -1;
993 1022
994 return symlinks; 1023 return symlinks;
995 1024
996#else 1025#else
997 tmp1 = res + PATH_MAX; 1026 tmp1 = res + EIO_PATH_MAX;
998 tmp2 = tmp1 + PATH_MAX; 1027 tmp2 = tmp1 + EIO_PATH_MAX;
999 1028
1000#if 0 /* disabled, the musl way to do things is just too racy */ 1029#if 0 /* disabled, the musl way to do things is just too racy */
1001#if __linux && defined(O_NONBLOCK) && defined(O_NOATIME) 1030#if __linux && defined(O_NONBLOCK) && defined(O_NOATIME)
1002 /* on linux we may be able to ask the kernel */ 1031 /* on linux we may be able to ask the kernel */
1003 { 1032 {
1004 int fd = open (rel, O_RDONLY | O_NONBLOCK | O_NOCTTY | O_NOATIME); 1033 int fd = open (rel, O_RDONLY | O_NONBLOCK | O_NOCTTY | O_NOATIME);
1005 1034
1006 if (fd >= 0) 1035 if (fd >= 0)
1007 { 1036 {
1008 sprintf (tmp1, "/proc/self/fd/%d", fd); 1037 sprintf (tmp1, "/proc/self/fd/%d", fd);
1009 req->result = readlink (tmp1, res, PATH_MAX); 1038 req->result = readlink (tmp1, res, EIO_PATH_MAX);
1010 /* here we should probably stat the open file and the disk file, to make sure they still match */ 1039 /* here we should probably stat the open file and the disk file, to make sure they still match */
1011 close (fd); 1040 eio__close (fd);
1012 1041
1013 if (req->result > 0) 1042 if (req->result > 0)
1014 goto done; 1043 goto done;
1015 } 1044 }
1016 else if (errno == ELOOP || errno == ENAMETOOLONG || errno == ENOENT || errno == ENOTDIR || errno == EIO) 1045 else if (errno == ELOOP || errno == ENAMETOOLONG || errno == ENOENT || errno == ENOTDIR || errno == EIO)
1027 if (wd == EIO_INVALID_WD) 1056 if (wd == EIO_INVALID_WD)
1028 return -1; 1057 return -1;
1029 1058
1030 if (wd == EIO_CWD) 1059 if (wd == EIO_CWD)
1031 { 1060 {
1032 if (!getcwd (res, PATH_MAX)) 1061 if (!getcwd (res, EIO_PATH_MAX))
1033 return -1; 1062 return -1;
1034 1063
1035 len = strlen (res); 1064 len = strlen (res);
1036 } 1065 }
1037 else 1066 else
1084 1113
1085 /* zero-terminate, for readlink */ 1114 /* zero-terminate, for readlink */
1086 res [len + 1] = 0; 1115 res [len + 1] = 0;
1087 1116
1088 /* now check if it's a symlink */ 1117 /* now check if it's a symlink */
1089 linklen = readlink (tmpbuf->ptr, tmp1, PATH_MAX); 1118 linklen = readlink (tmpbuf->ptr, tmp1, EIO_PATH_MAX);
1090 1119
1091 if (linklen < 0) 1120 if (linklen < 0)
1092 { 1121 {
1093 if (errno != EINVAL) 1122 if (errno != EINVAL)
1094 return -1; 1123 return -1;
1100 { 1129 {
1101 /* yay, it was a symlink - build new path in tmp2 */ 1130 /* yay, it was a symlink - build new path in tmp2 */
1102 int rellen = strlen (rel); 1131 int rellen = strlen (rel);
1103 1132
1104 errno = ENAMETOOLONG; 1133 errno = ENAMETOOLONG;
1105 if (linklen + 1 + rellen >= PATH_MAX) 1134 if (linklen + 1 + rellen >= EIO_PATH_MAX) /* also catch linklen >= EIO_PATH_MAX */
1106 return -1; 1135 return -1;
1107 1136
1108 errno = ELOOP; 1137 errno = ELOOP;
1109 if (!--symlinks) 1138 if (!--symlinks)
1110 return -1; 1139 return -1;
1374 return; 1403 return;
1375 1404
1376 dirp = fdopendir (fd); 1405 dirp = fdopendir (fd);
1377 1406
1378 if (!dirp) 1407 if (!dirp)
1379 close (fd); 1408 silent_close (fd);
1380 } 1409 }
1381 else 1410 else
1382 dirp = opendir (req->ptr1); 1411 dirp = opendir (req->ptr1);
1383 #else 1412 #else
1384 dirp = opendir (wd_expand (&self->tmpbuf, req->wd, req->ptr1)); 1413 dirp = opendir (wd_expand (&self->tmpbuf, req->wd, req->ptr1));
1663eio_wd_close_sync (eio_wd wd) 1692eio_wd_close_sync (eio_wd wd)
1664{ 1693{
1665 if (wd != EIO_INVALID_WD && wd != EIO_CWD) 1694 if (wd != EIO_INVALID_WD && wd != EIO_CWD)
1666 { 1695 {
1667 #if HAVE_AT 1696 #if HAVE_AT
1668 close (wd->fd); 1697 eio__close (wd->fd);
1669 #endif 1698 #endif
1670 free (wd); 1699 free (wd);
1671 } 1700 }
1672} 1701}
1673 1702
1674#if HAVE_AT 1703#if HAVE_AT
1675 1704
1705static int
1706eio__renameat2 (int olddirfd, const char *oldpath, int newdirfd, const char *newpath, unsigned int flags)
1707{
1708#if HAVE_RENAMEAT2
1709 return syscall (SYS_renameat2, olddirfd, oldpath, newdirfd, newpath, flags);
1710#else
1711 if (flags)
1712 return EIO_ENOSYS ();
1713
1714 return renameat (olddirfd, oldpath, newdirfd, newpath);
1715#endif
1716}
1717
1676/* they forgot these */ 1718/* they forgot these */
1677 1719
1678static int 1720static int
1679eio__truncateat (int dirfd, const char *path, off_t length) 1721eio__truncateat (int dirfd, const char *path, off_t length)
1680{ 1722{
1683 1725
1684 if (fd < 0) 1726 if (fd < 0)
1685 return fd; 1727 return fd;
1686 1728
1687 res = ftruncate (fd, length); 1729 res = ftruncate (fd, length);
1688 close (fd); 1730 silent_close (fd);
1689 return res; 1731 return res;
1690} 1732}
1691 1733
1692static int 1734static int
1693eio__statvfsat (int dirfd, const char *path, struct statvfs *buf) 1735eio__statvfsat (int dirfd, const char *path, struct statvfs *buf)
1697 1739
1698 if (fd < 0) 1740 if (fd < 0)
1699 return fd; 1741 return fd;
1700 1742
1701 res = fstatvfs (fd, buf); 1743 res = fstatvfs (fd, buf);
1702 close (fd); 1744 silent_close (fd);
1703 return res; 1745 return res;
1704
1705} 1746}
1706 1747
1707#endif 1748#endif
1708 1749
1709/*****************************************************************************/ 1750/*****************************************************************************/
1717 req->ptr2 = malloc (len); \ 1758 req->ptr2 = malloc (len); \
1718 if (!req->ptr2) \ 1759 if (!req->ptr2) \
1719 { \ 1760 { \
1720 errno = ENOMEM; \ 1761 errno = ENOMEM; \
1721 req->result = -1; \ 1762 req->result = -1; \
1722 break; \ 1763 goto alloc_fail; \
1723 } \ 1764 } \
1724 } 1765 }
1725 1766
1726/*****************************************************************************/ 1767/*****************************************************************************/
1768
1769static void
1770eio__slurp (int fd, eio_req *req)
1771{
1772 req->result = fd;
1773
1774 if (fd < 0)
1775 return;
1776
1777 if (req->offs < 0 || !req->size) /* do we need the size? */
1778 {
1779 off_t size = lseek (fd, 0, SEEK_END);
1780
1781 if (req->offs < 0)
1782 req->offs += size;
1783
1784 if (!req->size)
1785 req->size = size - req->offs;
1786 }
1787
1788 ALLOC (req->size);
1789 req->result = pread (fd, req->ptr2, req->size, req->offs);
1790
1791 silent_close (fd);
1792
1793alloc_fail:
1794 ;
1795}
1727 1796
1728int ecb_cold 1797int ecb_cold
1729eio_init (void (*want_poll)(void), void (*done_poll)(void)) 1798eio_init (void (*want_poll)(void), void (*done_poll)(void))
1730{ 1799{
1731 eio_want_poll_cb = want_poll; 1800 eio_want_poll_cb = want_poll;
1829 req->result = fstatat (dirfd, req->ptr1, (EIO_STRUCT_STAT *)req->ptr2, AT_SYMLINK_NOFOLLOW); break; 1898 req->result = fstatat (dirfd, req->ptr1, (EIO_STRUCT_STAT *)req->ptr2, AT_SYMLINK_NOFOLLOW); break;
1830 case EIO_CHOWN: req->result = fchownat (dirfd, req->ptr1, req->int2, req->int3, 0); break; 1899 case EIO_CHOWN: req->result = fchownat (dirfd, req->ptr1, req->int2, req->int3, 0); break;
1831 case EIO_CHMOD: req->result = fchmodat (dirfd, req->ptr1, (mode_t)req->int2, 0); break; 1900 case EIO_CHMOD: req->result = fchmodat (dirfd, req->ptr1, (mode_t)req->int2, 0); break;
1832 case EIO_TRUNCATE: req->result = eio__truncateat (dirfd, req->ptr1, req->offs); break; 1901 case EIO_TRUNCATE: req->result = eio__truncateat (dirfd, req->ptr1, req->offs); break;
1833 case EIO_OPEN: req->result = openat (dirfd, req->ptr1, req->int1, (mode_t)req->int2); break; 1902 case EIO_OPEN: req->result = openat (dirfd, req->ptr1, req->int1, (mode_t)req->int2); break;
1903 case EIO_SLURP: eio__slurp ( openat (dirfd, req->ptr1, O_RDONLY | O_CLOEXEC), req); break;
1834 1904
1835 case EIO_UNLINK: req->result = unlinkat (dirfd, req->ptr1, 0); break; 1905 case EIO_UNLINK: req->result = unlinkat (dirfd, req->ptr1, 0); break;
1836 case EIO_RMDIR: /* complications arise because "." cannot be removed, so we might have to expand */ 1906 case EIO_RMDIR: /* complications arise because "." cannot be removed, so we might have to expand */
1837 req->result = req->wd && SINGLEDOT (req->ptr1) 1907 req->result = req->wd && SINGLEDOT (req->ptr1)
1838 ? rmdir (req->wd->str) 1908 ? rmdir (req->wd->str)
1839 : unlinkat (dirfd, req->ptr1, AT_REMOVEDIR); break; 1909 : unlinkat (dirfd, req->ptr1, AT_REMOVEDIR); break;
1840 case EIO_MKDIR: req->result = mkdirat (dirfd, req->ptr1, (mode_t)req->int2); break; 1910 case EIO_MKDIR: req->result = mkdirat (dirfd, req->ptr1, (mode_t)req->int2); break;
1911 case EIO_RENAME: req->result = eio__renameat2 (
1912 dirfd,
1841 case EIO_RENAME: /* complications arise because "." cannot be renamed, so we might have to expand */ 1913 /* complications arise because "." cannot be renamed, so we might have to expand */
1842 req->result = req->wd && SINGLEDOT (req->ptr1) 1914 req->wd && SINGLEDOT (req->ptr1) ? req->wd->str : req->ptr1,
1843 ? rename (req->wd->str, req->ptr2) 1915 WD2FD ((eio_wd)req->int3),
1844 : renameat (dirfd, req->ptr1, WD2FD ((eio_wd)req->int3), req->ptr2); break; 1916 req->ptr2,
1917 req->int2
1918 );
1919 break;
1845 case EIO_LINK: req->result = linkat (dirfd, req->ptr1, WD2FD ((eio_wd)req->int3), req->ptr2, 0); break; 1920 case EIO_LINK: req->result = linkat (dirfd, req->ptr1, WD2FD ((eio_wd)req->int3), req->ptr2, 0); break;
1846 case EIO_SYMLINK: req->result = symlinkat (req->ptr1, dirfd, req->ptr2); break; 1921 case EIO_SYMLINK: req->result = symlinkat (req->ptr1, dirfd, req->ptr2); break;
1847 case EIO_MKNOD: req->result = mknodat (dirfd, req->ptr1, (mode_t)req->int2, (dev_t)req->offs); break; 1922 case EIO_MKNOD: req->result = mknodat (dirfd, req->ptr1, (mode_t)req->int2, (dev_t)req->offs); break;
1848 case EIO_READLINK: ALLOC (PATH_MAX);
1849 req->result = readlinkat (dirfd, req->ptr1, req->ptr2, PATH_MAX); break;
1850 case EIO_STATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS)); 1923 case EIO_STATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS));
1851 req->result = eio__statvfsat (dirfd, req->ptr1, (EIO_STRUCT_STATVFS *)req->ptr2); break; 1924 req->result = eio__statvfsat (dirfd, req->ptr1, (EIO_STRUCT_STATVFS *)req->ptr2); break;
1925 case EIO_READLINK: ALLOC (EIO_PATH_MAX);
1926 req->result = readlinkat (dirfd, req->ptr1, req->ptr2, EIO_PATH_MAX);
1927 if (req->result == EIO_PATH_MAX)
1928 {
1929 req->result = -1;
1930 errno = ENAMETOOLONG;
1931 }
1932 break;
1852 case EIO_UTIME: 1933 case EIO_UTIME:
1853 case EIO_FUTIME: 1934 case EIO_FUTIME:
1854 { 1935 {
1855 struct timespec ts[2]; 1936 struct timespec ts[2];
1856 struct timespec *times; 1937 struct timespec *times;
1881 req->result = lstat (path , (EIO_STRUCT_STAT *)req->ptr2); break; 1962 req->result = lstat (path , (EIO_STRUCT_STAT *)req->ptr2); break;
1882 case EIO_CHOWN: req->result = chown (path , req->int2, req->int3); break; 1963 case EIO_CHOWN: req->result = chown (path , req->int2, req->int3); break;
1883 case EIO_CHMOD: req->result = chmod (path , (mode_t)req->int2); break; 1964 case EIO_CHMOD: req->result = chmod (path , (mode_t)req->int2); break;
1884 case EIO_TRUNCATE: req->result = truncate (path , req->offs); break; 1965 case EIO_TRUNCATE: req->result = truncate (path , req->offs); break;
1885 case EIO_OPEN: req->result = open (path , req->int1, (mode_t)req->int2); break; 1966 case EIO_OPEN: req->result = open (path , req->int1, (mode_t)req->int2); break;
1967 case EIO_SLURP: eio__slurp ( open (path , O_RDONLY | O_CLOEXEC), req); break;
1886 1968
1887 case EIO_UNLINK: req->result = unlink (path ); break; 1969 case EIO_UNLINK: req->result = unlink (path ); break;
1888 case EIO_RMDIR: req->result = rmdir (path ); break; 1970 case EIO_RMDIR: req->result = rmdir (path ); break;
1889 case EIO_MKDIR: req->result = mkdir (path , (mode_t)req->int2); break; 1971 case EIO_MKDIR: req->result = mkdir (path , (mode_t)req->int2); break;
1890 case EIO_RENAME: req->result = rename (path , req->ptr2); break; 1972 case EIO_RENAME: req->result = req->int2 ? EIO_ENOSYS () : rename (path, req->ptr2); break;
1891 case EIO_LINK: req->result = link (path , req->ptr2); break; 1973 case EIO_LINK: req->result = link (path , req->ptr2); break;
1892 case EIO_SYMLINK: req->result = symlink (path , req->ptr2); break; 1974 case EIO_SYMLINK: req->result = symlink (path , req->ptr2); break;
1893 case EIO_MKNOD: req->result = mknod (path , (mode_t)req->int2, (dev_t)req->offs); break; 1975 case EIO_MKNOD: req->result = mknod (path , (mode_t)req->int2, (dev_t)req->offs); break;
1894 case EIO_READLINK: ALLOC (PATH_MAX);
1895 req->result = readlink (path, req->ptr2, PATH_MAX); break;
1896 case EIO_STATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS)); 1976 case EIO_STATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS));
1897 req->result = statvfs (path , (EIO_STRUCT_STATVFS *)req->ptr2); break; 1977 req->result = statvfs (path , (EIO_STRUCT_STATVFS *)req->ptr2); break;
1978 case EIO_READLINK: ALLOC (EIO_PATH_MAX);
1979 req->result = readlink (path, req->ptr2, EIO_PATH_MAX);
1980 if (req->result == EIO_PATH_MAX)
1981 {
1982 req->result = -1;
1983 errno = ENAMETOOLONG;
1984 }
1985 break;
1898 1986
1899 case EIO_UTIME: 1987 case EIO_UTIME:
1900 case EIO_FUTIME: 1988 case EIO_FUTIME:
1901 { 1989 {
1902 struct timeval tv[2]; 1990 struct timeval tv[2];
1937 2025
1938 case EIO_FCHOWN: req->result = fchown (req->int1, req->int2, req->int3); break; 2026 case EIO_FCHOWN: req->result = fchown (req->int1, req->int2, req->int3); break;
1939 case EIO_FCHMOD: req->result = fchmod (req->int1, (mode_t)req->int2); break; 2027 case EIO_FCHMOD: req->result = fchmod (req->int1, (mode_t)req->int2); break;
1940 case EIO_FTRUNCATE: req->result = ftruncate (req->int1, req->offs); break; 2028 case EIO_FTRUNCATE: req->result = ftruncate (req->int1, req->offs); break;
1941 2029
1942 case EIO_CLOSE: req->result = close (req->int1); break; 2030 case EIO_CLOSE: req->result = eio__close (req->int1); break;
1943 case EIO_DUP2: req->result = dup2 (req->int1, req->int2); break; 2031 case EIO_DUP2: req->result = dup2 (req->int1, req->int2); break;
1944 case EIO_SYNC: req->result = 0; sync (); break; 2032 case EIO_SYNC: req->result = 0; sync (); break;
1945 case EIO_FSYNC: req->result = fsync (req->int1); break; 2033 case EIO_FSYNC: req->result = fsync (req->int1); break;
1946 case EIO_FDATASYNC: req->result = fdatasync (req->int1); break; 2034 case EIO_FDATASYNC: req->result = fdatasync (req->int1); break;
1947 case EIO_SYNCFS: req->result = eio__syncfs (req->int1); break; 2035 case EIO_SYNCFS: req->result = eio__syncfs (req->int1); break;
1985 default: 2073 default:
1986 req->result = EIO_ENOSYS (); 2074 req->result = EIO_ENOSYS ();
1987 break; 2075 break;
1988 } 2076 }
1989 2077
2078alloc_fail:
1990 req->errorno = errno; 2079 req->errorno = errno;
1991} 2080}
1992 2081
1993#ifndef EIO_NO_WRAPPERS 2082#ifndef EIO_NO_WRAPPERS
1994 2083
2247eio_req *eio_rename (const char *path, const char *new_path, int pri, eio_cb cb, void *data) 2336eio_req *eio_rename (const char *path, const char *new_path, int pri, eio_cb cb, void *data)
2248{ 2337{
2249 return eio__2path (EIO_RENAME, path, new_path, pri, cb, data); 2338 return eio__2path (EIO_RENAME, path, new_path, pri, cb, data);
2250} 2339}
2251 2340
2341eio_req *eio_slurp (const char *path, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data)
2342{
2343 REQ (EIO_SLURP); PATH; req->offs = offset; req->size = length; req->ptr2 = buf; SEND;
2344}
2345
2252eio_req *eio_custom (void (*execute)(eio_req *), int pri, eio_cb cb, void *data) 2346eio_req *eio_custom (void (*execute)(eio_req *), int pri, eio_cb cb, void *data)
2253{ 2347{
2254 REQ (EIO_CUSTOM); req->feed = execute; SEND; 2348 REQ (EIO_CUSTOM); req->feed = execute; SEND;
2255} 2349}
2256 2350

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines