summaryrefslogtreecommitdiffstats
path: root/winsup
diff options
context:
space:
mode:
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog20
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc14
-rw-r--r--winsup/cygwin/path.h1
-rw-r--r--winsup/cygwin/wincap.cc33
-rw-r--r--winsup/cygwin/wincap.h2
-rw-r--r--winsup/w32api/ChangeLog4
-rw-r--r--winsup/w32api/include/winioctl.h1
7 files changed, 64 insertions, 11 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index aa1c4e245..7d2ddccda 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,23 @@
+2003-02-18 Vaclav Haisman <V.Haisman@sh.cvut.cz>
+
+ * 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.
+
2003-02-17 Pierre Humblet <pierre.humblet@ieee.org>
* grp.cc (internal_getgroups): Handle properly tokens with
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index 8deb7fb16..27e621708 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -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 ());
diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h
index e41d143be..4de14bf4b 100644
--- a/winsup/cygwin/path.h
+++ b/winsup/cygwin/path.h
@@ -152,6 +152,7 @@ class path_conv
short get_unitn () {return devn == FH_BAD ? 0 : unit;}
DWORD file_attributes () {return fileattr;}
DWORD drive_type () {return fs.drive_type;}
+ DWORD fs_flags () {return fs.flags;}
BOOL fs_fast_ea () {return fs.sym_opt & PC_CHECK_EA;}
void set_path (const char *p) {strcpy (path, p);}
char *return_and_clear_normalized_path ();
diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc
index e70a362da..b5671c558 100644
--- a/winsup/cygwin/wincap.cc
+++ b/winsup/cygwin/wincap.cc
@@ -47,7 +47,8 @@ static NO_COPY wincaps wincap_unknown = {
has_64bit_file_access:false,
has_process_io_counters:false,
supports_reading_modem_output_lines:false,
- needs_memory_protection:false
+ needs_memory_protection:false,
+ supports_sparse_files:false
};
static NO_COPY wincaps wincap_95 = {
@@ -86,7 +87,8 @@ static NO_COPY wincaps wincap_95 = {
has_64bit_file_access:false,
has_process_io_counters:false,
supports_reading_modem_output_lines:false,
- needs_memory_protection:false
+ needs_memory_protection:false,
+ supports_sparse_files:false
};
static NO_COPY wincaps wincap_95osr2 = {
@@ -125,7 +127,8 @@ static NO_COPY wincaps wincap_95osr2 = {
has_64bit_file_access:false,
has_process_io_counters:false,
supports_reading_modem_output_lines:false,
- needs_memory_protection:false
+ needs_memory_protection:false,
+ supports_sparse_files:false
};
static NO_COPY wincaps wincap_98 = {
@@ -164,7 +167,8 @@ static NO_COPY wincaps wincap_98 = {
has_64bit_file_access:false,
has_process_io_counters:false,
supports_reading_modem_output_lines:false,
- needs_memory_protection:false
+ needs_memory_protection:false,
+ supports_sparse_files:false
};
static NO_COPY wincaps wincap_98se = {
@@ -203,7 +207,8 @@ static NO_COPY wincaps wincap_98se = {
has_64bit_file_access:false,
has_process_io_counters:false,
supports_reading_modem_output_lines:false,
- needs_memory_protection:false
+ needs_memory_protection:false,
+ supports_sparse_files:false
};
static NO_COPY wincaps wincap_me = {
@@ -242,7 +247,8 @@ static NO_COPY wincaps wincap_me = {
has_64bit_file_access:false,
has_process_io_counters:false,
supports_reading_modem_output_lines:false,
- needs_memory_protection:false
+ needs_memory_protection:false,
+ supports_sparse_files:false
};
static NO_COPY wincaps wincap_nt3 = {
@@ -281,7 +287,8 @@ static NO_COPY wincaps wincap_nt3 = {
has_64bit_file_access:true,
has_process_io_counters:false,
supports_reading_modem_output_lines:true,
- needs_memory_protection:true
+ needs_memory_protection:true,
+ supports_sparse_files:false
};
static NO_COPY wincaps wincap_nt4 = {
@@ -320,7 +327,8 @@ static NO_COPY wincaps wincap_nt4 = {
has_64bit_file_access:true,
has_process_io_counters:false,
supports_reading_modem_output_lines:true,
- needs_memory_protection:true
+ needs_memory_protection:true,
+ supports_sparse_files:false
};
static NO_COPY wincaps wincap_nt4sp4 = {
@@ -359,7 +367,8 @@ static NO_COPY wincaps wincap_nt4sp4 = {
has_64bit_file_access:true,
has_process_io_counters:false,
supports_reading_modem_output_lines:true,
- needs_memory_protection:true
+ needs_memory_protection:true,
+ supports_sparse_files:false
};
static NO_COPY wincaps wincap_2000 = {
@@ -398,7 +407,8 @@ static NO_COPY wincaps wincap_2000 = {
has_64bit_file_access:true,
has_process_io_counters:true,
supports_reading_modem_output_lines:true,
- needs_memory_protection:true
+ needs_memory_protection:true,
+ supports_sparse_files:true
};
static NO_COPY wincaps wincap_xp = {
@@ -437,7 +447,8 @@ static NO_COPY wincaps wincap_xp = {
has_64bit_file_access:true,
has_process_io_counters:true,
supports_reading_modem_output_lines:true,
- needs_memory_protection:true
+ needs_memory_protection:true,
+ supports_sparse_files:true
};
wincapc wincap;
diff --git a/winsup/cygwin/wincap.h b/winsup/cygwin/wincap.h
index a89f0a5ad..ab3fcff4a 100644
--- a/winsup/cygwin/wincap.h
+++ b/winsup/cygwin/wincap.h
@@ -49,6 +49,7 @@ struct wincaps
unsigned has_process_io_counters : 1;
unsigned supports_reading_modem_output_lines : 1;
unsigned needs_memory_protection : 1;
+ unsigned supports_sparse_files : 1;
};
class wincapc
@@ -102,6 +103,7 @@ public:
bool IMPLEMENT (has_process_io_counters)
bool IMPLEMENT (supports_reading_modem_output_lines)
bool IMPLEMENT (needs_memory_protection)
+ bool IMPLEMENT (supports_sparse_files)
#undef IMPLEMENT
};
diff --git a/winsup/w32api/ChangeLog b/winsup/w32api/ChangeLog
index 9a827da24..7721a0861 100644
--- a/winsup/w32api/ChangeLog
+++ b/winsup/w32api/ChangeLog
@@ -1,3 +1,7 @@
+2003-02-17 Vaclav Haisman <V.Haisman@sh.cvut.cz>
+
+ * include/winioctl.h (FSCTL_SET_SPARSE): Define.
+
2003-02-12 Roland Schwingel <roland.schwingel@onevision.de>
* include/wingdi.h (AddFontResourceEx[AW]): Add.
diff --git a/winsup/w32api/include/winioctl.h b/winsup/w32api/include/winioctl.h
index 51eace260..26fdf2131 100644
--- a/winsup/w32api/include/winioctl.h
+++ b/winsup/w32api/include/winioctl.h
@@ -69,6 +69,7 @@ extern "C" {
#define FSCTL_GET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 42, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define FSCTL_SET_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 41, METHOD_BUFFERED, FILE_WRITE_DATA)
#define FSCTL_DELETE_REPARSE_POINT CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 43, METHOD_BUFFERED, FILE_WRITE_DATA)
+#define FSCTL_SET_SPARSE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 49, METHOD_BUFFERED, FILE_SPECIAL_ACCESS)
#define DEVICE_TYPE DWORD
#define FILE_DEVICE_BEEP 1
#define FILE_DEVICE_CD_ROM 2