Re: Why does Cygwin always use absolute paths instead of OBJECT_ATTRIBUTES.RootDirectory?

Corinna Vinschen via Cygwin <[email protected]>
Newsgroups gmane.os.cygwin
Message-ID <[email protected]>
On Feb  4 23:50, Dan Shelton via Cygwin wrote:
> On Wed, 4 Feb 2026 at 22:37, Brian Inglis via Cygwin <[email protected]> wrote:
> >
> > On 2026-02-04 14:17, Dan Shelton via Cygwin wrote:
> > > Why does Cygwin always use absolute paths instead of
> > > OBJECT_ATTRIBUTES.RootDirectory in NtOpenFile(),
> > > NtSetInformationFile() for rename and hardlinks
> > >
> > > This slows down Cygwin path lookups a lot, and with lots of path
> > > elements each lookup with a relative RootDirectory might be a lot
> > > faster, e.g. for openat(), linkat(), renameat().
> >
> > Because volunteers' spare time is limited, and performance is good enough for
> > those who might do the work:
> 
> Please do not slap me. That hurt.
> 
> My question is about whether there are any technical issues which
> prevent OBJECT_ATTRIBUTES.RootDirectory from being used in Cygwin for
> openat().

Yes.  Obviously it would be nice to be able to use relative paths
and a dir handle with openat and friends, but there are a few
technical reasons not to do that:

- Relative paths are length restricted.  They can only contain up to
  256 chars.

- Relative paths can't contain ".." and ".", so you can't do something
  like openat (dirfd, "../myfile", ...) without changing the path
  to an absolute path.

- Relative paths could cross Cygwin symlinks and Cygwin mount points.

- Relative paths could just as well cross virtual FS boundaries, like
  /proc, /dev/.

- Last but not least, the underlying path_conv class doesn't handle
  directory handle relative paths.  The history of this function is just
  as old as Cygwin itself, about 30 years.  I took a stab at rewriting
  the function a couple of times in the last couple of years but never
  got around to any workable code before giving up.  It's a pretty
  convoluted piece of code and writing a drop-in replacement is a
  multi-month job.  This very much collides with my day job, which isn't
  Cygwin-related at all.

> 2nd question: Is OBJECT_ATTRIBUTES.RootDirectory really a root, and
> you cannot do cd ..?

If I understand your question correctly, yes.  Because of the second
bullet point above.


Corinna

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.