* fhandler.h (class fhandler_registry): Declare dup method.

* fhandler_registry.cc (fhandler_registry::exists): Fix missing
	parenthesis.
	(fhandler_registry::dup): New method.
This commit is contained in:
Corinna Vinschen 2008-12-15 12:33:27 +00:00
parent 12406f25fb
commit 305b19d738
3 changed files with 34 additions and 8 deletions

View File

@ -1,3 +1,10 @@
2008-12-15 Corinna Vinschen <corinna@vinschen.de>
* fhandler.h (class fhandler_registry): Declare dup method.
* fhandler_registry.cc (fhandler_registry::exists): Fix missing
parenthesis.
(fhandler_registry::dup): New method.
2008-12-14 Christopher Faylor <me+cygwin@cgf.cx> 2008-12-14 Christopher Faylor <me+cygwin@cgf.cx>
* fhandler_disk_file.cc (readdir_get_ino): Don't complain about MS-DOS * fhandler_disk_file.cc (readdir_get_ino): Don't complain about MS-DOS

View File

@ -1299,6 +1299,7 @@ class fhandler_registry: public fhandler_proc
int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2))); int __stdcall fstat (struct __stat64 *buf) __attribute__ ((regparm (2)));
bool fill_filebuf (); bool fill_filebuf ();
int close (); int close ();
int dup (fhandler_base *child);
}; };
class pinfo; class pinfo;

View File

@ -237,6 +237,7 @@ fhandler_registry::exists ()
file++; file++;
if (file == path) if (file == path)
{
for (int i = 0; registry_listing[i]; i++) for (int i = 0; registry_listing[i]; i++)
if (path_prefix_p (registry_listing[i], path, if (path_prefix_p (registry_listing[i], path,
strlen (registry_listing[i]), true)) strlen (registry_listing[i]), true))
@ -244,6 +245,7 @@ fhandler_registry::exists ()
file_type = 1; file_type = 1;
break; break;
} }
}
else else
{ {
char dec_file[NAME_MAX + 1]; char dec_file[NAME_MAX + 1];
@ -640,6 +642,9 @@ fhandler_registry::open (int flags, mode_t mode)
else else
{ {
set_io_handle (registry_keys[i]); set_io_handle (registry_keys[i]);
/* Marking as nohandle allows to call dup on pseudo registry
handles. */
nohandle (true);
flags |= O_DIROPEN; flags |= O_DIROPEN;
goto success; goto success;
} }
@ -724,7 +729,7 @@ fhandler_registry::close ()
if (res != 0) if (res != 0)
return res; return res;
HKEY handle = (HKEY) get_handle (); HKEY handle = (HKEY) get_handle ();
if (handle != (HKEY) INVALID_HANDLE_VALUE) if (handle != (HKEY) INVALID_HANDLE_VALUE && handle < HKEY_CLASSES_ROOT)
{ {
if (RegCloseKey (handle) != ERROR_SUCCESS) if (RegCloseKey (handle) != ERROR_SUCCESS)
{ {
@ -891,3 +896,16 @@ open_key (const char *name, REGSAM access, DWORD wow64, bool isValue)
out: out:
return hKey; return hKey;
} }
int
fhandler_registry::dup (fhandler_base *child)
{
int ret = fhandler_virtual::dup (child);
/* Pseudo registry handles can't be duplicated using DuplicateHandle.
Therefore those fhandlers are marked with the nohandle flag. This
allows fhandler_base::dup to succeed as usual for nohandle fhandlers.
Here we just have to fix up by copying the pseudo handle value. */
if ((HKEY) get_handle () >= HKEY_CLASSES_ROOT)
child->set_io_handle (get_handle ());
return ret;
}