Accessing native NT namespace as filesystem

Corinna Vinschen
Fri Sep 3 20:20:00 GMT 2010

On Sep  3 11:02, Christopher Faylor wrote:
> On Fri, Sep 03, 2010 at 09:58:00AM +0200, Corinna Vinschen wrote:
> >Oooohkeeey.  I still like /proc/sys more, though.  It just *sounds*
> >better, imho.  Could you all live with that, too?
> No!  Absolutely not!  Red is a much better color for a bikeshed!
> cgf
> (/proc/sys is fine)


Attached is the more or less final patch which uses /proc/sys.

I also improved cygwin_conv_path to generate always valid Win32 paths
from paths via the native NT namespace, for instance

  /proc/sys/Device/CdRom0  ->  \\.\GLOBALROOT\Device\CdRom0


  /dev/sda1  ->  \\.\GLOBALROOT\Device\Harddisk0\Partition1

The patch also contains a change to cygpath which now groks the
GLOBALROOT prefix and still tries to find a better, shorter match by
searching the \??\ DOS device namespace, *iff* the path points into the
\Device directory.  So, by using cygpath, you can still get something
really short like this:

  $ cygpath -w /dev/sda1
  $ cygpath -w /proc/sys/Device/CdRom0

If the path is not the path to the block device, but a path to a file
on the block device, cygpath now takes this even a step beyond:

  $ cygpath -w /proc/sys/Device/CdRom0/foo

So it removes the \\.\ prefix if the path is a perfectly valid DOS
standard pathname even without the prefix.  If it's shorter than MAX_PATH.

Please have a look.  If nobody finds something terribly wrong, I'll
check this in on Monday.


P.S, this is neat:

  $ ln -s /proc/sys/SystemRoot /WINDOWS

  You neither have to know the drive letter of the system drive, nor the
  actual name of the systemroot (Windows, WINNT, whatever).  Very
  helpful if you have a machine with multiple Windows installations.

	* (DLL_OFILES): Add fhandler_procsys.o.
	* devices.h (enum fh_devices): Add FH_PROCSYS.
	* (dev_procsys_storage): New device.
	* Regenerate.
	* fhandler.h (proc_len): Convert to size_t.
	(procsys): Declare.
	(procsys_len): Declare.
	(enum virtual_ftype_t): Move here from fhandler_virtual.h.
	Add members supported by fhandler_procsys.
	(fhandler_virtual::exists): Return virtual_ftype_t.  Change
	in all derived classes.
	(class fhandler_procsys): New class.
	(fhandler_union): Add fhandler_procnet and fhandler_procsys members.
	* (__DIR_mounts::check_missing_mount): Use
	(fhandler_base::fstat_by_name): Add special case for virtual
	* (fhandler_netdrive::exists): Return
	* (proc_tab): Sort alphabetically.  Use _VN macro
	to store length.
	(proc_len): Change to size_t.
	(proc_tab_cmp): New static function.
	(virt_tab_search): New function to search entry in virt_tab_t
	arrays.  Use throughout in /proc and sibling classes instead of
	(fhandler_proc::exists): Return virtual_ftype_t.
	* (process_tab): Sort alphabetically.  Use _VN
	macro to store length.
	(fhandler_process::exists): Return virtual_ftype_t.
	(fhandler_process::open): Simplify code.
	* (procnet_tab): Sort alphabetically.  Use _VN
	macro to store length.
	(fhandler_procnet::exists): Return virtual_ftype_t.
	(fhandler_procnet::open): Simplify.
	* New file.
	* (fhandler_registry::exists): Return
	* (fhandler_virtual::exists): Ditto.
	* fhandler_virtual.h (enum virtual_ftype_t): Move to fhandler.h.
	(virt_tab_t): Add name_len member.
	(_VN): New macro.
	(virt_tab_search): Declare.
	* (mount_info::conv_to_win32_path): Fix comment.
	backslashify isprocsys_dev paths, rather than just copying as
	other proc paths.
	(NtOpenSymbolicLinkObject): Declare.
	(NtQuerySymbolicLinkObject): Declare.
	* (path_conv::check): Accommodate fact that exists method
	returns virtual_ftype_t now.  Add cases for new virtual_ftype_t
	(cygwin_conv_path): Add GLOBALROOT prefix to native device paths.
	Make sure to strip \\?\ prefix only for actual filesystem-based
	paths, not for all paths.
	* path.h (isproc_dev): Add FH_PROCSYS.
	(isprocsys_dev): Define.

	* (RtlEqualUnicodePathPrefix): New help function.
	(get_device_name): Take GLOBALROOT_PREFIX into account.
	Improve check for path to allow filesystem access via block devices.
	Potentially drop \\.\ prefix if resulting path is a valid DOS
	(do_pathconv): Make sure to drop \\?\ prefix only if path is
	actually a filesystem based path.
	(print_version): Fix copyright.

Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: procsys.diff
Type: text/x-patch
Size: 59003 bytes
Desc: not available
URL: <>

More information about the Cygwin-developers mailing list