Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2005-02-20 16:28:23 +0300
committerCorinna Vinschen <corinna@vinschen.de>2005-02-20 16:28:23 +0300
commit4944ca2f090de13e5afbde071def7449b25dcfd5 (patch)
tree3b5bb55b18a0b6ae32a6cfa4e797be9fbaf0ff97 /winsup
parent2b09be25a3929c8c6d7e23e1abb4756187c5036b (diff)
* autoload.cc (FindFirstVolumeA): Add.
(FindNextVolumeA): Add. (FindVolumeClose): Add. (GetVolumePathNamesForVolumeNameA): Add. * fhandler.h (class fhandler_base): Declare new method fsync. * fhandler.cc (fhandler_base::fsync): New method. * syscalls.cc (fsync): Move functionality into fhandler method fsync. Just call this method from here. (sync_worker): New static function. (sync): Fill with life for NT systems. * wincap.h (wincaps::has_guid_volumes): New element. * wincap.cc: Implement above element throughout.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog15
-rw-r--r--winsup/cygwin/autoload.cc4
-rw-r--r--winsup/cygwin/fhandler.cc11
-rw-r--r--winsup/cygwin/fhandler.h1
-rw-r--r--winsup/cygwin/syscalls.cc57
-rw-r--r--winsup/cygwin/wincap.cc36
-rw-r--r--winsup/cygwin/wincap.h2
7 files changed, 110 insertions, 16 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 896e72837..13b941efd 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,20 @@
2005-02-20 Corinna Vinschen <corinna@vinschen.de>
+ * autoload.cc (FindFirstVolumeA): Add.
+ (FindNextVolumeA): Add.
+ (FindVolumeClose): Add.
+ (GetVolumePathNamesForVolumeNameA): Add.
+ * fhandler.h (class fhandler_base): Declare new method fsync.
+ * fhandler.cc (fhandler_base::fsync): New method.
+ * syscalls.cc (fsync): Move functionality into fhandler method fsync.
+ Just call this method from here.
+ (sync_worker): New static function.
+ (sync): Fill with life for NT systems.
+ * wincap.h (wincaps::has_guid_volumes): New element.
+ * wincap.cc: Implement above element throughout.
+
+2005-02-20 Corinna Vinschen <corinna@vinschen.de>
+
* fhandler.h (enum query_state): Add query_write_attributes state.
(fhandler_base::status.query_open): Add a bit to make room for more
states.
diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc
index d69ac2fca..59c24f7c2 100644
--- a/winsup/cygwin/autoload.cc
+++ b/winsup/cygwin/autoload.cc
@@ -500,11 +500,15 @@ LoadDLLfunc (CoTaskMemFree, 4, ole32)
LoadDLLfuncEx (CancelIo, 4, kernel32, 1)
LoadDLLfuncEx (CreateHardLinkA, 12, kernel32, 1)
LoadDLLfuncEx (CreateToolhelp32Snapshot, 8, kernel32, 1)
+LoadDLLfuncEx (FindFirstVolumeA, 8, kernel32, 1)
+LoadDLLfuncEx (FindNextVolumeA, 12, kernel32, 1)
+LoadDLLfuncEx (FindVolumeClose, 4, kernel32, 1)
LoadDLLfuncEx2 (GetCompressedFileSizeA, 8, kernel32, 1, 0xffffffff)
LoadDLLfuncEx (GetConsoleWindow, 0, kernel32, 1)
LoadDLLfuncEx (GetDiskFreeSpaceEx, 16, kernel32, 1)
LoadDLLfuncEx (GetNativeSystemInfo, 4, kernel32, 1)
LoadDLLfuncEx (GetSystemTimes, 12, kernel32, 1)
+LoadDLLfuncEx (GetVolumePathNamesForVolumeNameA, 16, kernel32, 1)
LoadDLLfuncEx2 (IsDebuggerPresent, 0, kernel32, 1, 1)
LoadDLLfunc (IsProcessorFeaturePresent, 4, kernel32);
LoadDLLfuncEx (IsWow64Process, 8, kernel32, 1);
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 6a935fbec..e4089d64f 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -1623,3 +1623,14 @@ fhandler_base::utimes (const struct timeval *tvp)
set_errno (EINVAL);
return -1;
}
+
+int
+fhandler_base::fsync ()
+{
+ if (pc.isdir ()) /* Just succeed. */
+ return 0;
+ if (FlushFileBuffers (get_handle ()))
+ return 0;
+ __seterrno ();
+ return -1;
+}
diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h
index b6d1fae3c..34b0f20f4 100644
--- a/winsup/cygwin/fhandler.h
+++ b/winsup/cygwin/fhandler.h
@@ -267,6 +267,7 @@ class fhandler_base
virtual int __stdcall ftruncate (_off64_t) __attribute__ ((regparm (2)));
virtual int __stdcall link (const char *) __attribute__ ((regparm (2)));
virtual int __stdcall utimes (const struct timeval *) __attribute__ ((regparm (2)));
+ virtual int __stdcall fsync (void) __attribute__ ((regparm (1)));
virtual int ioctl (unsigned int cmd, void *);
virtual int fcntl (int cmd, void *);
virtual char const *ttyname () { return get_name (); }
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 079775657..d76960829 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -915,19 +915,68 @@ fsync (int fd)
syscall_printf ("-1 = fsync (%d)", fd);
return -1;
}
+ return cfd->fsync ();
+}
- if (FlushFileBuffers (cfd->get_handle ()) == 0)
+static void
+sync_worker (const char *vol)
+{
+ HANDLE fh = CreateFileA (vol, GENERIC_WRITE, wincap.shared (),
+ &sec_none_nih, OPEN_EXISTING, 0, NULL);
+ if (fh != INVALID_HANDLE_VALUE)
{
- __seterrno ();
- return -1;
+ FlushFileBuffers (fh);
+ CloseHandle (fh);
}
- return 0;
+ else
+ debug_printf ("Open failed with %E");
}
/* sync: SUSv3 */
extern "C" void
sync ()
{
+ char vol[CYG_MAX_PATH];
+
+ if (wincap.has_guid_volumes ()) /* Win2k and newer */
+ {
+ HANDLE sh = FindFirstVolumeA (vol, CYG_MAX_PATH);
+ if (sh != INVALID_HANDLE_VALUE)
+ {
+ do
+ {
+ char pvol[CYG_MAX_PATH];
+ DWORD len;
+ if (GetVolumePathNamesForVolumeNameA (vol, pvol, CYG_MAX_PATH,
+ &len))
+ debug_printf ("Try volume %s (GUID: %s)", pvol, vol);
+ else
+ debug_printf ("Try volume %s", vol);
+
+ /* Eliminate trailing backslash. */
+ vol[strlen (vol) - 1] = '\0';
+ sync_worker (vol);
+ }
+ while (FindNextVolumeA (sh, vol, CYG_MAX_PATH));
+ FindVolumeClose (sh);
+ }
+ }
+ else if (wincap.is_winnt ()) /* 9x has no concept for opening volumes */
+ {
+ DWORD drives = GetLogicalDrives ();
+ DWORD mask = 1;
+ strcpy (vol, "\\\\.\\A:");
+ do
+ {
+ if (drives & mask)
+ {
+ debug_printf ("Try volume %s", vol);
+ sync_worker (vol);
+ }
+ vol[4]++;
+ }
+ while ((mask <<= 1) <= 1 << 25);
+ }
}
/* Cygwin internal */
diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc
index 54badc456..4011b5dec 100644
--- a/winsup/cygwin/wincap.cc
+++ b/winsup/cygwin/wincap.cc
@@ -55,7 +55,8 @@ static NO_COPY wincaps wincap_unknown = {
cant_debug_dll_entry:false,
has_ioctl_storage_get_media_types_ex:false,
start_proc_suspended:true,
- has_extended_priority_class:false
+ has_extended_priority_class:false,
+ has_guid_volumes:false
};
static NO_COPY wincaps wincap_95 = {
@@ -102,7 +103,8 @@ static NO_COPY wincaps wincap_95 = {
cant_debug_dll_entry:true,
has_ioctl_storage_get_media_types_ex:false,
start_proc_suspended:true,
- has_extended_priority_class:false
+ has_extended_priority_class:false,
+ has_guid_volumes:false
};
static NO_COPY wincaps wincap_95osr2 = {
@@ -149,7 +151,8 @@ static NO_COPY wincaps wincap_95osr2 = {
cant_debug_dll_entry:true,
has_ioctl_storage_get_media_types_ex:false,
start_proc_suspended:true,
- has_extended_priority_class:false
+ has_extended_priority_class:false,
+ has_guid_volumes:false
};
static NO_COPY wincaps wincap_98 = {
@@ -196,7 +199,8 @@ static NO_COPY wincaps wincap_98 = {
cant_debug_dll_entry:true,
has_ioctl_storage_get_media_types_ex:false,
start_proc_suspended:true,
- has_extended_priority_class:false
+ has_extended_priority_class:false,
+ has_guid_volumes:false
};
static NO_COPY wincaps wincap_98se = {
@@ -243,7 +247,8 @@ static NO_COPY wincaps wincap_98se = {
cant_debug_dll_entry:true,
has_ioctl_storage_get_media_types_ex:false,
start_proc_suspended:true,
- has_extended_priority_class:false
+ has_extended_priority_class:false,
+ has_guid_volumes:false
};
static NO_COPY wincaps wincap_me = {
@@ -290,7 +295,8 @@ static NO_COPY wincaps wincap_me = {
cant_debug_dll_entry:true,
has_ioctl_storage_get_media_types_ex:false,
start_proc_suspended:true,
- has_extended_priority_class:false
+ has_extended_priority_class:false,
+ has_guid_volumes:false
};
static NO_COPY wincaps wincap_nt3 = {
@@ -337,7 +343,8 @@ static NO_COPY wincaps wincap_nt3 = {
cant_debug_dll_entry:false,
has_ioctl_storage_get_media_types_ex:false,
start_proc_suspended:false,
- has_extended_priority_class:false
+ has_extended_priority_class:false,
+ has_guid_volumes:false
};
static NO_COPY wincaps wincap_nt4 = {
@@ -384,7 +391,8 @@ static NO_COPY wincaps wincap_nt4 = {
cant_debug_dll_entry:false,
has_ioctl_storage_get_media_types_ex:false,
start_proc_suspended:false,
- has_extended_priority_class:false
+ has_extended_priority_class:false,
+ has_guid_volumes:false
};
static NO_COPY wincaps wincap_nt4sp4 = {
@@ -431,7 +439,8 @@ static NO_COPY wincaps wincap_nt4sp4 = {
cant_debug_dll_entry:false,
has_ioctl_storage_get_media_types_ex:false,
start_proc_suspended:false,
- has_extended_priority_class:false
+ has_extended_priority_class:false,
+ has_guid_volumes:false
};
static NO_COPY wincaps wincap_2000 = {
@@ -478,7 +487,8 @@ static NO_COPY wincaps wincap_2000 = {
cant_debug_dll_entry:false,
has_ioctl_storage_get_media_types_ex:false,
start_proc_suspended:false,
- has_extended_priority_class:true
+ has_extended_priority_class:true,
+ has_guid_volumes:true
};
static NO_COPY wincaps wincap_xp = {
@@ -525,7 +535,8 @@ static NO_COPY wincaps wincap_xp = {
cant_debug_dll_entry:false,
has_ioctl_storage_get_media_types_ex:true,
start_proc_suspended:false,
- has_extended_priority_class:true
+ has_extended_priority_class:true,
+ has_guid_volumes:true
};
static NO_COPY wincaps wincap_2003 = {
@@ -572,7 +583,8 @@ static NO_COPY wincaps wincap_2003 = {
cant_debug_dll_entry:false,
has_ioctl_storage_get_media_types_ex:true,
start_proc_suspended:false,
- has_extended_priority_class:true
+ has_extended_priority_class:true,
+ has_guid_volumes:true
};
wincapc wincap;
diff --git a/winsup/cygwin/wincap.h b/winsup/cygwin/wincap.h
index 2e5df1500..c6c54b0c1 100644
--- a/winsup/cygwin/wincap.h
+++ b/winsup/cygwin/wincap.h
@@ -57,6 +57,7 @@ struct wincaps
unsigned has_ioctl_storage_get_media_types_ex : 1;
unsigned start_proc_suspended : 1;
unsigned has_extended_priority_class : 1;
+ unsigned has_guid_volumes : 1;
};
class wincapc
@@ -118,6 +119,7 @@ public:
bool IMPLEMENT (has_ioctl_storage_get_media_types_ex)
bool IMPLEMENT (start_proc_suspended)
bool IMPLEMENT (has_extended_priority_class)
+ bool IMPLEMENT (has_guid_volumes)
#undef IMPLEMENT
};