DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 615ERuZS1273591
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 615ERuZS1273591
Authentication-Results: delorie.com;
	dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=Pj/ajdeb
X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1BB764BA23C3
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1770301674;
	bh=xU/5qX3FX7nLH6LqZ/6NAgl1a6OWY4rhEDEiWd5oyy0=;
	h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe:
	 List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:
	 From;
	b=Pj/ajdebJUJ0r2af4quG7r/kVs+fil6ppTOaIoeNNA7M8TkTydy/ja+08SHNVeCDI
	 vhDaJ9zkIf/l655zUdtpfqeK4SWOEzdVcMSi8tntLWozv7eeA4No6iOLDqse/shzCY
	 Io7Srf6QqPoReYn8dElRRJ87qMMUB7eewRwtljpg=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 895574BA2E0A
Date: Thu, 5 Feb 2026 15:27:35 +0100
To: cygwin@cygwin.com
Subject: Re: Why does Cygwin always use absolute paths instead of
 OBJECT_ATTRIBUTES.RootDirectory?
Message-ID: <aYSo15Wxr0Vv9X5w@calimero.vinschen.de>
Mail-Followup-To: cygwin@cygwin.com
References: <CAAvCNcC0z2pOi92UezFxR-_o53P7dq2fNt+9js6WQAbqwWZTAQ@mail.gmail.com>
 <9e2c81eb-03ea-46ca-83e3-8adf5aa31934@SystematicSW.ab.ca>
 <CAAvCNcBSozq08ASWx6c-M8QB7aPz6tRx+Cqk8wz-1x=y0u_e5g@mail.gmail.com>
MIME-Version: 1.0
Content-Disposition: inline
In-Reply-To: <CAAvCNcBSozq08ASWx6c-M8QB7aPz6tRx+Cqk8wz-1x=y0u_e5g@mail.gmail.com>
X-BeenThere: cygwin@cygwin.com
X-Mailman-Version: 2.1.30
Precedence: list
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-request@cygwin.com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
 <mailto:cygwin-request@cygwin.com?subject=subscribe>
From: Corinna Vinschen via Cygwin <cygwin@cygwin.com>
Reply-To: cygwin@cygwin.com
Cc: Corinna Vinschen <corinna-cygwin@cygwin.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cygwin-bounces~archive-cygwin=delorie.com@cygwin.com
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie.com@cygwin.com>

On Feb  4 23:50, Dan Shelton via Cygwin wrote:
> On Wed, 4 Feb 2026 at 22:37, Brian Inglis via Cygwin <cygwin@cygwin.com> 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
