* 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.
This commit is contained in:
Corinna Vinschen 2013-10-25 16:16:50 +00:00
parent 46943206dc
commit 2118eee1ce
6 changed files with 23 additions and 28 deletions

View File

@ -1,3 +1,15 @@
2013-10-25 Corinna Vinschen <corinna@vinschen.de>
* 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 <corinna@vinschen.de> 2013-10-25 Corinna Vinschen <corinna@vinschen.de>
* fhandler_disk_file.cc (fhandler_base::fstat_fs): Fix comment. * fhandler_disk_file.cc (fhandler_base::fstat_fs): Fix comment.

View File

@ -142,7 +142,7 @@ const device dev_error_storage =
const _RDATA device dev_storage[] = const _RDATA device dev_storage[] =
{ {
{"/dev", BRACK(FH_DEV), "/dev", exists, S_IFDIR, false}, {"/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/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/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}, {"/dev/com3", BRACK(FHDEV(DEV_SERIAL_MAJOR, 2)), "\\??\\COM3", exists_ntdev_silent, S_IFCHR, true},

View File

@ -156,7 +156,7 @@ const device dev_error_storage =
"/dev/full", BRACK(FH_FULL), "\\Device\\Null", exists_ntdev, S_IFCHR "/dev/full", BRACK(FH_FULL), "\\Device\\Null", exists_ntdev, S_IFCHR
"/dev/random", BRACK(FH_RANDOM), "\\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/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/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 "/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 ":pipe", BRACK(FH_PIPE), "/dev/pipe", exists_internal, S_IFCHR

View File

@ -1691,7 +1691,6 @@ class fhandler_dev_clipboard: public fhandler_base
public: public:
fhandler_dev_clipboard (); fhandler_dev_clipboard ();
int is_windows () { return 1; } int is_windows () { return 1; }
int open (int flags, mode_t mode = 0);
int __reg2 fstat (struct stat *buf); int __reg2 fstat (struct stat *buf);
ssize_t __stdcall write (const void *ptr, size_t len); ssize_t __stdcall write (const void *ptr, size_t len);
void __reg3 read (void *ptr, size_t& len); void __reg3 read (void *ptr, size_t& len);

View File

@ -55,25 +55,12 @@ fhandler_dev_clipboard::fhandler_dev_clipboard ()
*/ */
int 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; fhandler_dev_clipboard *fhc = (fhandler_dev_clipboard *) child;
fhc->pos = fhc->msize = 0;
if (!fhc->open (get_flags (), 0)) fhc->membuffer = NULL;
system_printf ("error opening clipboard, %E"); return fhandler_base::dup (child, flags);
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;
} }
static int static int
@ -100,8 +87,6 @@ set_clipboard (const void *buf, size_t len)
GlobalUnlock (hmem); GlobalUnlock (hmem);
EmptyClipboard (); EmptyClipboard ();
if (!cygnativeformat)
cygnativeformat = RegisterClipboardFormatW (CYGWIN_NATIVE);
HANDLE ret = SetClipboardData (cygnativeformat, hmem); HANDLE ret = SetClipboardData (cygnativeformat, hmem);
CloseClipboard (); CloseClipboard ();
/* According to MSDN, hmem must not be free'd after transferring the /* According to MSDN, hmem must not be free'd after transferring the
@ -346,15 +331,14 @@ fhandler_dev_clipboard::close ()
{ {
if (!have_execed) if (!have_execed)
{ {
pos = 0; pos = msize = 0;
if (membuffer) if (membuffer)
{ {
free (membuffer); free (membuffer);
membuffer = NULL; membuffer = NULL;
} }
msize = 0;
} }
return 0; return fhandler_base::close ();
} }
void void

View File

@ -7,9 +7,9 @@ What changed:
- Slightly improve randomness of /dev/random emulation. - Slightly improve randomness of /dev/random emulation.
- Allow to use advisory locking on any device which is backed by an OS - Allow to use advisory locking on any device which is backed by an OS handle.
handle. Right now this excludes /dev/clipboard, /dev/dsp, as well as Right now this excludes /dev/dsp as well as almost all virtual files under
almost all virtual files under /proc. /proc.
Bug fixes: Bug fixes: