diff options
author | Ron Yorston <rmy@pobox.com> | 2020-03-24 16:37:13 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2020-03-24 16:43:46 +0000 |
commit | e6680912a298dc2dee83f41837cb52160cf562d9 (patch) | |
tree | 90e61d8566d6279d8dfbb0c823b87c1cc91148d7 /win32 | |
parent | 87a56761cf04eca49295f95f353f252a53b33a46 (diff) | |
download | busybox-w32-e6680912a298dc2dee83f41837cb52160cf562d9.tar.gz busybox-w32-e6680912a298dc2dee83f41837cb52160cf562d9.tar.bz2 busybox-w32-e6680912a298dc2dee83f41837cb52160cf562d9.zip |
dd: create a sparse file when seek=N is used
When the seek=N argument is used mark the file as sparse and set
the range that is sparse.
See https://stackoverflow.com/questions/4011508/how-to-create-a-sparse-file-on-ntfs
Diffstat (limited to 'win32')
-rw-r--r-- | win32/mingw.c | 17 |
1 files changed, 17 insertions, 0 deletions
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 | |||
1754 | void 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 | } | ||