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.152 by root, Fri Aug 17 17:16:22 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 *
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
316# define NAME_MAX 4096 322# define NAME_MAX 4096
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 4096 327# define PATH_MAX 0
322#endif 328#endif
329
330#ifndef O_CLOEXEC
331 #define O_CLOEXEC 0
332#endif
333
334#ifndef EIO_PATH_MIN
335# define EIO_PATH_MIN 8160
336#endif
337
338#define EIO_PATH_MAX (PATH_MAX <= EIO_PATH_MIN ? EIO_PATH_MIN : PATH_MAX)
323 339
324/* buffer size for various temporary buffers */ 340/* buffer size for various temporary buffers */
325#define EIO_BUFSIZE 65536 341#define EIO_BUFSIZE 65536
326 342
327#define dBUF \ 343#define dBUF \
541} 557}
542 558
543/*****************************************************************************/ 559/*****************************************************************************/
544/* work around various missing functions */ 560/* work around various missing functions */
545 561
562#if HAVE_POSIX_CLOSE && !__linux
563# define eio__close(fd) posix_close (fd, 0)
564#else
565# define eio__close(fd) close (fd)
566#endif
567
568/* close() without disturbing errno */
569static void
570silent_close (int fd)
571{
572 int saved_errno = errno;
573 eio__close (fd);
574 errno = saved_errno;
575}
576
546#ifndef HAVE_UTIMES 577#ifndef HAVE_UTIMES
547 578
548# undef utimes 579# undef utimes
549# define utimes(path,times) eio__utimes (path, times) 580# define utimes(path,times) eio__utimes (path, times)
550 581
928 intptr_t end = addr + len; 959 intptr_t end = addr + len;
929 intptr_t page = eio_pagesize (); 960 intptr_t page = eio_pagesize ();
930 961
931 if (addr < end) 962 if (addr < end)
932 if (flags & EIO_MT_MODIFY) /* modify */ 963 if (flags & EIO_MT_MODIFY) /* modify */
933 do { *((volatile sig_atomic_t *)addr) |= 0; } while ((addr += page) < len && !EIO_CANCELLED (req)); 964 do { *((volatile sig_atomic_t *)addr) |= 0; } while ((addr += page) < end && !EIO_CANCELLED (req));
934 else 965 else
935 do { *((volatile sig_atomic_t *)addr) ; } while ((addr += page) < len && !EIO_CANCELLED (req)); 966 do { *((volatile sig_atomic_t *)addr) ; } while ((addr += page) < end && !EIO_CANCELLED (req));
936 } 967 }
937 968
938 return 0; 969 return 0;
939} 970}
940 971
974 1005
975 errno = ENOENT; 1006 errno = ENOENT;
976 if (!*rel) 1007 if (!*rel)
977 return -1; 1008 return -1;
978 1009
979 res = etp_tmpbuf_get (tmpbuf, PATH_MAX * 3); 1010 res = etp_tmpbuf_get (tmpbuf, EIO_PATH_MAX * 3);
980#ifdef _WIN32 1011#ifdef _WIN32
981 if (_access (rel, 4) != 0) 1012 if (_access (rel, 4) != 0)
982 return -1; 1013 return -1;
983 1014
984 symlinks = GetFullPathName (rel, PATH_MAX * 3, res, 0); 1015 symlinks = GetFullPathName (rel, EIO_PATH_MAX * 3, res, 0);
985 1016
986 errno = ENAMETOOLONG; 1017 errno = ENAMETOOLONG;
987 if (symlinks >= PATH_MAX * 3) 1018 if (symlinks >= EIO_PATH_MAX * 3)
988 return -1; 1019 return -1;
989 1020
990 errno = EIO; 1021 errno = EIO;
991 if (symlinks <= 0) 1022 if (symlinks <= 0)
992 return -1; 1023 return -1;
993 1024
994 return symlinks; 1025 return symlinks;
995 1026
996#else 1027#else
997 tmp1 = res + PATH_MAX; 1028 tmp1 = res + EIO_PATH_MAX;
998 tmp2 = tmp1 + PATH_MAX; 1029 tmp2 = tmp1 + EIO_PATH_MAX;
999 1030
1000#if 0 /* disabled, the musl way to do things is just too racy */ 1031#if 0 /* disabled, the musl way to do things is just too racy */
1001#if __linux && defined(O_NONBLOCK) && defined(O_NOATIME) 1032#if __linux && defined(O_NONBLOCK) && defined(O_NOATIME)
1002 /* on linux we may be able to ask the kernel */ 1033 /* on linux we may be able to ask the kernel */
1003 { 1034 {
1004 int fd = open (rel, O_RDONLY | O_NONBLOCK | O_NOCTTY | O_NOATIME); 1035 int fd = open (rel, O_RDONLY | O_NONBLOCK | O_NOCTTY | O_NOATIME);
1005 1036
1006 if (fd >= 0) 1037 if (fd >= 0)
1007 { 1038 {
1008 sprintf (tmp1, "/proc/self/fd/%d", fd); 1039 sprintf (tmp1, "/proc/self/fd/%d", fd);
1009 req->result = readlink (tmp1, res, PATH_MAX); 1040 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 */ 1041 /* here we should probably stat the open file and the disk file, to make sure they still match */
1011 close (fd); 1042 eio__close (fd);
1012 1043
1013 if (req->result > 0) 1044 if (req->result > 0)
1014 goto done; 1045 goto done;
1015 } 1046 }
1016 else if (errno == ELOOP || errno == ENAMETOOLONG || errno == ENOENT || errno == ENOTDIR || errno == EIO) 1047 else if (errno == ELOOP || errno == ENAMETOOLONG || errno == ENOENT || errno == ENOTDIR || errno == EIO)
1027 if (wd == EIO_INVALID_WD) 1058 if (wd == EIO_INVALID_WD)
1028 return -1; 1059 return -1;
1029 1060
1030 if (wd == EIO_CWD) 1061 if (wd == EIO_CWD)
1031 { 1062 {
1032 if (!getcwd (res, PATH_MAX)) 1063 if (!getcwd (res, EIO_PATH_MAX))
1033 return -1; 1064 return -1;
1034 1065
1035 len = strlen (res); 1066 len = strlen (res);
1036 } 1067 }
1037 else 1068 else
1084 1115
1085 /* zero-terminate, for readlink */ 1116 /* zero-terminate, for readlink */
1086 res [len + 1] = 0; 1117 res [len + 1] = 0;
1087 1118
1088 /* now check if it's a symlink */ 1119 /* now check if it's a symlink */
1089 linklen = readlink (tmpbuf->ptr, tmp1, PATH_MAX); 1120 linklen = readlink (tmpbuf->ptr, tmp1, EIO_PATH_MAX);
1090 1121
1091 if (linklen < 0) 1122 if (linklen < 0)
1092 { 1123 {
1093 if (errno != EINVAL) 1124 if (errno != EINVAL)
1094 return -1; 1125 return -1;
1100 { 1131 {
1101 /* yay, it was a symlink - build new path in tmp2 */ 1132 /* yay, it was a symlink - build new path in tmp2 */
1102 int rellen = strlen (rel); 1133 int rellen = strlen (rel);
1103 1134
1104 errno = ENAMETOOLONG; 1135 errno = ENAMETOOLONG;
1105 if (linklen + 1 + rellen >= PATH_MAX) 1136 if (linklen + 1 + rellen >= EIO_PATH_MAX) /* also catch linklen >= EIO_PATH_MAX */
1106 return -1; 1137 return -1;
1107 1138
1108 errno = ELOOP; 1139 errno = ELOOP;
1109 if (!--symlinks) 1140 if (!--symlinks)
1110 return -1; 1141 return -1;
1364 return; 1395 return;
1365 } 1396 }
1366 } 1397 }
1367#else 1398#else
1368 #if HAVE_AT 1399 #if HAVE_AT
1369 if (req->wd)
1370 { 1400 {
1371 int fd = openat (WD2FD (req->wd), req->ptr1, O_CLOEXEC | O_SEARCH | O_DIRECTORY); 1401 int fd = openat (WD2FD (req->wd), req->ptr1, O_CLOEXEC | O_SEARCH | O_DIRECTORY);
1372 1402
1373 if (fd < 0) 1403 if (fd < 0)
1374 return; 1404 return;
1375 1405
1376 dirp = fdopendir (fd); 1406 dirp = fdopendir (fd);
1377 1407
1378 if (!dirp) 1408 if (!dirp)
1379 close (fd); 1409 silent_close (fd);
1380 } 1410 }
1381 else
1382 dirp = opendir (req->ptr1);
1383 #else 1411 #else
1384 dirp = opendir (wd_expand (&self->tmpbuf, req->wd, req->ptr1)); 1412 dirp = opendir (wd_expand (&self->tmpbuf, req->wd, req->ptr1));
1385 #endif 1413 #endif
1386 1414
1387 if (!dirp) 1415 if (!dirp)
1650} 1678}
1651 1679
1652eio_wd 1680eio_wd
1653eio_wd_open_sync (eio_wd wd, const char *path) 1681eio_wd_open_sync (eio_wd wd, const char *path)
1654{ 1682{
1655 struct etp_tmpbuf tmpbuf = { }; 1683 struct etp_tmpbuf tmpbuf = { 0 };
1656 wd = eio__wd_open_sync (&tmpbuf, wd, path); 1684 wd = eio__wd_open_sync (&tmpbuf, wd, path);
1657 free (tmpbuf.ptr); 1685 free (tmpbuf.ptr);
1658 1686
1659 return wd; 1687 return wd;
1660} 1688}
1663eio_wd_close_sync (eio_wd wd) 1691eio_wd_close_sync (eio_wd wd)
1664{ 1692{
1665 if (wd != EIO_INVALID_WD && wd != EIO_CWD) 1693 if (wd != EIO_INVALID_WD && wd != EIO_CWD)
1666 { 1694 {
1667 #if HAVE_AT 1695 #if HAVE_AT
1668 close (wd->fd); 1696 eio__close (wd->fd);
1669 #endif 1697 #endif
1670 free (wd); 1698 free (wd);
1671 } 1699 }
1672} 1700}
1673 1701
1674#if HAVE_AT 1702#if HAVE_AT
1675 1703
1704static int
1705eio__renameat2 (int olddirfd, const char *oldpath, int newdirfd, const char *newpath, unsigned int flags)
1706{
1707#if HAVE_RENAMEAT2
1708 return syscall (SYS_renameat2, olddirfd, oldpath, newdirfd, newpath, flags);
1709#else
1710 if (flags)
1711 return EIO_ENOSYS ();
1712
1713 return renameat (olddirfd, oldpath, newdirfd, newpath);
1714#endif
1715}
1716
1676/* they forgot these */ 1717/* they forgot these */
1677 1718
1678static int 1719static int
1679eio__truncateat (int dirfd, const char *path, off_t length) 1720eio__truncateat (int dirfd, const char *path, off_t length)
1680{ 1721{
1683 1724
1684 if (fd < 0) 1725 if (fd < 0)
1685 return fd; 1726 return fd;
1686 1727
1687 res = ftruncate (fd, length); 1728 res = ftruncate (fd, length);
1688 close (fd); 1729 silent_close (fd);
1689 return res; 1730 return res;
1690} 1731}
1691 1732
1692static int 1733static int
1693eio__statvfsat (int dirfd, const char *path, struct statvfs *buf) 1734eio__statvfsat (int dirfd, const char *path, struct statvfs *buf)
1697 1738
1698 if (fd < 0) 1739 if (fd < 0)
1699 return fd; 1740 return fd;
1700 1741
1701 res = fstatvfs (fd, buf); 1742 res = fstatvfs (fd, buf);
1702 close (fd); 1743 silent_close (fd);
1703 return res; 1744 return res;
1704
1705} 1745}
1706 1746
1707#endif 1747#endif
1708 1748
1709/*****************************************************************************/ 1749/*****************************************************************************/
1717 req->ptr2 = malloc (len); \ 1757 req->ptr2 = malloc (len); \
1718 if (!req->ptr2) \ 1758 if (!req->ptr2) \
1719 { \ 1759 { \
1720 errno = ENOMEM; \ 1760 errno = ENOMEM; \
1721 req->result = -1; \ 1761 req->result = -1; \
1722 break; \ 1762 goto alloc_fail; \
1723 } \ 1763 } \
1724 } 1764 }
1725 1765
1726/*****************************************************************************/ 1766/*****************************************************************************/
1767
1768static void
1769eio__slurp (int fd, eio_req *req)
1770{
1771 req->result = fd;
1772
1773 if (fd < 0)
1774 return;
1775
1776 if (req->offs < 0 || !req->size) /* do we need the size? */
1777 {
1778 off_t size = lseek (fd, 0, SEEK_END);
1779
1780 if (req->offs < 0)
1781 req->offs += size;
1782
1783 if (!req->size)
1784 req->size = size - req->offs;
1785 }
1786
1787 ALLOC (req->size);
1788 req->result = pread (fd, req->ptr2, req->size, req->offs);
1789
1790 silent_close (fd);
1791
1792alloc_fail:
1793 ;
1794}
1727 1795
1728int ecb_cold 1796int ecb_cold
1729eio_init (void (*want_poll)(void), void (*done_poll)(void)) 1797eio_init (void (*want_poll)(void), void (*done_poll)(void))
1730{ 1798{
1731 eio_want_poll_cb = want_poll; 1799 eio_want_poll_cb = want_poll;
1829 req->result = fstatat (dirfd, req->ptr1, (EIO_STRUCT_STAT *)req->ptr2, AT_SYMLINK_NOFOLLOW); break; 1897 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; 1898 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; 1899 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; 1900 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; 1901 case EIO_OPEN: req->result = openat (dirfd, req->ptr1, req->int1, (mode_t)req->int2); break;
1902 case EIO_SLURP: eio__slurp ( openat (dirfd, req->ptr1, O_RDONLY | O_CLOEXEC), req); break;
1834 1903
1835 case EIO_UNLINK: req->result = unlinkat (dirfd, req->ptr1, 0); break; 1904 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 */ 1905 case EIO_RMDIR: /* complications arise because "." cannot be removed, so we might have to expand */
1837 req->result = req->wd && SINGLEDOT (req->ptr1) 1906 req->result = req->wd && SINGLEDOT (req->ptr1)
1838 ? rmdir (req->wd->str) 1907 ? rmdir (req->wd->str)
1839 : unlinkat (dirfd, req->ptr1, AT_REMOVEDIR); break; 1908 : unlinkat (dirfd, req->ptr1, AT_REMOVEDIR); break;
1840 case EIO_MKDIR: req->result = mkdirat (dirfd, req->ptr1, (mode_t)req->int2); break; 1909 case EIO_MKDIR: req->result = mkdirat (dirfd, req->ptr1, (mode_t)req->int2); break;
1910 case EIO_RENAME: req->result = eio__renameat2 (
1911 dirfd,
1841 case EIO_RENAME: /* complications arise because "." cannot be renamed, so we might have to expand */ 1912 /* complications arise because "." cannot be renamed, so we might have to expand */
1842 req->result = req->wd && SINGLEDOT (req->ptr1) 1913 req->wd && SINGLEDOT (req->ptr1) ? req->wd->str : req->ptr1,
1843 ? rename (req->wd->str, req->ptr2) 1914 WD2FD ((eio_wd)req->int3),
1844 : renameat (dirfd, req->ptr1, WD2FD ((eio_wd)req->int3), req->ptr2); break; 1915 req->ptr2,
1916 req->int2
1917 );
1918 break;
1845 case EIO_LINK: req->result = linkat (dirfd, req->ptr1, WD2FD ((eio_wd)req->int3), req->ptr2, 0); break; 1919 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; 1920 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; 1921 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)); 1922 case EIO_STATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS));
1851 req->result = eio__statvfsat (dirfd, req->ptr1, (EIO_STRUCT_STATVFS *)req->ptr2); break; 1923 req->result = eio__statvfsat (dirfd, req->ptr1, (EIO_STRUCT_STATVFS *)req->ptr2); break;
1924 case EIO_READLINK: ALLOC (EIO_PATH_MAX);
1925 req->result = readlinkat (dirfd, req->ptr1, req->ptr2, EIO_PATH_MAX);
1926 if (req->result == EIO_PATH_MAX)
1927 {
1928 req->result = -1;
1929 errno = ENAMETOOLONG;
1930 }
1931 break;
1852 case EIO_UTIME: 1932 case EIO_UTIME:
1853 case EIO_FUTIME: 1933 case EIO_FUTIME:
1854 { 1934 {
1855 struct timespec ts[2]; 1935 struct timespec ts[2];
1856 struct timespec *times; 1936 struct timespec *times;
1881 req->result = lstat (path , (EIO_STRUCT_STAT *)req->ptr2); break; 1961 req->result = lstat (path , (EIO_STRUCT_STAT *)req->ptr2); break;
1882 case EIO_CHOWN: req->result = chown (path , req->int2, req->int3); break; 1962 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; 1963 case EIO_CHMOD: req->result = chmod (path , (mode_t)req->int2); break;
1884 case EIO_TRUNCATE: req->result = truncate (path , req->offs); break; 1964 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; 1965 case EIO_OPEN: req->result = open (path , req->int1, (mode_t)req->int2); break;
1966 case EIO_SLURP: eio__slurp ( open (path , O_RDONLY | O_CLOEXEC), req); break;
1886 1967
1887 case EIO_UNLINK: req->result = unlink (path ); break; 1968 case EIO_UNLINK: req->result = unlink (path ); break;
1888 case EIO_RMDIR: req->result = rmdir (path ); break; 1969 case EIO_RMDIR: req->result = rmdir (path ); break;
1889 case EIO_MKDIR: req->result = mkdir (path , (mode_t)req->int2); break; 1970 case EIO_MKDIR: req->result = mkdir (path , (mode_t)req->int2); break;
1890 case EIO_RENAME: req->result = rename (path , req->ptr2); break; 1971 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; 1972 case EIO_LINK: req->result = link (path , req->ptr2); break;
1892 case EIO_SYMLINK: req->result = symlink (path , req->ptr2); break; 1973 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; 1974 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)); 1975 case EIO_STATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS));
1897 req->result = statvfs (path , (EIO_STRUCT_STATVFS *)req->ptr2); break; 1976 req->result = statvfs (path , (EIO_STRUCT_STATVFS *)req->ptr2); break;
1977 case EIO_READLINK: ALLOC (EIO_PATH_MAX);
1978 req->result = readlink (path, req->ptr2, EIO_PATH_MAX);
1979 if (req->result == EIO_PATH_MAX)
1980 {
1981 req->result = -1;
1982 errno = ENAMETOOLONG;
1983 }
1984 break;
1898 1985
1899 case EIO_UTIME: 1986 case EIO_UTIME:
1900 case EIO_FUTIME: 1987 case EIO_FUTIME:
1901 { 1988 {
1902 struct timeval tv[2]; 1989 struct timeval tv[2];
1937 2024
1938 case EIO_FCHOWN: req->result = fchown (req->int1, req->int2, req->int3); break; 2025 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; 2026 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; 2027 case EIO_FTRUNCATE: req->result = ftruncate (req->int1, req->offs); break;
1941 2028
1942 case EIO_CLOSE: req->result = close (req->int1); break; 2029 case EIO_CLOSE: req->result = eio__close (req->int1); break;
1943 case EIO_DUP2: req->result = dup2 (req->int1, req->int2); break; 2030 case EIO_DUP2: req->result = dup2 (req->int1, req->int2); break;
1944 case EIO_SYNC: req->result = 0; sync (); break; 2031 case EIO_SYNC: req->result = 0; sync (); break;
1945 case EIO_FSYNC: req->result = fsync (req->int1); break; 2032 case EIO_FSYNC: req->result = fsync (req->int1); break;
1946 case EIO_FDATASYNC: req->result = fdatasync (req->int1); break; 2033 case EIO_FDATASYNC: req->result = fdatasync (req->int1); break;
1947 case EIO_SYNCFS: req->result = eio__syncfs (req->int1); break; 2034 case EIO_SYNCFS: req->result = eio__syncfs (req->int1); break;
1985 default: 2072 default:
1986 req->result = EIO_ENOSYS (); 2073 req->result = EIO_ENOSYS ();
1987 break; 2074 break;
1988 } 2075 }
1989 2076
2077alloc_fail:
1990 req->errorno = errno; 2078 req->errorno = errno;
1991} 2079}
1992 2080
1993#ifndef EIO_NO_WRAPPERS 2081#ifndef EIO_NO_WRAPPERS
1994 2082
2247eio_req *eio_rename (const char *path, const char *new_path, int pri, eio_cb cb, void *data) 2335eio_req *eio_rename (const char *path, const char *new_path, int pri, eio_cb cb, void *data)
2248{ 2336{
2249 return eio__2path (EIO_RENAME, path, new_path, pri, cb, data); 2337 return eio__2path (EIO_RENAME, path, new_path, pri, cb, data);
2250} 2338}
2251 2339
2340eio_req *eio_slurp (const char *path, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data)
2341{
2342 REQ (EIO_SLURP); PATH; req->offs = offset; req->size = length; req->ptr2 = buf; SEND;
2343}
2344
2252eio_req *eio_custom (void (*execute)(eio_req *), int pri, eio_cb cb, void *data) 2345eio_req *eio_custom (void (*execute)(eio_req *), int pri, eio_cb cb, void *data)
2253{ 2346{
2254 REQ (EIO_CUSTOM); req->feed = execute; SEND; 2347 REQ (EIO_CUSTOM); req->feed = execute; SEND;
2255} 2348}
2256 2349

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines