diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 1b45354b9..90716e9a0 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,15 @@ +2013-10-25 Corinna Vinschen + + * devices.in (dev_storage): Map /dev/clipboard to \Device\Null. + * devices.cc: Regenerate. + * fhandler.h (fhandler_dev_clipboard::open): Drop declaration. + * fhandler_clipboard.cc (fhandler_dev_clipboard::dup): Drop call to + open. Set private members to 0 and call fhandler_base::dup. + (fhandler_dev_clipboard::open): Remove so that default + fhandler_base::open is used to open \Device\Null. + (set_clipboard): Drop gratuitios call to RegisterClipboardFormatW. + (fhandler_dev_clipboard::close): Call fhandler_base::close from here. + 2013-10-25 Corinna Vinschen * fhandler_disk_file.cc (fhandler_base::fstat_fs): Fix comment. diff --git a/winsup/cygwin/devices.cc b/winsup/cygwin/devices.cc index 2e36dc85f..6c6960c2f 100644 --- a/winsup/cygwin/devices.cc +++ b/winsup/cygwin/devices.cc @@ -142,7 +142,7 @@ const device dev_error_storage = const _RDATA device dev_storage[] = { {"/dev", BRACK(FH_DEV), "/dev", exists, S_IFDIR, false}, - {"/dev/clipboard", BRACK(FH_CLIPBOARD), "/dev/clipboard", exists, S_IFCHR, true}, + {"/dev/clipboard", BRACK(FH_CLIPBOARD), "\\Device\\Null", exists_ntdev, S_IFCHR, true}, {"/dev/com1", BRACK(FHDEV(DEV_SERIAL_MAJOR, 0)), "\\??\\COM1", exists_ntdev_silent, S_IFCHR, true}, {"/dev/com2", BRACK(FHDEV(DEV_SERIAL_MAJOR, 1)), "\\??\\COM2", exists_ntdev_silent, S_IFCHR, true}, {"/dev/com3", BRACK(FHDEV(DEV_SERIAL_MAJOR, 2)), "\\??\\COM3", exists_ntdev_silent, S_IFCHR, true}, diff --git a/winsup/cygwin/devices.in b/winsup/cygwin/devices.in index a297b31f6..ef10557e9 100644 --- a/winsup/cygwin/devices.in +++ b/winsup/cygwin/devices.in @@ -156,7 +156,7 @@ const device dev_error_storage = "/dev/full", BRACK(FH_FULL), "\\Device\\Null", exists_ntdev, S_IFCHR "/dev/random", BRACK(FH_RANDOM), "\\Device\\Null", exists_ntdev, S_IFCHR "/dev/urandom", BRACK(FH_URANDOM), "\\Device\\Null", exists_ntdev, S_IFCHR, =urandom_dev -"/dev/clipboard", BRACK(FH_CLIPBOARD), "/dev/clipboard", exists, S_IFCHR +"/dev/clipboard", BRACK(FH_CLIPBOARD), "\\Device\\Null", exists_ntdev, S_IFCHR "/dev/com%(1-16)d", BRACK(FHDEV(DEV_SERIAL_MAJOR, {$1 - 1})), "\\??\\COM{$1}", exists_ntdev_silent, S_IFCHR "/dev/ttyS%(0-63)d", BRACK(FHDEV(DEV_SERIAL_MAJOR, {$1})), "\\??\\COM{$1 + 1}", exists_ntdev, S_IFCHR ":pipe", BRACK(FH_PIPE), "/dev/pipe", exists_internal, S_IFCHR diff --git a/winsup/cygwin/fhandler.h b/winsup/cygwin/fhandler.h index bb10ea1bb..b8b984eb4 100644 --- a/winsup/cygwin/fhandler.h +++ b/winsup/cygwin/fhandler.h @@ -1691,7 +1691,6 @@ class fhandler_dev_clipboard: public fhandler_base public: fhandler_dev_clipboard (); int is_windows () { return 1; } - int open (int flags, mode_t mode = 0); int __reg2 fstat (struct stat *buf); ssize_t __stdcall write (const void *ptr, size_t len); void __reg3 read (void *ptr, size_t& len); diff --git a/winsup/cygwin/fhandler_clipboard.cc b/winsup/cygwin/fhandler_clipboard.cc index ad5304f0b..f360dc0ba 100644 --- a/winsup/cygwin/fhandler_clipboard.cc +++ b/winsup/cygwin/fhandler_clipboard.cc @@ -55,25 +55,12 @@ fhandler_dev_clipboard::fhandler_dev_clipboard () */ int -fhandler_dev_clipboard::dup (fhandler_base * child, int) +fhandler_dev_clipboard::dup (fhandler_base * child, int flags) { fhandler_dev_clipboard *fhc = (fhandler_dev_clipboard *) child; - - if (!fhc->open (get_flags (), 0)) - system_printf ("error opening clipboard, %E"); - return 0; -} - -int -fhandler_dev_clipboard::open (int flags, mode_t) -{ - set_flags (flags | O_TEXT); - pos = 0; - if (!cygnativeformat) - cygnativeformat = RegisterClipboardFormatW (CYGWIN_NATIVE); - nohandle (true); - set_open_status (); - return 1; + fhc->pos = fhc->msize = 0; + fhc->membuffer = NULL; + return fhandler_base::dup (child, flags); } static int @@ -100,8 +87,6 @@ set_clipboard (const void *buf, size_t len) GlobalUnlock (hmem); EmptyClipboard (); - if (!cygnativeformat) - cygnativeformat = RegisterClipboardFormatW (CYGWIN_NATIVE); HANDLE ret = SetClipboardData (cygnativeformat, hmem); CloseClipboard (); /* According to MSDN, hmem must not be free'd after transferring the @@ -346,15 +331,14 @@ fhandler_dev_clipboard::close () { if (!have_execed) { - pos = 0; + pos = msize = 0; if (membuffer) { free (membuffer); membuffer = NULL; } - msize = 0; } - return 0; + return fhandler_base::close (); } void diff --git a/winsup/cygwin/release/1.7.26 b/winsup/cygwin/release/1.7.26 index 1da677bd0..58994053f 100644 --- a/winsup/cygwin/release/1.7.26 +++ b/winsup/cygwin/release/1.7.26 @@ -7,9 +7,9 @@ What changed: - Slightly improve randomness of /dev/random emulation. -- Allow to use advisory locking on any device which is backed by an OS - handle. Right now this excludes /dev/clipboard, /dev/dsp, as well as - almost all virtual files under /proc. +- Allow to use advisory locking on any device which is backed by an OS handle. + Right now this excludes /dev/dsp as well as almost all virtual files under + /proc. Bug fixes: