Lines Matching refs:req
63 if (req == NULL) \
65 uv__fs_req_init(loop, req, subtype, cb); \
74 &req->work_req, \
80 uv__fs_work(&req->work_req); \
81 return req->result; \
86 #define SET_REQ_RESULT(req, result_value) \ argument
88 req->result = (result_value); \
89 assert(req->result != -1); \
92 #define SET_REQ_WIN32_ERROR(req, sys_errno) \ argument
94 req->sys_errno_ = (sys_errno); \
95 req->result = uv_translate_sys_error(req->sys_errno_); \
98 #define SET_REQ_UV_ERROR(req, uv_errno, sys_errno) \ argument
100 req->result = (uv_errno); \
101 req->sys_errno_ = (sys_errno); \
104 #define VERIFY_FD(fd, req) \ argument
106 req->result = UV_EBADF; \
107 req->sys_errno_ = ERROR_INVALID_HANDLE; \
309 INLINE static int fs__capture_path(uv_fs_t* req, const char* path, in fs__capture_path() argument
342 req->file.pathw = NULL; in fs__capture_path()
343 req->fs.info.new_pathw = NULL; in fs__capture_path()
344 req->path = NULL; in fs__capture_path()
357 req->file.pathw = pos; in fs__capture_path()
360 req->file.pathw = NULL; in fs__capture_path()
365 req->fs.info.new_pathw = pos; in fs__capture_path()
368 req->fs.info.new_pathw = NULL; in fs__capture_path()
371 req->path = path; in fs__capture_path()
375 req->path = (char*) pos; in fs__capture_path()
378 req->flags |= UV_FS_FREE_PATHS; in fs__capture_path()
384 INLINE static void uv__fs_req_init(uv_loop_t* loop, uv_fs_t* req, in uv__fs_req_init() argument
387 UV_REQ_INIT(req, UV_FS); in uv__fs_req_init()
388 req->loop = loop; in uv__fs_req_init()
389 req->flags = 0; in uv__fs_req_init()
390 req->fs_type = fs_type; in uv__fs_req_init()
391 req->sys_errno_ = 0; in uv__fs_req_init()
392 req->result = 0; in uv__fs_req_init()
393 req->ptr = NULL; in uv__fs_req_init()
394 req->path = NULL; in uv__fs_req_init()
395 req->cb = cb; in uv__fs_req_init()
396 memset(&req->fs, 0, sizeof(req->fs)); in uv__fs_req_init()
400 void fs__open(uv_fs_t* req) { in fs__open() argument
407 int flags = req->fs.info.file_flags; in fs__open()
496 if (!((req->fs.info.mode & ~current_umask) & _S_IWRITE)) { in fs__open()
568 file = CreateFileW(req->file.pathw, in fs__open()
581 SET_REQ_UV_ERROR(req, UV_EISDIR, error); in fs__open()
583 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__open()
595 SET_REQ_UV_ERROR(req, UV_EMFILE, ERROR_TOO_MANY_OPEN_FILES); in fs__open()
597 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__open()
599 SET_REQ_WIN32_ERROR(req, (DWORD) UV_UNKNOWN); in fs__open()
610 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__open()
621 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__open()
638 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__open()
648 SET_REQ_RESULT(req, fd); in fs__open()
652 SET_REQ_UV_ERROR(req, UV_EINVAL, ERROR_INVALID_PARAMETER); in fs__open()
655 void fs__close(uv_fs_t* req) { in fs__close() argument
656 int fd = req->file.fd; in fs__close()
660 VERIFY_FD(fd, req); in fs__close()
678 SET_REQ_UV_ERROR(req, UV_EBADF, ERROR_INVALID_HANDLE); in fs__close()
680 SET_REQ_RESULT(req, 0); in fs__close()
705 void fs__read_filemap(uv_fs_t* req, struct uv__fd_info_s* fd_info) { in fs__read_filemap() argument
706 int fd = req->file.fd; /* VERIFY_FD done in fs__read */ in fs__read_filemap()
717 SET_REQ_WIN32_ERROR(req, ERROR_INVALID_FLAGS); in fs__read_filemap()
721 SET_REQ_WIN32_ERROR(req, ERROR_INVALID_FUNCTION); in fs__read_filemap()
725 if (req->fs.info.offset == -1) { in fs__read_filemap()
728 pos.QuadPart = req->fs.info.offset; in fs__read_filemap()
733 SET_REQ_RESULT(req, 0); in fs__read_filemap()
738 for (index = 0; index < req->fs.info.nbufs; ++index) { in fs__read_filemap()
739 read_size += req->fs.info.bufs[index].len; in fs__read_filemap()
744 SET_REQ_RESULT(req, 0); in fs__read_filemap()
758 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__read_filemap()
764 index < req->fs.info.nbufs && done_read < read_size; in fs__read_filemap()
766 size_t this_read_size = MIN(req->fs.info.bufs[index].len, in fs__read_filemap()
772 memcpy(req->fs.info.bufs[index].base, in fs__read_filemap()
779 SET_REQ_WIN32_ERROR(req, err); in fs__read_filemap()
789 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__read_filemap()
793 if (req->fs.info.offset == -1) { in fs__read_filemap()
798 SET_REQ_RESULT(req, read_size); in fs__read_filemap()
802 void fs__read(uv_fs_t* req) { in fs__read() argument
803 int fd = req->file.fd; in fs__read()
804 int64_t offset = req->fs.info.offset; in fs__read()
817 VERIFY_FD(fd, req); in fs__read()
820 fs__read_filemap(req, &fd_info); in fs__read()
829 SET_REQ_WIN32_ERROR(req, ERROR_INVALID_HANDLE); in fs__read()
856 req->fs.info.bufs[index].base, in fs__read()
857 req->fs.info.bufs[index].len, in fs__read()
862 } while (result && index < req->fs.info.nbufs); in fs__read()
868 SET_REQ_RESULT(req, bytes); in fs__read()
876 SET_REQ_RESULT(req, bytes); in fs__read()
878 SET_REQ_WIN32_ERROR(req, error); in fs__read()
884 void fs__write_filemap(uv_fs_t* req, HANDLE file, in fs__write_filemap() argument
886 int fd = req->file.fd; /* VERIFY_FD done in fs__write */ in fs__write_filemap()
899 SET_REQ_WIN32_ERROR(req, ERROR_INVALID_FLAGS); in fs__write_filemap()
903 SET_REQ_WIN32_ERROR(req, ERROR_INVALID_FUNCTION); in fs__write_filemap()
908 for (index = 0; index < req->fs.info.nbufs; ++index) { in fs__write_filemap()
909 write_size += req->fs.info.bufs[index].len; in fs__write_filemap()
913 SET_REQ_RESULT(req, 0); in fs__write_filemap()
919 } else if (req->fs.info.offset == -1) { in fs__write_filemap()
922 pos.QuadPart = req->fs.info.offset; in fs__write_filemap()
940 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__write_filemap()
961 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__write_filemap()
966 for (index = 0; index < req->fs.info.nbufs; ++index) { in fs__write_filemap()
972 req->fs.info.bufs[index].base, in fs__write_filemap()
973 req->fs.info.bufs[index].len); in fs__write_filemap()
978 SET_REQ_WIN32_ERROR(req, err); in fs__write_filemap()
983 done_write += req->fs.info.bufs[index].len; in fs__write_filemap()
988 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__write_filemap()
993 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__write_filemap()
997 if (req->fs.info.offset == -1) { in fs__write_filemap()
1005 SET_REQ_RESULT(req, done_write); in fs__write_filemap()
1008 void fs__write(uv_fs_t* req) { in fs__write() argument
1009 int fd = req->file.fd; in fs__write()
1010 int64_t offset = req->fs.info.offset; in fs__write()
1023 VERIFY_FD(fd, req); in fs__write()
1029 SET_REQ_WIN32_ERROR(req, ERROR_INVALID_HANDLE); in fs__write()
1034 fs__write_filemap(req, handle, &fd_info); in fs__write()
1061 req->fs.info.bufs[index].base, in fs__write()
1062 req->fs.info.bufs[index].len, in fs__write()
1067 } while (result && index < req->fs.info.nbufs); in fs__write()
1073 SET_REQ_RESULT(req, bytes); in fs__write()
1081 SET_REQ_UV_ERROR(req, uv_translate_write_sys_error(error), error); in fs__write()
1086 static void fs__unlink_rmdir(uv_fs_t* req, BOOL isrmdir) { in fs__unlink_rmdir() argument
1087 const WCHAR* pathw = req->file.pathw; in fs__unlink_rmdir()
1105 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__unlink_rmdir()
1110 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__unlink_rmdir()
1118 SET_REQ_UV_ERROR(req, UV_ENOENT, ERROR_DIRECTORY); in fs__unlink_rmdir()
1130 SET_REQ_WIN32_ERROR(req, ERROR_ACCESS_DENIED); in fs__unlink_rmdir()
1141 SET_REQ_WIN32_ERROR(req, error); in fs__unlink_rmdir()
1157 SET_REQ_SUCCESS(req); in fs__unlink_rmdir()
1181 SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(status)); in fs__unlink_rmdir()
1195 SET_REQ_SUCCESS(req); in fs__unlink_rmdir()
1197 SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(status)); in fs__unlink_rmdir()
1200 SET_REQ_WIN32_ERROR(req, error); in fs__unlink_rmdir()
1208 static void fs__rmdir(uv_fs_t* req) { in fs__rmdir() argument
1209 fs__unlink_rmdir(req, /*isrmdir*/1); in fs__rmdir()
1213 static void fs__unlink(uv_fs_t* req) { in fs__unlink() argument
1214 fs__unlink_rmdir(req, /*isrmdir*/0); in fs__unlink()
1218 void fs__mkdir(uv_fs_t* req) { in fs__mkdir() argument
1220 if (CreateDirectoryW(req->file.pathw, NULL)) { in fs__mkdir()
1221 SET_REQ_RESULT(req, 0); in fs__mkdir()
1223 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__mkdir()
1224 if (req->sys_errno_ == ERROR_INVALID_NAME || in fs__mkdir()
1225 req->sys_errno_ == ERROR_DIRECTORY) in fs__mkdir()
1226 req->result = UV_EINVAL; in fs__mkdir()
1230 typedef int (*uv__fs_mktemp_func)(uv_fs_t* req);
1233 void fs__mktemp(uv_fs_t* req, uv__fs_mktemp_func func) { in fs__mktemp() argument
1244 path = (char*)req->path; in fs__mktemp()
1245 len = wcslen(req->file.pathw); in fs__mktemp()
1246 ep = req->file.pathw + len; in fs__mktemp()
1248 SET_REQ_UV_ERROR(req, UV_EINVAL, ERROR_INVALID_PARAMETER); in fs__mktemp()
1255 SET_REQ_UV_ERROR(req, UV_EIO, ERROR_IO_DEVICE); in fs__mktemp()
1265 if (func(req)) { in fs__mktemp()
1266 if (req->result >= 0) { in fs__mktemp()
1274 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__mktemp()
1281 static int fs__mkdtemp_func(uv_fs_t* req) { in fs__mkdtemp_func() argument
1283 if (CreateDirectoryW(req->file.pathw, NULL)) { in fs__mkdtemp_func()
1284 SET_REQ_RESULT(req, 0); in fs__mkdtemp_func()
1289 SET_REQ_WIN32_ERROR(req, error); in fs__mkdtemp_func()
1297 void fs__mkdtemp(uv_fs_t* req) { in fs__mkdtemp() argument
1298 fs__mktemp(req, fs__mkdtemp_func); in fs__mkdtemp()
1302 static int fs__mkstemp_func(uv_fs_t* req) { in fs__mkstemp_func() argument
1306 file = CreateFileW(req->file.pathw, in fs__mkstemp_func()
1321 SET_REQ_WIN32_ERROR(req, error); in fs__mkstemp_func()
1335 SET_REQ_UV_ERROR(req, UV_EMFILE, ERROR_TOO_MANY_OPEN_FILES); in fs__mkstemp_func()
1337 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__mkstemp_func()
1339 SET_REQ_WIN32_ERROR(req, UV_UNKNOWN); in fs__mkstemp_func()
1344 SET_REQ_RESULT(req, fd); in fs__mkstemp_func()
1350 void fs__mkstemp(uv_fs_t* req) { in fs__mkstemp() argument
1351 fs__mktemp(req, fs__mkstemp_func); in fs__mkstemp()
1355 void fs__scandir(uv_fs_t* req) { in fs__scandir() argument
1384 CreateFileW(req->file.pathw, in fs__scandir()
1520 req->ptr = dirents; in fs__scandir()
1522 req->flags |= UV_FS_FREE_PTR; in fs__scandir()
1524 SET_REQ_RESULT(req, dirents_used); in fs__scandir()
1527 req->fs.info.nbufs = 0; in fs__scandir()
1532 SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(status)); in fs__scandir()
1536 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__scandir()
1540 SET_REQ_UV_ERROR(req, UV_ENOTDIR, ERROR_DIRECTORY); in fs__scandir()
1544 SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY); in fs__scandir()
1556 void fs__opendir(uv_fs_t* req) { in fs__opendir() argument
1563 pathw = req->file.pathw; in fs__opendir()
1569 SET_REQ_UV_ERROR(req, UV_ENOTDIR, ERROR_DIRECTORY); in fs__opendir()
1575 SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY); in fs__opendir()
1590 SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY); in fs__opendir()
1600 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__opendir()
1605 req->ptr = dir; in fs__opendir()
1606 SET_REQ_RESULT(req, 0); in fs__opendir()
1612 req->ptr = NULL; in fs__opendir()
1615 void fs__readdir(uv_fs_t* req) { in fs__readdir() argument
1624 req->flags |= UV_FS_FREE_PTR; in fs__readdir()
1625 dir = req->ptr; in fs__readdir()
1668 SET_REQ_RESULT(req, dirent_idx); in fs__readdir()
1672 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__readdir()
1679 void fs__closedir(uv_fs_t* req) { in fs__closedir() argument
1682 dir = req->ptr; in fs__closedir()
1684 uv__free(req->ptr); in fs__closedir()
1685 SET_REQ_RESULT(req, 0); in fs__closedir()
1988 INLINE static void fs__stat_impl(uv_fs_t* req, int do_lstat) { in fs__stat_impl() argument
1991 error = fs__stat_impl_from_path(req->file.pathw, do_lstat, &req->statbuf); in fs__stat_impl()
1997 fs__stat_impl(req, 0); in fs__stat_impl()
2000 SET_REQ_WIN32_ERROR(req, error); in fs__stat_impl()
2006 req->ptr = &req->statbuf; in fs__stat_impl()
2007 SET_REQ_RESULT(req, 0); in fs__stat_impl()
2042 static void fs__stat(uv_fs_t* req) { in fs__stat() argument
2043 fs__stat_prepare_path(req->file.pathw); in fs__stat()
2044 fs__stat_impl(req, 0); in fs__stat()
2048 static void fs__lstat(uv_fs_t* req) { in fs__lstat() argument
2049 fs__stat_prepare_path(req->file.pathw); in fs__lstat()
2050 fs__stat_impl(req, 1); in fs__lstat()
2054 static void fs__fstat(uv_fs_t* req) { in fs__fstat() argument
2055 int fd = req->file.fd; in fs__fstat()
2058 VERIFY_FD(fd, req); in fs__fstat()
2063 SET_REQ_WIN32_ERROR(req, ERROR_INVALID_HANDLE); in fs__fstat()
2067 if (fs__fstat_handle(fd, handle, &req->statbuf) != 0) { in fs__fstat()
2068 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__fstat()
2072 req->ptr = &req->statbuf; in fs__fstat()
2073 SET_REQ_RESULT(req, 0); in fs__fstat()
2077 static void fs__rename(uv_fs_t* req) { in fs__rename() argument
2078 if (!MoveFileExW(req->file.pathw, req->fs.info.new_pathw, MOVEFILE_REPLACE_EXISTING)) { in fs__rename()
2079 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__rename()
2083 SET_REQ_RESULT(req, 0); in fs__rename()
2087 INLINE static void fs__sync_impl(uv_fs_t* req) { in fs__sync_impl() argument
2088 int fd = req->file.fd; in fs__sync_impl()
2091 VERIFY_FD(fd, req); in fs__sync_impl()
2095 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__sync_impl()
2097 SET_REQ_RESULT(req, result); in fs__sync_impl()
2102 static void fs__fsync(uv_fs_t* req) { in fs__fsync() argument
2103 fs__sync_impl(req); in fs__fsync()
2107 static void fs__fdatasync(uv_fs_t* req) { in fs__fdatasync() argument
2108 fs__sync_impl(req); in fs__fdatasync()
2112 static void fs__ftruncate(uv_fs_t* req) { in fs__ftruncate() argument
2113 int fd = req->file.fd; in fs__ftruncate()
2120 VERIFY_FD(fd, req); in fs__ftruncate()
2126 SET_REQ_WIN32_ERROR(req, ERROR_ACCESS_DENIED); in fs__ftruncate()
2135 eof_info.EndOfFile.QuadPart = req->fs.info.offset; in fs__ftruncate()
2144 SET_REQ_RESULT(req, 0); in fs__ftruncate()
2146 SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(status)); in fs__ftruncate()
2173 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__ftruncate()
2188 static void fs__copyfile(uv_fs_t* req) { in fs__copyfile() argument
2194 flags = req->fs.info.file_flags; in fs__copyfile()
2197 SET_REQ_UV_ERROR(req, UV_ENOSYS, ERROR_NOT_SUPPORTED); in fs__copyfile()
2203 if (CopyFileW(req->file.pathw, req->fs.info.new_pathw, overwrite) != 0) { in fs__copyfile()
2204 SET_REQ_RESULT(req, 0); in fs__copyfile()
2208 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__copyfile()
2209 if (req->result != UV_EBUSY) in fs__copyfile()
2213 if (fs__stat_impl_from_path(req->file.pathw, 0, &statbuf) != 0 || in fs__copyfile()
2214 fs__stat_impl_from_path(req->fs.info.new_pathw, 0, &new_statbuf) != 0) { in fs__copyfile()
2220 SET_REQ_RESULT(req, 0); in fs__copyfile()
2225 static void fs__sendfile(uv_fs_t* req) { in fs__sendfile() argument
2226 int fd_in = req->file.fd, fd_out = req->fs.info.fd_out; in fs__sendfile()
2227 size_t length = req->fs.info.bufsml[0].len; in fs__sendfile()
2228 int64_t offset = req->fs.info.offset; in fs__sendfile()
2268 SET_REQ_RESULT(req, result); in fs__sendfile()
2272 static void fs__access(uv_fs_t* req) { in fs__access() argument
2273 DWORD attr = GetFileAttributesW(req->file.pathw); in fs__access()
2276 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__access()
2287 if (!(req->fs.info.mode & W_OK) || in fs__access()
2290 SET_REQ_RESULT(req, 0); in fs__access()
2292 SET_REQ_WIN32_ERROR(req, UV_EPERM); in fs__access()
2298 static void fs__chmod(uv_fs_t* req) { in fs__chmod() argument
2299 int result = _wchmod(req->file.pathw, req->fs.info.mode); in fs__chmod()
2301 SET_REQ_WIN32_ERROR(req, _doserrno); in fs__chmod()
2303 SET_REQ_RESULT(req, 0); in fs__chmod()
2307 static void fs__fchmod(uv_fs_t* req) { in fs__fchmod() argument
2308 int fd = req->file.fd; in fs__fchmod()
2315 VERIFY_FD(fd, req); in fs__fchmod()
2319 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__fchmod()
2330 SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(nt_status)); in fs__fchmod()
2345 SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(nt_status)); in fs__fchmod()
2354 if (req->fs.info.mode & _S_IWRITE) { in fs__fchmod()
2367 SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(nt_status)); in fs__fchmod()
2382 SET_REQ_WIN32_ERROR(req, pRtlNtStatusToDosError(nt_status)); in fs__fchmod()
2387 SET_REQ_SUCCESS(req); in fs__fchmod()
2439 INLINE static void fs__utime_impl(uv_fs_t* req, int do_lutime) { in fs__utime_impl() argument
2442 error = fs__utime_impl_from_path(req->file.pathw, in fs__utime_impl()
2443 req->fs.time.atime, in fs__utime_impl()
2444 req->fs.time.mtime, in fs__utime_impl()
2452 fs__utime_impl(req, 0); in fs__utime_impl()
2455 SET_REQ_WIN32_ERROR(req, error); in fs__utime_impl()
2461 SET_REQ_RESULT(req, 0); in fs__utime_impl()
2464 static void fs__utime(uv_fs_t* req) { in fs__utime() argument
2465 fs__utime_impl(req, /* do_lutime */ 0); in fs__utime()
2469 static void fs__futime(uv_fs_t* req) { in fs__futime() argument
2470 int fd = req->file.fd; in fs__futime()
2472 VERIFY_FD(fd, req); in fs__futime()
2477 SET_REQ_WIN32_ERROR(req, ERROR_INVALID_HANDLE); in fs__futime()
2481 if (fs__utime_handle(handle, req->fs.time.atime, req->fs.time.mtime) != 0) { in fs__futime()
2482 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__futime()
2486 SET_REQ_RESULT(req, 0); in fs__futime()
2489 static void fs__lutime(uv_fs_t* req) { in fs__lutime() argument
2490 fs__utime_impl(req, /* do_lutime */ 1); in fs__lutime()
2494 static void fs__link(uv_fs_t* req) { in fs__link() argument
2495 DWORD r = CreateHardLinkW(req->fs.info.new_pathw, req->file.pathw, NULL); in fs__link()
2497 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__link()
2499 SET_REQ_RESULT(req, 0); in fs__link()
2503 static void fs__create_junction(uv_fs_t* req, const WCHAR* path, in fs__create_junction() argument
2528 SET_REQ_UV_ERROR(req, UV_EINVAL, ERROR_NOT_SUPPORTED); in fs__create_junction()
2622 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__create_junction()
2637 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__create_junction()
2650 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__create_junction()
2658 SET_REQ_RESULT(req, 0); in fs__create_junction()
2674 static void fs__symlink(uv_fs_t* req) { in fs__symlink() argument
2680 pathw = req->file.pathw; in fs__symlink()
2681 new_pathw = req->fs.info.new_pathw; in fs__symlink()
2683 if (req->fs.info.file_flags & UV_FS_SYMLINK_JUNCTION) { in fs__symlink()
2684 fs__create_junction(req, pathw, new_pathw); in fs__symlink()
2688 if (req->fs.info.file_flags & UV_FS_SYMLINK_DIR) in fs__symlink()
2694 SET_REQ_RESULT(req, 0); in fs__symlink()
2708 fs__symlink(req); in fs__symlink()
2710 SET_REQ_WIN32_ERROR(req, err); in fs__symlink()
2715 static void fs__readlink(uv_fs_t* req) { in fs__readlink() argument
2718 handle = CreateFileW(req->file.pathw, in fs__readlink()
2727 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__readlink()
2731 assert(req->ptr == NULL); in fs__readlink()
2732 if (fs__readlink_handle(handle, (char**) &req->ptr, NULL) != 0) { in fs__readlink()
2734 SET_REQ_WIN32_ERROR(req, error); in fs__readlink()
2736 req->result = UV_EINVAL; in fs__readlink()
2741 req->flags |= UV_FS_FREE_PTR; in fs__readlink()
2742 SET_REQ_RESULT(req, 0); in fs__readlink()
2797 static void fs__realpath(uv_fs_t* req) { in fs__realpath() argument
2800 handle = CreateFileW(req->file.pathw, in fs__realpath()
2808 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__realpath()
2812 assert(req->ptr == NULL); in fs__realpath()
2813 if (fs__realpath_handle(handle, (char**) &req->ptr) == -1) { in fs__realpath()
2815 SET_REQ_WIN32_ERROR(req, GetLastError()); in fs__realpath()
2820 req->flags |= UV_FS_FREE_PTR; in fs__realpath()
2821 SET_REQ_RESULT(req, 0); in fs__realpath()
2825 static void fs__chown(uv_fs_t* req) { in fs__chown() argument
2826 SET_REQ_RESULT(req, 0); in fs__chown()
2830 static void fs__fchown(uv_fs_t* req) { in fs__fchown() argument
2831 SET_REQ_RESULT(req, 0); in fs__fchown()
2835 static void fs__lchown(uv_fs_t* req) { in fs__lchown() argument
2836 SET_REQ_RESULT(req, 0); in fs__lchown()
2840 static void fs__statfs(uv_fs_t* req) { in fs__statfs() argument
2848 pathw = req->file.pathw; in fs__statfs()
2862 is_second = pathw != req->file.pathw; in fs__statfs()
2867 SET_REQ_WIN32_ERROR(req, err); in fs__statfs()
2874 SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY); in fs__statfs()
2878 ret = GetFullPathNameW(req->file.pathw, in fs__statfs()
2884 SET_REQ_WIN32_ERROR(req, err); in fs__statfs()
2890 SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY); in fs__statfs()
2900 if (pathw != req->file.pathw) { in fs__statfs()
2906 SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY); in fs__statfs()
2917 req->ptr = stat_fs; in fs__statfs()
2918 req->flags |= UV_FS_FREE_PTR; in fs__statfs()
2919 SET_REQ_RESULT(req, 0); in fs__statfs()
2924 uv_fs_t* req; in uv__fs_work() local
2926 req = container_of(w, uv_fs_t, work_req); in uv__fs_work()
2927 assert(req->type == UV_FS); in uv__fs_work()
2929 #define XX(uc, lc) case UV_FS_##uc: fs__##lc(req); break; in uv__fs_work()
2930 switch (req->fs_type) { in uv__fs_work()
2974 uv_fs_t* req; in uv__fs_done() local
2976 req = container_of(w, uv_fs_t, work_req); in uv__fs_done()
2977 uv__req_unregister(req->loop); in uv__fs_done()
2980 assert(req->result == 0); in uv__fs_done()
2981 SET_REQ_UV_ERROR(req, UV_ECANCELED, 0); in uv__fs_done()
2984 req->cb(req); in uv__fs_done()
2988 void uv_fs_req_cleanup(uv_fs_t* req) { in uv_fs_req_cleanup() argument
2989 if (req == NULL) in uv_fs_req_cleanup()
2992 if (req->flags & UV_FS_CLEANEDUP) in uv_fs_req_cleanup()
2995 if (req->flags & UV_FS_FREE_PATHS) in uv_fs_req_cleanup()
2996 uv__free(req->file.pathw); in uv_fs_req_cleanup()
2998 if (req->flags & UV_FS_FREE_PTR) { in uv_fs_req_cleanup()
2999 if (req->fs_type == UV_FS_SCANDIR && req->ptr != NULL) in uv_fs_req_cleanup()
3000 uv__fs_scandir_cleanup(req); in uv_fs_req_cleanup()
3001 else if (req->fs_type == UV_FS_READDIR) in uv_fs_req_cleanup()
3002 uv__fs_readdir_cleanup(req); in uv_fs_req_cleanup()
3004 uv__free(req->ptr); in uv_fs_req_cleanup()
3007 if (req->fs.info.bufs != req->fs.info.bufsml) in uv_fs_req_cleanup()
3008 uv__free(req->fs.info.bufs); in uv_fs_req_cleanup()
3010 req->path = NULL; in uv_fs_req_cleanup()
3011 req->file.pathw = NULL; in uv_fs_req_cleanup()
3012 req->fs.info.new_pathw = NULL; in uv_fs_req_cleanup()
3013 req->fs.info.bufs = NULL; in uv_fs_req_cleanup()
3014 req->ptr = NULL; in uv_fs_req_cleanup()
3016 req->flags |= UV_FS_CLEANEDUP; in uv_fs_req_cleanup()
3020 int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, in uv_fs_open() argument
3025 err = fs__capture_path(req, path, NULL, cb != NULL); in uv_fs_open()
3027 SET_REQ_WIN32_ERROR(req, err); in uv_fs_open()
3028 return req->result; in uv_fs_open()
3031 req->fs.info.file_flags = flags; in uv_fs_open()
3032 req->fs.info.mode = mode; in uv_fs_open()
3037 int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_fs_cb cb) { in uv_fs_close() argument
3039 req->file.fd = fd; in uv_fs_close()
3045 uv_fs_t* req, in uv_fs_read() argument
3054 SET_REQ_UV_ERROR(req, UV_EINVAL, ERROR_INVALID_PARAMETER); in uv_fs_read()
3058 req->file.fd = fd; in uv_fs_read()
3060 req->fs.info.nbufs = nbufs; in uv_fs_read()
3061 req->fs.info.bufs = req->fs.info.bufsml; in uv_fs_read()
3062 if (nbufs > ARRAY_SIZE(req->fs.info.bufsml)) in uv_fs_read()
3063 req->fs.info.bufs = uv__malloc(nbufs * sizeof(*bufs)); in uv_fs_read()
3065 if (req->fs.info.bufs == NULL) { in uv_fs_read()
3066 SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY); in uv_fs_read()
3070 memcpy(req->fs.info.bufs, bufs, nbufs * sizeof(*bufs)); in uv_fs_read()
3072 req->fs.info.offset = offset; in uv_fs_read()
3078 uv_fs_t* req, in uv_fs_write() argument
3087 SET_REQ_UV_ERROR(req, UV_EINVAL, ERROR_INVALID_PARAMETER); in uv_fs_write()
3091 req->file.fd = fd; in uv_fs_write()
3093 req->fs.info.nbufs = nbufs; in uv_fs_write()
3094 req->fs.info.bufs = req->fs.info.bufsml; in uv_fs_write()
3095 if (nbufs > ARRAY_SIZE(req->fs.info.bufsml)) in uv_fs_write()
3096 req->fs.info.bufs = uv__malloc(nbufs * sizeof(*bufs)); in uv_fs_write()
3098 if (req->fs.info.bufs == NULL) { in uv_fs_write()
3099 SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY); in uv_fs_write()
3103 memcpy(req->fs.info.bufs, bufs, nbufs * sizeof(*bufs)); in uv_fs_write()
3105 req->fs.info.offset = offset; in uv_fs_write()
3110 int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path, in uv_fs_unlink() argument
3115 err = fs__capture_path(req, path, NULL, cb != NULL); in uv_fs_unlink()
3117 SET_REQ_WIN32_ERROR(req, err); in uv_fs_unlink()
3118 return req->result; in uv_fs_unlink()
3125 int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, in uv_fs_mkdir() argument
3130 err = fs__capture_path(req, path, NULL, cb != NULL); in uv_fs_mkdir()
3132 SET_REQ_WIN32_ERROR(req, err); in uv_fs_mkdir()
3133 return req->result; in uv_fs_mkdir()
3136 req->fs.info.mode = mode; in uv_fs_mkdir()
3142 uv_fs_t* req, in uv_fs_mkdtemp() argument
3148 err = fs__capture_path(req, tpl, NULL, TRUE); in uv_fs_mkdtemp()
3150 SET_REQ_WIN32_ERROR(req, err); in uv_fs_mkdtemp()
3151 return req->result; in uv_fs_mkdtemp()
3159 uv_fs_t* req, in uv_fs_mkstemp() argument
3165 err = fs__capture_path(req, tpl, NULL, TRUE); in uv_fs_mkstemp()
3167 SET_REQ_WIN32_ERROR(req, err); in uv_fs_mkstemp()
3168 return req->result; in uv_fs_mkstemp()
3175 int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { in uv_fs_rmdir() argument
3179 err = fs__capture_path(req, path, NULL, cb != NULL); in uv_fs_rmdir()
3181 SET_REQ_WIN32_ERROR(req, err); in uv_fs_rmdir()
3182 return req->result; in uv_fs_rmdir()
3189 int uv_fs_scandir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, in uv_fs_scandir() argument
3194 err = fs__capture_path(req, path, NULL, cb != NULL); in uv_fs_scandir()
3196 SET_REQ_WIN32_ERROR(req, err); in uv_fs_scandir()
3197 return req->result; in uv_fs_scandir()
3200 req->fs.info.file_flags = flags; in uv_fs_scandir()
3205 uv_fs_t* req, in uv_fs_opendir() argument
3211 err = fs__capture_path(req, path, NULL, cb != NULL); in uv_fs_opendir()
3213 SET_REQ_WIN32_ERROR(req, err); in uv_fs_opendir()
3214 return req->result; in uv_fs_opendir()
3220 uv_fs_t* req, in uv_fs_readdir() argument
3228 SET_REQ_UV_ERROR(req, UV_EINVAL, ERROR_INVALID_PARAMETER); in uv_fs_readdir()
3232 req->ptr = dir; in uv_fs_readdir()
3237 uv_fs_t* req, in uv_fs_closedir() argument
3242 SET_REQ_UV_ERROR(req, UV_EINVAL, ERROR_INVALID_PARAMETER); in uv_fs_closedir()
3245 req->ptr = dir; in uv_fs_closedir()
3249 int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path, in uv_fs_link() argument
3254 err = fs__capture_path(req, path, new_path, cb != NULL); in uv_fs_link()
3256 SET_REQ_WIN32_ERROR(req, err); in uv_fs_link()
3257 return req->result; in uv_fs_link()
3264 int uv_fs_symlink(uv_loop_t* loop, uv_fs_t* req, const char* path, in uv_fs_symlink() argument
3269 err = fs__capture_path(req, path, new_path, cb != NULL); in uv_fs_symlink()
3271 SET_REQ_WIN32_ERROR(req, err); in uv_fs_symlink()
3272 return req->result; in uv_fs_symlink()
3275 req->fs.info.file_flags = flags; in uv_fs_symlink()
3280 int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path, in uv_fs_readlink() argument
3285 err = fs__capture_path(req, path, NULL, cb != NULL); in uv_fs_readlink()
3287 SET_REQ_WIN32_ERROR(req, err); in uv_fs_readlink()
3288 return req->result; in uv_fs_readlink()
3295 int uv_fs_realpath(uv_loop_t* loop, uv_fs_t* req, const char* path, in uv_fs_realpath() argument
3302 SET_REQ_UV_ERROR(req, UV_EINVAL, ERROR_INVALID_PARAMETER); in uv_fs_realpath()
3306 err = fs__capture_path(req, path, NULL, cb != NULL); in uv_fs_realpath()
3308 SET_REQ_WIN32_ERROR(req, err); in uv_fs_realpath()
3309 return req->result; in uv_fs_realpath()
3316 int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_uid_t uid, in uv_fs_chown() argument
3321 err = fs__capture_path(req, path, NULL, cb != NULL); in uv_fs_chown()
3323 SET_REQ_WIN32_ERROR(req, err); in uv_fs_chown()
3324 return req->result; in uv_fs_chown()
3331 int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_uid_t uid, in uv_fs_fchown() argument
3338 int uv_fs_lchown(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_uid_t uid, in uv_fs_lchown() argument
3343 err = fs__capture_path(req, path, NULL, cb != NULL); in uv_fs_lchown()
3345 SET_REQ_WIN32_ERROR(req, err); in uv_fs_lchown()
3346 return req->result; in uv_fs_lchown()
3353 int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { in uv_fs_stat() argument
3357 err = fs__capture_path(req, path, NULL, cb != NULL); in uv_fs_stat()
3359 SET_REQ_WIN32_ERROR(req, err); in uv_fs_stat()
3360 return req->result; in uv_fs_stat()
3367 int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) { in uv_fs_lstat() argument
3371 err = fs__capture_path(req, path, NULL, cb != NULL); in uv_fs_lstat()
3373 SET_REQ_WIN32_ERROR(req, err); in uv_fs_lstat()
3374 return req->result; in uv_fs_lstat()
3381 int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_fs_cb cb) { in uv_fs_fstat() argument
3383 req->file.fd = fd; in uv_fs_fstat()
3388 int uv_fs_rename(uv_loop_t* loop, uv_fs_t* req, const char* path, in uv_fs_rename() argument
3393 err = fs__capture_path(req, path, new_path, cb != NULL); in uv_fs_rename()
3395 SET_REQ_WIN32_ERROR(req, err); in uv_fs_rename()
3396 return req->result; in uv_fs_rename()
3403 int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_fs_cb cb) { in uv_fs_fsync() argument
3405 req->file.fd = fd; in uv_fs_fsync()
3410 int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file fd, uv_fs_cb cb) { in uv_fs_fdatasync() argument
3412 req->file.fd = fd; in uv_fs_fdatasync()
3417 int uv_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req, uv_file fd, in uv_fs_ftruncate() argument
3420 req->file.fd = fd; in uv_fs_ftruncate()
3421 req->fs.info.offset = offset; in uv_fs_ftruncate()
3427 uv_fs_t* req, in uv_fs_copyfile() argument
3439 SET_REQ_UV_ERROR(req, UV_EINVAL, ERROR_INVALID_PARAMETER); in uv_fs_copyfile()
3443 err = fs__capture_path(req, path, new_path, cb != NULL); in uv_fs_copyfile()
3445 SET_REQ_WIN32_ERROR(req, err); in uv_fs_copyfile()
3446 return req->result; in uv_fs_copyfile()
3449 req->fs.info.file_flags = flags; in uv_fs_copyfile()
3454 int uv_fs_sendfile(uv_loop_t* loop, uv_fs_t* req, uv_file fd_out, in uv_fs_sendfile() argument
3457 req->file.fd = fd_in; in uv_fs_sendfile()
3458 req->fs.info.fd_out = fd_out; in uv_fs_sendfile()
3459 req->fs.info.offset = in_offset; in uv_fs_sendfile()
3460 req->fs.info.bufsml[0].len = length; in uv_fs_sendfile()
3466 uv_fs_t* req, in uv_fs_access() argument
3473 err = fs__capture_path(req, path, NULL, cb != NULL); in uv_fs_access()
3475 SET_REQ_WIN32_ERROR(req, err); in uv_fs_access()
3476 return req->result; in uv_fs_access()
3479 req->fs.info.mode = flags; in uv_fs_access()
3484 int uv_fs_chmod(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, in uv_fs_chmod() argument
3489 err = fs__capture_path(req, path, NULL, cb != NULL); in uv_fs_chmod()
3491 SET_REQ_WIN32_ERROR(req, err); in uv_fs_chmod()
3492 return req->result; in uv_fs_chmod()
3495 req->fs.info.mode = mode; in uv_fs_chmod()
3500 int uv_fs_fchmod(uv_loop_t* loop, uv_fs_t* req, uv_file fd, int mode, in uv_fs_fchmod() argument
3503 req->file.fd = fd; in uv_fs_fchmod()
3504 req->fs.info.mode = mode; in uv_fs_fchmod()
3509 int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime, in uv_fs_utime() argument
3514 err = fs__capture_path(req, path, NULL, cb != NULL); in uv_fs_utime()
3516 SET_REQ_WIN32_ERROR(req, err); in uv_fs_utime()
3517 return req->result; in uv_fs_utime()
3520 req->fs.time.atime = atime; in uv_fs_utime()
3521 req->fs.time.mtime = mtime; in uv_fs_utime()
3526 int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file fd, double atime, in uv_fs_futime() argument
3529 req->file.fd = fd; in uv_fs_futime()
3530 req->fs.time.atime = atime; in uv_fs_futime()
3531 req->fs.time.mtime = mtime; in uv_fs_futime()
3535 int uv_fs_lutime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime, in uv_fs_lutime() argument
3540 err = fs__capture_path(req, path, NULL, cb != NULL); in uv_fs_lutime()
3542 SET_REQ_WIN32_ERROR(req, err); in uv_fs_lutime()
3543 return req->result; in uv_fs_lutime()
3546 req->fs.time.atime = atime; in uv_fs_lutime()
3547 req->fs.time.mtime = mtime; in uv_fs_lutime()
3553 uv_fs_t* req, in uv_fs_statfs() argument
3559 err = fs__capture_path(req, path, NULL, cb != NULL); in uv_fs_statfs()
3561 SET_REQ_WIN32_ERROR(req, err); in uv_fs_statfs()
3562 return req->result; in uv_fs_statfs()
3568 int uv_fs_get_system_error(const uv_fs_t* req) { in uv_fs_get_system_error() argument
3569 return req->sys_errno_; in uv_fs_get_system_error()