aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coreutils/dd.c3
-rw-r--r--include/mingw.h1
-rw-r--r--win32/mingw.c17
3 files changed, 21 insertions, 0 deletions
diff --git a/coreutils/dd.c b/coreutils/dd.c
index 3054ec6ea..fc8b1dbb2 100644
--- a/coreutils/dd.c
+++ b/coreutils/dd.c
@@ -502,6 +502,9 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
502 } 502 }
503 if (seek) { 503 if (seek) {
504 size_t blocksz = (G.flags & FLAG_SEEK_BYTES) ? 1 : obs; 504 size_t blocksz = (G.flags & FLAG_SEEK_BYTES) ? 1 : obs;
505#if ENABLE_PLATFORM_MINGW32
506 seek_sparse(ofd, seek * blocksz);
507#endif
505 if (lseek(ofd, seek * blocksz, SEEK_CUR) < 0) 508 if (lseek(ofd, seek * blocksz, SEEK_CUR) < 0)
506 goto die_outfile; 509 goto die_outfile;
507 } 510 }
diff --git a/include/mingw.h b/include/mingw.h
index 3ab49a920..a5a84cff2 100644
--- a/include/mingw.h
+++ b/include/mingw.h
@@ -533,3 +533,4 @@ int chdir_system_drive(void);
533char *xabsolute_path(char *path); 533char *xabsolute_path(char *path);
534char *get_drive_cwd(const char *path, char *buffer, int size); 534char *get_drive_cwd(const char *path, char *buffer, int size);
535void fix_path_case(char *path); 535void fix_path_case(char *path);
536void seek_sparse(int fd, size_t size);
diff --git a/win32/mingw.c b/win32/mingw.c
index 894388b64..7f8fecdc3 100644
--- a/win32/mingw.c
+++ b/win32/mingw.c
@@ -1750,3 +1750,20 @@ void fix_path_case(char *path)
1750 } 1750 }
1751 } 1751 }
1752} 1752}
1753
1754void seek_sparse(int fd, size_t size)
1755{
1756 DWORD dwTemp;
1757 HANDLE fh;
1758 FILE_ZERO_DATA_INFORMATION fzdi;
1759
1760 if ((fh=(HANDLE)_get_osfhandle(fd)) == INVALID_HANDLE_VALUE)
1761 return;
1762
1763 DeviceIoControl(fh, FSCTL_SET_SPARSE, NULL, 0, NULL, 0, &dwTemp, NULL);
1764
1765 fzdi.FileOffset.QuadPart = 0;
1766 fzdi.BeyondFinalZero.QuadPart = size;
1767 DeviceIoControl(fh, FSCTL_SET_ZERO_DATA, &fzdi, sizeof(fzdi),
1768 NULL, 0, &dwTemp, NULL);
1769}