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

Comparing libeio/eio.c (file contents):
Revision 1.144 by root, Tue Dec 27 09:58:44 2016 UTC vs.
Revision 1.156 by root, Thu Nov 29 19:47:33 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,2018 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 *
231 #define D_NAME(entp) entp.cFileName 231 #define D_NAME(entp) entp.cFileName
232 #define D_TYPE(entp) (entp.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? DT_DIR : DT_REG) 232 #define D_TYPE(entp) (entp.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? DT_DIR : DT_REG)
233 233
234#else 234#else
235 235
236 #include <sys/ioctl.h>
236 #include <sys/time.h> 237 #include <sys/time.h>
237 #include <sys/select.h> 238 #include <sys/select.h>
238 #include <unistd.h> 239 #include <unistd.h>
239 #include <signal.h> 240 #include <signal.h>
240 #include <dirent.h> 241 #include <dirent.h>
299# else 300# else
300# error sendfile support requested but not available 301# error sendfile support requested but not available
301# endif 302# endif
302#endif 303#endif
303 304
305#if HAVE_RENAMEAT2
306# include <sys/syscall.h>
307# include <linux/fs.h>
308#endif
309
304#ifndef D_TYPE 310#ifndef D_TYPE
305# define D_TYPE(de) 0 311# define D_TYPE(de) 0
306#endif 312#endif
307#ifndef D_INO 313#ifndef D_INO
308# define D_INO(de) 0 314# define D_INO(de) 0
317#endif 323#endif
318 324
319/* used for readlink etc. */ 325/* used for readlink etc. */
320#ifndef PATH_MAX 326#ifndef PATH_MAX
321# define PATH_MAX 0 327# define PATH_MAX 0
328#endif
329
330#ifndef O_CLOEXEC
331 #define O_CLOEXEC 0
332#endif
333
334#ifndef O_NONBLOCK
335 #define O_NONBLOCK 0
336#endif
337
338#ifndef O_SEARCH
339 #define O_SEARCH O_RDONLY
340#endif
341
342#ifndef O_DIRECTORY
343 #define O_DIRECTORY 0
322#endif 344#endif
323 345
324#ifndef EIO_PATH_MIN 346#ifndef EIO_PATH_MIN
325# define EIO_PATH_MIN 8160 347# define EIO_PATH_MIN 8160
326#endif 348#endif
344struct etp_tmpbuf; 366struct etp_tmpbuf;
345 367
346#if _POSIX_VERSION >= 200809L 368#if _POSIX_VERSION >= 200809L
347 #define HAVE_AT 1 369 #define HAVE_AT 1
348 #define WD2FD(wd) ((wd) ? (wd)->fd : AT_FDCWD) 370 #define WD2FD(wd) ((wd) ? (wd)->fd : AT_FDCWD)
349 #ifndef O_SEARCH
350 #define O_SEARCH O_RDONLY
351 #endif
352#else 371#else
353 #define HAVE_AT 0 372 #define HAVE_AT 0
354 static const char *wd_expand (struct etp_tmpbuf *tmpbuf, eio_wd wd, const char *path); 373 static const char *wd_expand (struct etp_tmpbuf *tmpbuf, eio_wd wd, const char *path);
355#endif 374#endif
356 375
546 return etp_poll (EIO_POOL); 565 return etp_poll (EIO_POOL);
547} 566}
548 567
549/*****************************************************************************/ 568/*****************************************************************************/
550/* work around various missing functions */ 569/* work around various missing functions */
570
571#if HAVE_POSIX_CLOSE && !__linux
572# define eio__close(fd) posix_close (fd, 0)
573#else
574# define eio__close(fd) close (fd)
575#endif
576
577/* close() without disturbing errno */
578static void
579silent_close (int fd)
580{
581 int saved_errno = errno;
582 eio__close (fd);
583 errno = saved_errno;
584}
551 585
552#ifndef HAVE_UTIMES 586#ifndef HAVE_UTIMES
553 587
554# undef utimes 588# undef utimes
555# define utimes(path,times) eio__utimes (path, times) 589# define utimes(path,times) eio__utimes (path, times)
868 #if __GLIBC__ == 2 && __GLIBC_MINOR__ <= 7 902 #if __GLIBC__ == 2 && __GLIBC_MINOR__ <= 7
869 extern int mallopt (int, int); 903 extern int mallopt (int, int);
870 mallopt (-6, 238); /* http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=473812 */ 904 mallopt (-6, 238); /* http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=473812 */
871 #endif 905 #endif
872 906
907 #ifndef MCL_ONFAULT
908 if (flags & EIO_MCL_ONFAULT)
909 return EIO_ERRNO (EINVAL, -1);
910 #define MCL_ONFAULT 4
911 #endif
912
873 if (EIO_MCL_CURRENT != MCL_CURRENT 913 if (EIO_MCL_CURRENT != MCL_CURRENT
874 || EIO_MCL_FUTURE != MCL_FUTURE) 914 || EIO_MCL_FUTURE != MCL_FUTURE
915 || EIO_MCL_ONFAULT != MCL_ONFAULT)
875 { 916 {
876 flags = 0 917 flags = 0
877 | (flags & EIO_MCL_CURRENT ? MCL_CURRENT : 0) 918 | (flags & EIO_MCL_CURRENT ? MCL_CURRENT : 0)
878 | (flags & EIO_MCL_FUTURE ? MCL_FUTURE : 0); 919 | (flags & EIO_MCL_FUTURE ? MCL_FUTURE : 0)
920 | (flags & EIO_MCL_ONFAULT ? MCL_ONFAULT : 0)
921 ;
879 } 922 }
880 923
881 return mlockall (flags); 924 return mlockall (flags);
882} 925}
883#endif 926#endif
934 intptr_t end = addr + len; 977 intptr_t end = addr + len;
935 intptr_t page = eio_pagesize (); 978 intptr_t page = eio_pagesize ();
936 979
937 if (addr < end) 980 if (addr < end)
938 if (flags & EIO_MT_MODIFY) /* modify */ 981 if (flags & EIO_MT_MODIFY) /* modify */
939 do { *((volatile sig_atomic_t *)addr) |= 0; } while ((addr += page) < len && !EIO_CANCELLED (req)); 982 do { *((volatile sig_atomic_t *)addr) |= 0; } while ((addr += page) < end && !EIO_CANCELLED (req));
940 else 983 else
941 do { *((volatile sig_atomic_t *)addr) ; } while ((addr += page) < len && !EIO_CANCELLED (req)); 984 do { *((volatile sig_atomic_t *)addr) ; } while ((addr += page) < end && !EIO_CANCELLED (req));
942 } 985 }
943 986
944 return 0; 987 return 0;
945} 988}
946 989
1012 if (fd >= 0) 1055 if (fd >= 0)
1013 { 1056 {
1014 sprintf (tmp1, "/proc/self/fd/%d", fd); 1057 sprintf (tmp1, "/proc/self/fd/%d", fd);
1015 req->result = readlink (tmp1, res, EIO_PATH_MAX); 1058 req->result = readlink (tmp1, res, EIO_PATH_MAX);
1016 /* here we should probably stat the open file and the disk file, to make sure they still match */ 1059 /* here we should probably stat the open file and the disk file, to make sure they still match */
1017 close (fd); 1060 eio__close (fd);
1018 1061
1019 if (req->result > 0) 1062 if (req->result > 0)
1020 goto done; 1063 goto done;
1021 } 1064 }
1022 else if (errno == ELOOP || errno == ENAMETOOLONG || errno == ENOENT || errno == ENOTDIR || errno == EIO) 1065 else if (errno == ELOOP || errno == ENAMETOOLONG || errno == ENOENT || errno == ENOTDIR || errno == EIO)
1370 return; 1413 return;
1371 } 1414 }
1372 } 1415 }
1373#else 1416#else
1374 #if HAVE_AT 1417 #if HAVE_AT
1375 if (req->wd)
1376 { 1418 {
1377 int fd = openat (WD2FD (req->wd), req->ptr1, O_CLOEXEC | O_SEARCH | O_DIRECTORY); 1419 int fd = openat (WD2FD (req->wd), req->ptr1, O_CLOEXEC | O_SEARCH | O_DIRECTORY | O_NONBLOCK);
1378 1420
1379 if (fd < 0) 1421 if (fd < 0)
1422 return;
1423
1424 dirp = fdopendir (fd);
1425
1426 if (!dirp)
1427 {
1428 silent_close (fd);
1380 return; 1429 return;
1381
1382 dirp = fdopendir (fd);
1383
1384 if (!dirp)
1385 close (fd);
1386 } 1430 }
1387 else 1431 }
1388 dirp = opendir (req->ptr1);
1389 #else 1432 #else
1390 dirp = opendir (wd_expand (&self->tmpbuf, req->wd, req->ptr1)); 1433 dirp = opendir (wd_expand (&self->tmpbuf, req->wd, req->ptr1));
1434
1435 if (!dirp)
1436 return;
1391 #endif 1437 #endif
1392
1393 if (!dirp)
1394 return;
1395#endif 1438#endif
1396 1439
1397 if (req->flags & EIO_FLAG_PTR1_FREE) 1440 if (req->flags & EIO_FLAG_PTR1_FREE)
1398 free (req->ptr1); 1441 free (req->ptr1);
1399 1442
1634 1677
1635 if (len < 0) 1678 if (len < 0)
1636 return EIO_INVALID_WD; 1679 return EIO_INVALID_WD;
1637 1680
1638#if HAVE_AT 1681#if HAVE_AT
1639 fd = openat (WD2FD (wd), path, O_CLOEXEC | O_SEARCH | O_DIRECTORY); 1682 fd = openat (WD2FD (wd), path, O_CLOEXEC | O_SEARCH | O_DIRECTORY | O_NONBLOCK);
1640 1683
1641 if (fd < 0) 1684 if (fd < 0)
1642 return EIO_INVALID_WD; 1685 return EIO_INVALID_WD;
1643#endif 1686#endif
1644 1687
1656} 1699}
1657 1700
1658eio_wd 1701eio_wd
1659eio_wd_open_sync (eio_wd wd, const char *path) 1702eio_wd_open_sync (eio_wd wd, const char *path)
1660{ 1703{
1661 struct etp_tmpbuf tmpbuf = { }; 1704 struct etp_tmpbuf tmpbuf = { 0 };
1662 wd = eio__wd_open_sync (&tmpbuf, wd, path); 1705 wd = eio__wd_open_sync (&tmpbuf, wd, path);
1663 free (tmpbuf.ptr); 1706 free (tmpbuf.ptr);
1664 1707
1665 return wd; 1708 return wd;
1666} 1709}
1669eio_wd_close_sync (eio_wd wd) 1712eio_wd_close_sync (eio_wd wd)
1670{ 1713{
1671 if (wd != EIO_INVALID_WD && wd != EIO_CWD) 1714 if (wd != EIO_INVALID_WD && wd != EIO_CWD)
1672 { 1715 {
1673 #if HAVE_AT 1716 #if HAVE_AT
1674 close (wd->fd); 1717 eio__close (wd->fd);
1675 #endif 1718 #endif
1676 free (wd); 1719 free (wd);
1677 } 1720 }
1678} 1721}
1679 1722
1680#if HAVE_AT 1723#if HAVE_AT
1681 1724
1725static int
1726eio__renameat2 (int olddirfd, const char *oldpath, int newdirfd, const char *newpath, unsigned int flags)
1727{
1728#if HAVE_RENAMEAT2
1729 return syscall (SYS_renameat2, olddirfd, oldpath, newdirfd, newpath, flags);
1730#else
1731 if (flags)
1732 return EIO_ENOSYS ();
1733
1734 return renameat (olddirfd, oldpath, newdirfd, newpath);
1735#endif
1736}
1737
1682/* they forgot these */ 1738/* they forgot these */
1683 1739
1684static int 1740static int
1685eio__truncateat (int dirfd, const char *path, off_t length) 1741eio__truncateat (int dirfd, const char *path, off_t length)
1686{ 1742{
1687 int fd = openat (dirfd, path, O_WRONLY | O_CLOEXEC); 1743 int fd = openat (dirfd, path, O_WRONLY | O_CLOEXEC | O_NONBLOCK);
1688 int res; 1744 int res;
1689 1745
1690 if (fd < 0) 1746 if (fd < 0)
1691 return fd; 1747 return fd;
1692 1748
1693 res = ftruncate (fd, length); 1749 res = ftruncate (fd, length);
1694 close (fd); 1750 silent_close (fd);
1695 return res; 1751 return res;
1696} 1752}
1697 1753
1698static int 1754static int
1699eio__statvfsat (int dirfd, const char *path, struct statvfs *buf) 1755eio__statvfsat (int dirfd, const char *path, struct statvfs *buf)
1700{ 1756{
1701 int fd = openat (dirfd, path, O_SEARCH | O_CLOEXEC); 1757 int fd = openat (dirfd, path, O_SEARCH | O_CLOEXEC | O_NONBLOCK);
1702 int res; 1758 int res;
1703 1759
1704 if (fd < 0) 1760 if (fd < 0)
1705 return fd; 1761 return fd;
1706 1762
1707 res = fstatvfs (fd, buf); 1763 res = fstatvfs (fd, buf);
1708 close (fd); 1764 silent_close (fd);
1709 return res; 1765 return res;
1710
1711} 1766}
1712 1767
1713#endif 1768#endif
1714 1769
1715/*****************************************************************************/ 1770/*****************************************************************************/
1723 req->ptr2 = malloc (len); \ 1778 req->ptr2 = malloc (len); \
1724 if (!req->ptr2) \ 1779 if (!req->ptr2) \
1725 { \ 1780 { \
1726 errno = ENOMEM; \ 1781 errno = ENOMEM; \
1727 req->result = -1; \ 1782 req->result = -1; \
1728 break; \ 1783 goto alloc_fail; \
1729 } \ 1784 } \
1730 } 1785 }
1731 1786
1732/*****************************************************************************/ 1787/*****************************************************************************/
1788
1789static void
1790eio__slurp (int fd, eio_req *req)
1791{
1792 req->result = fd;
1793
1794 if (fd < 0)
1795 return;
1796
1797 if (req->offs < 0 || !req->size) /* do we need the size? */
1798 {
1799 off_t size = lseek (fd, 0, SEEK_END);
1800
1801 if (req->offs < 0)
1802 req->offs += size;
1803
1804 if (!req->size)
1805 req->size = size - req->offs;
1806 }
1807
1808 ALLOC (req->size);
1809 req->result = pread (fd, req->ptr2, req->size, req->offs);
1810
1811 silent_close (fd);
1812
1813alloc_fail:
1814 ;
1815}
1733 1816
1734int ecb_cold 1817int ecb_cold
1735eio_init (void (*want_poll)(void), void (*done_poll)(void)) 1818eio_init (void (*want_poll)(void), void (*done_poll)(void))
1736{ 1819{
1737 eio_want_poll_cb = want_poll; 1820 eio_want_poll_cb = want_poll;
1835 req->result = fstatat (dirfd, req->ptr1, (EIO_STRUCT_STAT *)req->ptr2, AT_SYMLINK_NOFOLLOW); break; 1918 req->result = fstatat (dirfd, req->ptr1, (EIO_STRUCT_STAT *)req->ptr2, AT_SYMLINK_NOFOLLOW); break;
1836 case EIO_CHOWN: req->result = fchownat (dirfd, req->ptr1, req->int2, req->int3, 0); break; 1919 case EIO_CHOWN: req->result = fchownat (dirfd, req->ptr1, req->int2, req->int3, 0); break;
1837 case EIO_CHMOD: req->result = fchmodat (dirfd, req->ptr1, (mode_t)req->int2, 0); break; 1920 case EIO_CHMOD: req->result = fchmodat (dirfd, req->ptr1, (mode_t)req->int2, 0); break;
1838 case EIO_TRUNCATE: req->result = eio__truncateat (dirfd, req->ptr1, req->offs); break; 1921 case EIO_TRUNCATE: req->result = eio__truncateat (dirfd, req->ptr1, req->offs); break;
1839 case EIO_OPEN: req->result = openat (dirfd, req->ptr1, req->int1, (mode_t)req->int2); break; 1922 case EIO_OPEN: req->result = openat (dirfd, req->ptr1, req->int1, (mode_t)req->int2); break;
1923 case EIO_SLURP: eio__slurp ( openat (dirfd, req->ptr1, O_RDONLY | O_CLOEXEC), req); break;
1840 1924
1841 case EIO_UNLINK: req->result = unlinkat (dirfd, req->ptr1, 0); break; 1925 case EIO_UNLINK: req->result = unlinkat (dirfd, req->ptr1, 0); break;
1842 case EIO_RMDIR: /* complications arise because "." cannot be removed, so we might have to expand */ 1926 case EIO_RMDIR: /* complications arise because "." cannot be removed, so we might have to expand */
1843 req->result = req->wd && SINGLEDOT (req->ptr1) 1927 req->result = req->wd && SINGLEDOT (req->ptr1)
1844 ? rmdir (req->wd->str) 1928 ? rmdir (req->wd->str)
1845 : unlinkat (dirfd, req->ptr1, AT_REMOVEDIR); break; 1929 : unlinkat (dirfd, req->ptr1, AT_REMOVEDIR); break;
1846 case EIO_MKDIR: req->result = mkdirat (dirfd, req->ptr1, (mode_t)req->int2); break; 1930 case EIO_MKDIR: req->result = mkdirat (dirfd, req->ptr1, (mode_t)req->int2); break;
1931 case EIO_RENAME: req->result = eio__renameat2 (
1932 dirfd,
1847 case EIO_RENAME: /* complications arise because "." cannot be renamed, so we might have to expand */ 1933 /* complications arise because "." cannot be renamed, so we might have to expand */
1848 req->result = req->wd && SINGLEDOT (req->ptr1) 1934 req->wd && SINGLEDOT (req->ptr1) ? req->wd->str : req->ptr1,
1849 ? rename (req->wd->str, req->ptr2) 1935 WD2FD ((eio_wd)req->int3),
1850 : renameat (dirfd, req->ptr1, WD2FD ((eio_wd)req->int3), req->ptr2); break; 1936 req->ptr2,
1937 req->int2
1938 );
1939 break;
1851 case EIO_LINK: req->result = linkat (dirfd, req->ptr1, WD2FD ((eio_wd)req->int3), req->ptr2, 0); break; 1940 case EIO_LINK: req->result = linkat (dirfd, req->ptr1, WD2FD ((eio_wd)req->int3), req->ptr2, 0); break;
1852 case EIO_SYMLINK: req->result = symlinkat (req->ptr1, dirfd, req->ptr2); break; 1941 case EIO_SYMLINK: req->result = symlinkat (req->ptr1, dirfd, req->ptr2); break;
1853 case EIO_MKNOD: req->result = mknodat (dirfd, req->ptr1, (mode_t)req->int2, (dev_t)req->offs); break; 1942 case EIO_MKNOD: req->result = mknodat (dirfd, req->ptr1, (mode_t)req->int2, (dev_t)req->offs); break;
1854 case EIO_STATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS)); 1943 case EIO_STATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS));
1855 req->result = eio__statvfsat (dirfd, req->ptr1, (EIO_STRUCT_STATVFS *)req->ptr2); break; 1944 req->result = eio__statvfsat (dirfd, req->ptr1, (EIO_STRUCT_STATVFS *)req->ptr2); break;
1893 req->result = lstat (path , (EIO_STRUCT_STAT *)req->ptr2); break; 1982 req->result = lstat (path , (EIO_STRUCT_STAT *)req->ptr2); break;
1894 case EIO_CHOWN: req->result = chown (path , req->int2, req->int3); break; 1983 case EIO_CHOWN: req->result = chown (path , req->int2, req->int3); break;
1895 case EIO_CHMOD: req->result = chmod (path , (mode_t)req->int2); break; 1984 case EIO_CHMOD: req->result = chmod (path , (mode_t)req->int2); break;
1896 case EIO_TRUNCATE: req->result = truncate (path , req->offs); break; 1985 case EIO_TRUNCATE: req->result = truncate (path , req->offs); break;
1897 case EIO_OPEN: req->result = open (path , req->int1, (mode_t)req->int2); break; 1986 case EIO_OPEN: req->result = open (path , req->int1, (mode_t)req->int2); break;
1987 case EIO_SLURP: eio__slurp ( open (path , O_RDONLY | O_CLOEXEC), req); break;
1898 1988
1899 case EIO_UNLINK: req->result = unlink (path ); break; 1989 case EIO_UNLINK: req->result = unlink (path ); break;
1900 case EIO_RMDIR: req->result = rmdir (path ); break; 1990 case EIO_RMDIR: req->result = rmdir (path ); break;
1901 case EIO_MKDIR: req->result = mkdir (path , (mode_t)req->int2); break; 1991 case EIO_MKDIR: req->result = mkdir (path , (mode_t)req->int2); break;
1902 case EIO_RENAME: req->result = rename (path , req->ptr2); break; 1992 case EIO_RENAME: req->result = req->int2 ? EIO_ENOSYS () : rename (path, req->ptr2); break;
1903 case EIO_LINK: req->result = link (path , req->ptr2); break; 1993 case EIO_LINK: req->result = link (path , req->ptr2); break;
1904 case EIO_SYMLINK: req->result = symlink (path , req->ptr2); break; 1994 case EIO_SYMLINK: req->result = symlink (path , req->ptr2); break;
1905 case EIO_MKNOD: req->result = mknod (path , (mode_t)req->int2, (dev_t)req->offs); break; 1995 case EIO_MKNOD: req->result = mknod (path , (mode_t)req->int2, (dev_t)req->offs); break;
1906 case EIO_STATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS)); 1996 case EIO_STATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS));
1907 req->result = statvfs (path , (EIO_STRUCT_STATVFS *)req->ptr2); break; 1997 req->result = statvfs (path , (EIO_STRUCT_STATVFS *)req->ptr2); break;
1955 2045
1956 case EIO_FCHOWN: req->result = fchown (req->int1, req->int2, req->int3); break; 2046 case EIO_FCHOWN: req->result = fchown (req->int1, req->int2, req->int3); break;
1957 case EIO_FCHMOD: req->result = fchmod (req->int1, (mode_t)req->int2); break; 2047 case EIO_FCHMOD: req->result = fchmod (req->int1, (mode_t)req->int2); break;
1958 case EIO_FTRUNCATE: req->result = ftruncate (req->int1, req->offs); break; 2048 case EIO_FTRUNCATE: req->result = ftruncate (req->int1, req->offs); break;
1959 2049
1960 case EIO_CLOSE: req->result = close (req->int1); break; 2050 case EIO_CLOSE: req->result = eio__close (req->int1); break;
1961 case EIO_DUP2: req->result = dup2 (req->int1, req->int2); break; 2051 case EIO_DUP2: req->result = dup2 (req->int1, req->int2); break;
1962 case EIO_SYNC: req->result = 0; sync (); break; 2052 case EIO_SYNC: req->result = 0; sync (); break;
1963 case EIO_FSYNC: req->result = fsync (req->int1); break; 2053 case EIO_FSYNC: req->result = fsync (req->int1); break;
1964 case EIO_FDATASYNC: req->result = fdatasync (req->int1); break; 2054 case EIO_FDATASYNC: req->result = fdatasync (req->int1); break;
1965 case EIO_SYNCFS: req->result = eio__syncfs (req->int1); break; 2055 case EIO_SYNCFS: req->result = eio__syncfs (req->int1); break;
2003 default: 2093 default:
2004 req->result = EIO_ENOSYS (); 2094 req->result = EIO_ENOSYS ();
2005 break; 2095 break;
2006 } 2096 }
2007 2097
2098alloc_fail:
2008 req->errorno = errno; 2099 req->errorno = errno;
2009} 2100}
2010 2101
2011#ifndef EIO_NO_WRAPPERS 2102#ifndef EIO_NO_WRAPPERS
2012 2103
2265eio_req *eio_rename (const char *path, const char *new_path, int pri, eio_cb cb, void *data) 2356eio_req *eio_rename (const char *path, const char *new_path, int pri, eio_cb cb, void *data)
2266{ 2357{
2267 return eio__2path (EIO_RENAME, path, new_path, pri, cb, data); 2358 return eio__2path (EIO_RENAME, path, new_path, pri, cb, data);
2268} 2359}
2269 2360
2361eio_req *eio_slurp (const char *path, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data)
2362{
2363 REQ (EIO_SLURP); PATH; req->offs = offset; req->size = length; req->ptr2 = buf; SEND;
2364}
2365
2270eio_req *eio_custom (void (*execute)(eio_req *), int pri, eio_cb cb, void *data) 2366eio_req *eio_custom (void (*execute)(eio_req *), int pri, eio_cb cb, void *data)
2271{ 2367{
2272 REQ (EIO_CUSTOM); req->feed = execute; SEND; 2368 REQ (EIO_CUSTOM); req->feed = execute; SEND;
2273} 2369}
2274 2370

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines