* include/winioctl.h (FSCTL_SET_SPARSE): Define.

cygwin:

        * wincap.h (wincaps::supports_sparse_files): New flag.
        (wincapc::supports_sparse_files): New method.
        * wincap.cc (wincap_unknown): Define value for the new flag.
        (wincap_95): Ditto.
        (wincap_95osr2): Ditto.
        (wincap_98): Ditto.
        (wincap_98se): Ditto.
        (wincap_me): Ditto.
        (wincap_nt3): Ditto.
        (wincap_nt4): Ditto.
        (wincap_nt4sp4): Ditto.
        (wincap_2000): Ditto.
        (wincap_xp): Ditto.
        * path.h (path_conv::fs_flags): New method.
        * fhandler_disk_file.cc: Include winioctl.h for DeviceIoControl.
        (fhandler_disk_file::open): Set newly created and truncated files as
        sparse on platforms that support it.
This commit is contained in:
Corinna Vinschen
2003-02-20 10:14:53 +00:00
parent 3f3d479490
commit 7920792369
7 changed files with 64 additions and 11 deletions

View File

@ -26,6 +26,7 @@ details. */
#include "pinfo.h"
#include <assert.h>
#include <ctype.h>
#include <winioctl.h>
#define _COMPILING_NEWLIB
#include <dirent.h>
@ -386,6 +387,19 @@ fhandler_disk_file::open (path_conv *real_path, int flags, mode_t mode)
return 0;
}
/* Set newly created and truncated files as sparse files. */
if ((real_path->fs_flags () & FILE_SUPPORTS_SPARSE_FILES)
&& (get_access () & GENERIC_WRITE) == GENERIC_WRITE
&& (get_flags () & (O_CREAT | O_TRUNC)))
{
DWORD dw;
HANDLE h = get_handle ();
BOOL r = DeviceIoControl (h , FSCTL_SET_SPARSE, NULL, 0, NULL, 0, &dw,
NULL);
syscall_printf ("%d = DeviceIoControl(0x%x, FSCTL_SET_SPARSE, NULL, 0, "
"NULL, 0, &dw, NULL)", r, h);
}
set_symlink_p (real_path->issymlink ());
set_execable_p (real_path->exec_state ());
set_socket_p (real_path->issocket ());