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
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/cygwin/syscalls.cc
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/cygwin/syscalls.cc')
-rw-r--r--winsup/cygwin/syscalls.cc57
1 files changed, 53 insertions, 4 deletions
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 */