- ssize_t total_bytes_written = 0;
-
- if (iovcnt <= 0) {
- errno = EINVAL;
- return -1;
- }
- for (int i = 0; i < iovcnt; i++) {
- ssize_t bytes_written;
-
- bytes_written = write(fd, iov[i].iov_base, iov[i].iov_len);
- if (bytes_written >= 0)
- total_bytes_written += bytes_written;
- if (bytes_written != iov[i].iov_len) {
- if (total_bytes_written == 0)
- total_bytes_written = -1;
- break;
- }
- }
- return total_bytes_written;
-}
-
-/* Given a path, which may not yet exist, get a set of flags that describe the
- * features of the volume the path is on. */
-int
-win32_get_vol_flags(const wchar_t *path, unsigned *vol_flags_ret)
-{
- wchar_t *volume;
- BOOL bret;
- DWORD vol_flags;
-
- if (path[0] != L'\0' && path[0] != L'\\' &&
- path[0] != L'/' && path[1] == L':')
- {
- /* Path starts with a drive letter; use it. */
- volume = alloca(4 * sizeof(wchar_t));
- volume[0] = path[0];
- volume[1] = path[1];
- volume[2] = L'\\';
- volume[3] = L'\0';
- } else {
- /* Path does not start with a drive letter; use the volume of
- * the current working directory. */
- volume = NULL;
- }
- bret = GetVolumeInformationW(volume, /* lpRootPathName */
- NULL, /* lpVolumeNameBuffer */
- 0, /* nVolumeNameSize */
- NULL, /* lpVolumeSerialNumber */
- NULL, /* lpMaximumComponentLength */
- &vol_flags, /* lpFileSystemFlags */
- NULL, /* lpFileSystemNameBuffer */
- 0); /* nFileSystemNameSize */
- if (!bret) {
- DWORD err = GetLastError();
- WARNING("Failed to get volume information for path \"%ls\"", path);
- win32_error(err);
- vol_flags = 0xffffffff;
- }
-
- DEBUG("using vol_flags = %x", vol_flags);
- *vol_flags_ret = vol_flags;
- return 0;