diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2012-12-14 10:45:29 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2012-12-14 10:45:29 +0000 |
commit | 05297cca5fe43585ba7f8b6299d318b8b31b634a (patch) | |
tree | 36ab6968209c5f6c4a5fb2344dbf313f68612720 /winsup/cygwin/fhandler.cc | |
parent | 60f901f4a9e7ab9e6030cc38f297b140233640ea (diff) | |
download | cygnal-05297cca5fe43585ba7f8b6299d318b8b31b634a.tar.gz cygnal-05297cca5fe43585ba7f8b6299d318b8b31b634a.tar.bz2 cygnal-05297cca5fe43585ba7f8b6299d318b8b31b634a.zip |
* fhandler.cc (fhandler_base::write): Don't attempt to sparsify
an already sparse file. Drop check for FILE_SUPPORTS_SPARSE_FILES
flag. Explicitely set FILE_ATTRIBUTE_SPARSE_FILE attribute in
cached attributes.
(fhandler_base::lseek): Only set did_lseek if sparseness is supported.
* fhandler_disk_file.cc (fhandler_disk_file::ftruncate): Don't attempt
to sparsify an already sparse file. Explicitely set
FILE_ATTRIBUTE_SPARSE_FILE attribute in cached attributes.
* mount.cc (oopt): Add "sparse" flag.
(fillout_mntent): Ditto.
* path.h (enum path_types): Add PATH_SPARSE.
(path_conv::support_sparse): New method.
(path_conv::fs_flags): Constify.
(path_conv::fs_name_len): Ditto.
include/sys/mount.h: Replace unused MOUNT_MIXED flag with MOUNT_SPARSE.
Diffstat (limited to 'winsup/cygwin/fhandler.cc')
-rw-r--r-- | winsup/cygwin/fhandler.cc | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index b84263db5..169ff95be 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -817,15 +817,17 @@ ssize_t __stdcall fhandler_base::write (const void *ptr, size_t len) { int res; - IO_STATUS_BLOCK io; - FILE_POSITION_INFORMATION fpi; - FILE_STANDARD_INFORMATION fsi; if (did_lseek ()) { + IO_STATUS_BLOCK io; + FILE_POSITION_INFORMATION fpi; + FILE_STANDARD_INFORMATION fsi; + did_lseek (false); /* don't do it again */ if (!(get_flags () & O_APPEND) + && !has_attribute (FILE_ATTRIBUTE_SPARSE_FILE) && NT_SUCCESS (NtQueryInformationFile (get_output_handle (), &io, &fsi, sizeof fsi, FileStandardInformation)) @@ -833,8 +835,7 @@ fhandler_base::write (const void *ptr, size_t len) &io, &fpi, sizeof fpi, FilePositionInformation)) && fpi.CurrentByteOffset.QuadPart - >= fsi.EndOfFile.QuadPart + (128 * 1024) - && (pc.fs_flags () & FILE_SUPPORTS_SPARSE_FILES)) + >= fsi.EndOfFile.QuadPart + (128 * 1024)) { /* If the file system supports sparse files and the application is writing after a long seek beyond EOF, convert the file to @@ -842,6 +843,9 @@ fhandler_base::write (const void *ptr, size_t len) NTSTATUS status; status = NtFsControlFile (get_output_handle (), NULL, NULL, NULL, &io, FSCTL_SET_SPARSE, NULL, 0, NULL, 0); + if (NT_SUCCESS (status)) + pc.file_attributes (pc.file_attributes () + | FILE_ATTRIBUTE_SPARSE_FILE); debug_printf ("%p = NtFsControlFile(%S, FSCTL_SET_SPARSE)", status, pc.get_nt_native_path ()); } @@ -1071,7 +1075,8 @@ fhandler_base::lseek (_off64_t offset, int whence) /* When next we write(), we will check to see if *this* seek went beyond the end of the file and if so, potentially sparsify the file. */ - did_lseek (true); + if (pc.support_sparse ()) + did_lseek (true); /* If this was a SEEK_CUR with offset 0, we still might have readahead that we have to take into account when calculating |