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.161 by root, Fri Feb 16 21:20:52 2024 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,2019 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
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
322#endif 328#endif
323 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
344#endif
345
324#ifndef EIO_PATH_MIN 346#ifndef EIO_PATH_MIN
325# define EIO_PATH_MIN 8160 347# define EIO_PATH_MIN 8160
348#endif
349
350#if defined(O_PATH)
351# define EIO_O_PATH O_PATH
352#elif defined(O_SEARCH)
353# define EIO_O_PATH O_SEARCH
354#else
355# define EIO_O_PATH 0
326#endif 356#endif
327 357
328#define EIO_PATH_MAX (PATH_MAX <= EIO_PATH_MIN ? EIO_PATH_MIN : PATH_MAX) 358#define EIO_PATH_MAX (PATH_MAX <= EIO_PATH_MIN ? EIO_PATH_MIN : PATH_MAX)
329 359
330/* buffer size for various temporary buffers */ 360/* buffer size for various temporary buffers */
344struct etp_tmpbuf; 374struct etp_tmpbuf;
345 375
346#if _POSIX_VERSION >= 200809L 376#if _POSIX_VERSION >= 200809L
347 #define HAVE_AT 1 377 #define HAVE_AT 1
348 #define WD2FD(wd) ((wd) ? (wd)->fd : AT_FDCWD) 378 #define WD2FD(wd) ((wd) ? (wd)->fd : AT_FDCWD)
349 #ifndef O_SEARCH
350 #define O_SEARCH O_RDONLY
351 #endif
352#else 379#else
353 #define HAVE_AT 0 380 #define HAVE_AT 0
354 static const char *wd_expand (struct etp_tmpbuf *tmpbuf, eio_wd wd, const char *path); 381 static const char *wd_expand (struct etp_tmpbuf *tmpbuf, eio_wd wd, const char *path);
355#endif 382#endif
356 383
546 return etp_poll (EIO_POOL); 573 return etp_poll (EIO_POOL);
547} 574}
548 575
549/*****************************************************************************/ 576/*****************************************************************************/
550/* work around various missing functions */ 577/* work around various missing functions */
578
579#if HAVE_POSIX_CLOSE && !__linux
580# define eio__close(fd) posix_close (fd, 0)
581#else
582# define eio__close(fd) close (fd)
583#endif
584
585/* close() without disturbing errno */
586static void
587silent_close (int fd)
588{
589 int saved_errno = errno;
590 eio__close (fd);
591 errno = saved_errno;
592}
551 593
552#ifndef HAVE_UTIMES 594#ifndef HAVE_UTIMES
553 595
554# undef utimes 596# undef utimes
555# define utimes(path,times) eio__utimes (path, times) 597# define utimes(path,times) eio__utimes (path, times)
868 #if __GLIBC__ == 2 && __GLIBC_MINOR__ <= 7 910 #if __GLIBC__ == 2 && __GLIBC_MINOR__ <= 7
869 extern int mallopt (int, int); 911 extern int mallopt (int, int);
870 mallopt (-6, 238); /* http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=473812 */ 912 mallopt (-6, 238); /* http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=473812 */
871 #endif 913 #endif
872 914
915 #ifndef MCL_ONFAULT
916 if (flags & EIO_MCL_ONFAULT)
917 return EIO_ERRNO (EINVAL, -1);
918 #define MCL_ONFAULT 4
919 #endif
920
873 if (EIO_MCL_CURRENT != MCL_CURRENT 921 if (EIO_MCL_CURRENT != MCL_CURRENT
874 || EIO_MCL_FUTURE != MCL_FUTURE) 922 || EIO_MCL_FUTURE != MCL_FUTURE
923 || EIO_MCL_ONFAULT != MCL_ONFAULT)
875 { 924 {
876 flags = 0 925 flags = 0
877 | (flags & EIO_MCL_CURRENT ? MCL_CURRENT : 0) 926 | (flags & EIO_MCL_CURRENT ? MCL_CURRENT : 0)
878 | (flags & EIO_MCL_FUTURE ? MCL_FUTURE : 0); 927 | (flags & EIO_MCL_FUTURE ? MCL_FUTURE : 0)
928 | (flags & EIO_MCL_ONFAULT ? MCL_ONFAULT : 0)
929 ;
879 } 930 }
880 931
881 return mlockall (flags); 932 return mlockall (flags);
882} 933}
883#endif 934#endif
934 intptr_t end = addr + len; 985 intptr_t end = addr + len;
935 intptr_t page = eio_pagesize (); 986 intptr_t page = eio_pagesize ();
936 987
937 if (addr < end) 988 if (addr < end)
938 if (flags & EIO_MT_MODIFY) /* modify */ 989 if (flags & EIO_MT_MODIFY) /* modify */
939 do { *((volatile sig_atomic_t *)addr) |= 0; } while ((addr += page) < len && !EIO_CANCELLED (req)); 990 do { *((volatile sig_atomic_t *)addr) |= 0; } while ((addr += page) < end && !EIO_CANCELLED (req));
940 else 991 else
941 do { *((volatile sig_atomic_t *)addr) ; } while ((addr += page) < len && !EIO_CANCELLED (req)); 992 do { *((volatile sig_atomic_t *)addr) ; } while ((addr += page) < end && !EIO_CANCELLED (req));
942 } 993 }
943 994
944 return 0; 995 return 0;
945} 996}
946 997
1012 if (fd >= 0) 1063 if (fd >= 0)
1013 { 1064 {
1014 sprintf (tmp1, "/proc/self/fd/%d", fd); 1065 sprintf (tmp1, "/proc/self/fd/%d", fd);
1015 req->result = readlink (tmp1, res, EIO_PATH_MAX); 1066 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 */ 1067 /* here we should probably stat the open file and the disk file, to make sure they still match */
1017 close (fd); 1068 eio__close (fd);
1018 1069
1019 if (req->result > 0) 1070 if (req->result > 0)
1020 goto done; 1071 goto done;
1021 } 1072 }
1022 else if (errno == ELOOP || errno == ENAMETOOLONG || errno == ENOENT || errno == ENOTDIR || errno == EIO) 1073 else if (errno == ELOOP || errno == ENAMETOOLONG || errno == ENOENT || errno == ENOTDIR || errno == EIO)
1370 return; 1421 return;
1371 } 1422 }
1372 } 1423 }
1373#else 1424#else
1374 #if HAVE_AT 1425 #if HAVE_AT
1375 if (req->wd)
1376 { 1426 {
1377 int fd = openat (WD2FD (req->wd), req->ptr1, O_CLOEXEC | O_SEARCH | O_DIRECTORY); 1427 int fd = openat (WD2FD (req->wd), req->ptr1, O_CLOEXEC | O_RDONLY | O_DIRECTORY | O_NONBLOCK);
1378 1428
1379 if (fd < 0) 1429 if (fd < 0)
1430 return;
1431
1432 dirp = fdopendir (fd);
1433
1434 if (!dirp)
1435 {
1436 silent_close (fd);
1380 return; 1437 return;
1381
1382 dirp = fdopendir (fd);
1383
1384 if (!dirp)
1385 close (fd);
1386 } 1438 }
1387 else 1439 }
1388 dirp = opendir (req->ptr1);
1389 #else 1440 #else
1390 dirp = opendir (wd_expand (&self->tmpbuf, req->wd, req->ptr1)); 1441 dirp = opendir (wd_expand (&self->tmpbuf, req->wd, req->ptr1));
1442
1443 if (!dirp)
1444 return;
1391 #endif 1445 #endif
1392
1393 if (!dirp)
1394 return;
1395#endif 1446#endif
1396 1447
1397 if (req->flags & EIO_FLAG_PTR1_FREE) 1448 if (req->flags & EIO_FLAG_PTR1_FREE)
1398 free (req->ptr1); 1449 free (req->ptr1);
1399 1450
1596/* keep the absolute path in string form at all times */ 1647/* keep the absolute path in string form at all times */
1597/* fuck yeah. */ 1648/* fuck yeah. */
1598 1649
1599#if !HAVE_AT 1650#if !HAVE_AT
1600 1651
1601/* a bit like realpath, but usually faster because it doesn'T have to return */ 1652/* a bit like realpath, but usually faster because it doesn't have to return */
1602/* an absolute or canonical path */ 1653/* an absolute or canonical path */
1603static const char * 1654static const char *
1604wd_expand (struct etp_tmpbuf *tmpbuf, eio_wd wd, const char *path) 1655wd_expand (struct etp_tmpbuf *tmpbuf, eio_wd wd, const char *path)
1605{ 1656{
1606 if (!wd || *path == '/') 1657 if (!wd || *path == '/')
1634 1685
1635 if (len < 0) 1686 if (len < 0)
1636 return EIO_INVALID_WD; 1687 return EIO_INVALID_WD;
1637 1688
1638#if HAVE_AT 1689#if HAVE_AT
1639 fd = openat (WD2FD (wd), path, O_CLOEXEC | O_SEARCH | O_DIRECTORY); 1690 fd = openat (WD2FD (wd), path, EIO_O_PATH | O_DIRECTORY | O_NONBLOCK | O_CLOEXEC);
1691
1692 /* 0 is a valid fd, but we use it for EIO_CWD, so in the very unlikely */
1693 /* case of fd 0 being available (almost certainly an a pplication bug) */
1694 /* make sure we use another fd value */
1695 #if EIO_CWD
1696 error EIO_CWD must be 0
1697 #endif
1698 if (ecb_expect_false (fd == 0))
1699 {
1700 int fd2 = fcntl (fd, F_DUPFD_CLOEXEC ? F_DUPFD_CLOEXEC : F_DUPFD);
1701 fcntl (fd2, F_SETFD, FD_CLOEXEC);
1702 eio__close (fd);
1703 fd = fd2;
1704 }
1640 1705
1641 if (fd < 0) 1706 if (fd < 0)
1642 return EIO_INVALID_WD; 1707 return EIO_INVALID_WD;
1643#endif 1708#endif
1644 1709
1656} 1721}
1657 1722
1658eio_wd 1723eio_wd
1659eio_wd_open_sync (eio_wd wd, const char *path) 1724eio_wd_open_sync (eio_wd wd, const char *path)
1660{ 1725{
1661 struct etp_tmpbuf tmpbuf = { }; 1726 struct etp_tmpbuf tmpbuf = { 0 };
1662 wd = eio__wd_open_sync (&tmpbuf, wd, path); 1727 wd = eio__wd_open_sync (&tmpbuf, wd, path);
1663 free (tmpbuf.ptr); 1728 free (tmpbuf.ptr);
1664 1729
1665 return wd; 1730 return wd;
1666} 1731}
1669eio_wd_close_sync (eio_wd wd) 1734eio_wd_close_sync (eio_wd wd)
1670{ 1735{
1671 if (wd != EIO_INVALID_WD && wd != EIO_CWD) 1736 if (wd != EIO_INVALID_WD && wd != EIO_CWD)
1672 { 1737 {
1673 #if HAVE_AT 1738 #if HAVE_AT
1674 close (wd->fd); 1739 eio__close (wd->fd);
1675 #endif 1740 #endif
1676 free (wd); 1741 free (wd);
1677 } 1742 }
1678} 1743}
1679 1744
1680#if HAVE_AT 1745#if HAVE_AT
1681 1746
1747static int
1748eio__renameat2 (int olddirfd, const char *oldpath, int newdirfd, const char *newpath, unsigned int flags)
1749{
1750#if HAVE_RENAMEAT2
1751 return syscall (SYS_renameat2, olddirfd, oldpath, newdirfd, newpath, flags);
1752#else
1753 if (flags)
1754 return EIO_ENOSYS ();
1755
1756 return renameat (olddirfd, oldpath, newdirfd, newpath);
1757#endif
1758}
1759
1682/* they forgot these */ 1760/* they forgot these */
1683 1761
1684static int 1762static int
1685eio__truncateat (int dirfd, const char *path, off_t length) 1763eio__truncateat (int dirfd, const char *path, off_t length)
1686{ 1764{
1687 int fd = openat (dirfd, path, O_WRONLY | O_CLOEXEC); 1765 int fd = openat (dirfd, path, O_WRONLY | O_CLOEXEC | O_NONBLOCK);
1688 int res; 1766 int res;
1689 1767
1690 if (fd < 0) 1768 if (fd < 0)
1691 return fd; 1769 return fd;
1692 1770
1693 res = ftruncate (fd, length); 1771 res = ftruncate (fd, length);
1694 close (fd); 1772 silent_close (fd);
1695 return res; 1773 return res;
1696} 1774}
1697 1775
1698static int 1776static int
1699eio__statvfsat (int dirfd, const char *path, struct statvfs *buf) 1777eio__statvfsat (int dirfd, const char *path, struct statvfs *buf)
1700{ 1778{
1701 int fd = openat (dirfd, path, O_SEARCH | O_CLOEXEC); 1779 int fd = openat (dirfd, path, EIO_O_PATH | O_CLOEXEC | O_NONBLOCK);
1702 int res; 1780 int res;
1703 1781
1704 if (fd < 0) 1782 if (fd < 0)
1705 return fd; 1783 return fd;
1706 1784
1707 res = fstatvfs (fd, buf); 1785 res = fstatvfs (fd, buf);
1708 close (fd); 1786 silent_close (fd);
1709 return res; 1787 return res;
1710
1711} 1788}
1712 1789
1713#endif 1790#endif
1714 1791
1715/*****************************************************************************/ 1792/*****************************************************************************/
1723 req->ptr2 = malloc (len); \ 1800 req->ptr2 = malloc (len); \
1724 if (!req->ptr2) \ 1801 if (!req->ptr2) \
1725 { \ 1802 { \
1726 errno = ENOMEM; \ 1803 errno = ENOMEM; \
1727 req->result = -1; \ 1804 req->result = -1; \
1728 break; \ 1805 goto alloc_fail; \
1729 } \ 1806 } \
1730 } 1807 }
1731 1808
1732/*****************************************************************************/ 1809/*****************************************************************************/
1810
1811static void
1812eio__slurp (int fd, eio_req *req)
1813{
1814 req->result = fd;
1815
1816 if (fd < 0)
1817 return;
1818
1819 if (req->offs < 0 || !req->size) /* do we need the size? */
1820 {
1821 off_t size = lseek (fd, 0, SEEK_END);
1822
1823 if (req->offs < 0)
1824 req->offs += size;
1825
1826 if (!req->size)
1827 req->size = size - req->offs;
1828 }
1829
1830 ALLOC (req->size);
1831 req->result = pread (fd, req->ptr2, req->size, req->offs);
1832
1833 silent_close (fd);
1834
1835alloc_fail:
1836 ;
1837}
1733 1838
1734int ecb_cold 1839int ecb_cold
1735eio_init (void (*want_poll)(void), void (*done_poll)(void)) 1840eio_init (void (*want_poll)(void), void (*done_poll)(void))
1736{ 1841{
1737 eio_want_poll_cb = want_poll; 1842 eio_want_poll_cb = want_poll;
1835 req->result = fstatat (dirfd, req->ptr1, (EIO_STRUCT_STAT *)req->ptr2, AT_SYMLINK_NOFOLLOW); break; 1940 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; 1941 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; 1942 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; 1943 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; 1944 case EIO_OPEN: req->result = openat (dirfd, req->ptr1, req->int1, (mode_t)req->int2); break;
1945 case EIO_SLURP: eio__slurp ( openat (dirfd, req->ptr1, O_RDONLY | O_CLOEXEC), req); break;
1840 1946
1841 case EIO_UNLINK: req->result = unlinkat (dirfd, req->ptr1, 0); break; 1947 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 */ 1948 case EIO_RMDIR: /* complications arise because "." cannot be removed, so we might have to expand */
1843 req->result = req->wd && SINGLEDOT (req->ptr1) 1949 req->result = req->wd && SINGLEDOT (req->ptr1)
1844 ? rmdir (req->wd->str) 1950 ? rmdir (req->wd->str)
1845 : unlinkat (dirfd, req->ptr1, AT_REMOVEDIR); break; 1951 : unlinkat (dirfd, req->ptr1, AT_REMOVEDIR); break;
1846 case EIO_MKDIR: req->result = mkdirat (dirfd, req->ptr1, (mode_t)req->int2); break; 1952 case EIO_MKDIR: req->result = mkdirat (dirfd, req->ptr1, (mode_t)req->int2); break;
1953 case EIO_RENAME: req->result = eio__renameat2 (
1954 dirfd,
1847 case EIO_RENAME: /* complications arise because "." cannot be renamed, so we might have to expand */ 1955 /* complications arise because "." cannot be renamed, so we might have to expand */
1848 req->result = req->wd && SINGLEDOT (req->ptr1) 1956 req->wd && SINGLEDOT (req->ptr1) ? req->wd->str : req->ptr1,
1849 ? rename (req->wd->str, req->ptr2) 1957 WD2FD ((eio_wd)req->int3),
1850 : renameat (dirfd, req->ptr1, WD2FD ((eio_wd)req->int3), req->ptr2); break; 1958 req->ptr2,
1959 req->int2
1960 );
1961 break;
1851 case EIO_LINK: req->result = linkat (dirfd, req->ptr1, WD2FD ((eio_wd)req->int3), req->ptr2, 0); break; 1962 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; 1963 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; 1964 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)); 1965 case EIO_STATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS));
1855 req->result = eio__statvfsat (dirfd, req->ptr1, (EIO_STRUCT_STATVFS *)req->ptr2); break; 1966 req->result = eio__statvfsat (dirfd, req->ptr1, (EIO_STRUCT_STATVFS *)req->ptr2); break;
1893 req->result = lstat (path , (EIO_STRUCT_STAT *)req->ptr2); break; 2004 req->result = lstat (path , (EIO_STRUCT_STAT *)req->ptr2); break;
1894 case EIO_CHOWN: req->result = chown (path , req->int2, req->int3); break; 2005 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; 2006 case EIO_CHMOD: req->result = chmod (path , (mode_t)req->int2); break;
1896 case EIO_TRUNCATE: req->result = truncate (path , req->offs); break; 2007 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; 2008 case EIO_OPEN: req->result = open (path , req->int1, (mode_t)req->int2); break;
2009 case EIO_SLURP: eio__slurp ( open (path , O_RDONLY | O_CLOEXEC), req); break;
1898 2010
1899 case EIO_UNLINK: req->result = unlink (path ); break; 2011 case EIO_UNLINK: req->result = unlink (path ); break;
1900 case EIO_RMDIR: req->result = rmdir (path ); break; 2012 case EIO_RMDIR: req->result = rmdir (path ); break;
1901 case EIO_MKDIR: req->result = mkdir (path , (mode_t)req->int2); break; 2013 case EIO_MKDIR: req->result = mkdir (path , (mode_t)req->int2); break;
1902 case EIO_RENAME: req->result = rename (path , req->ptr2); break; 2014 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; 2015 case EIO_LINK: req->result = link (path , req->ptr2); break;
1904 case EIO_SYMLINK: req->result = symlink (path , req->ptr2); break; 2016 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; 2017 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)); 2018 case EIO_STATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS));
1907 req->result = statvfs (path , (EIO_STRUCT_STATVFS *)req->ptr2); break; 2019 req->result = statvfs (path , (EIO_STRUCT_STATVFS *)req->ptr2); break;
1955 2067
1956 case EIO_FCHOWN: req->result = fchown (req->int1, req->int2, req->int3); break; 2068 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; 2069 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; 2070 case EIO_FTRUNCATE: req->result = ftruncate (req->int1, req->offs); break;
1959 2071
1960 case EIO_CLOSE: req->result = close (req->int1); break; 2072 case EIO_CLOSE: req->result = eio__close (req->int1); break;
1961 case EIO_DUP2: req->result = dup2 (req->int1, req->int2); break; 2073 case EIO_DUP2: req->result = dup2 (req->int1, req->int2); break;
1962 case EIO_SYNC: req->result = 0; sync (); break; 2074 case EIO_SYNC: req->result = 0; sync (); break;
1963 case EIO_FSYNC: req->result = fsync (req->int1); break; 2075 case EIO_FSYNC: req->result = fsync (req->int1); break;
1964 case EIO_FDATASYNC: req->result = fdatasync (req->int1); break; 2076 case EIO_FDATASYNC: req->result = fdatasync (req->int1); break;
1965 case EIO_SYNCFS: req->result = eio__syncfs (req->int1); break; 2077 case EIO_SYNCFS: req->result = eio__syncfs (req->int1); break;
2003 default: 2115 default:
2004 req->result = EIO_ENOSYS (); 2116 req->result = EIO_ENOSYS ();
2005 break; 2117 break;
2006 } 2118 }
2007 2119
2120alloc_fail:
2008 req->errorno = errno; 2121 req->errorno = errno;
2009} 2122}
2010 2123
2011#ifndef EIO_NO_WRAPPERS 2124#ifndef EIO_NO_WRAPPERS
2012 2125
2265eio_req *eio_rename (const char *path, const char *new_path, int pri, eio_cb cb, void *data) 2378eio_req *eio_rename (const char *path, const char *new_path, int pri, eio_cb cb, void *data)
2266{ 2379{
2267 return eio__2path (EIO_RENAME, path, new_path, pri, cb, data); 2380 return eio__2path (EIO_RENAME, path, new_path, pri, cb, data);
2268} 2381}
2269 2382
2383eio_req *eio_slurp (const char *path, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data)
2384{
2385 REQ (EIO_SLURP); PATH; req->offs = offset; req->size = length; req->ptr2 = buf; SEND;
2386}
2387
2270eio_req *eio_custom (void (*execute)(eio_req *), int pri, eio_cb cb, void *data) 2388eio_req *eio_custom (void (*execute)(eio_req *), int pri, eio_cb cb, void *data)
2271{ 2389{
2272 REQ (EIO_CUSTOM); req->feed = execute; SEND; 2390 REQ (EIO_CUSTOM); req->feed = execute; SEND;
2273} 2391}
2274 2392
2331eio_sendfile_sync (int ofd, int ifd, off_t offset, size_t count) 2449eio_sendfile_sync (int ofd, int ifd, off_t offset, size_t count)
2332{ 2450{
2333 return eio__sendfile (ofd, ifd, offset, count); 2451 return eio__sendfile (ofd, ifd, offset, count);
2334} 2452}
2335 2453
2454int eio_mlockall_sync (int flags)
2455{
2456 return eio__mlockall (flags);
2457}
2458

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines