X-Recipient: archive-cygwin@delorie.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2CAF63858C41
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
	s=default; t=1704991300;
	bh=uvU5N76IZVl6xgPl44HCPFSx0p5usIQeRqRnjJ/WXoA=;
	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=OUk9VQjbcUgZNPdWXuyCr611yiPlbbwosF/NjAB6e3hYEXaIzfeawF1PAA5wy53nl
	 uf7Bsi5xN6FPlAKSlOFtpCzV8NujBejDHbEAwhrnJHdSxKtJltLj1mVN4vbByuVgVI
	 qfAqlv5RITPDvpPnfz+0lK1akLJmcLDebNvhIItg=
X-Original-To: cygwin@cygwin.com
Delivered-To: cygwin@cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 79B9F3858C41
Date: Thu, 11 Jan 2024 17:41:06 +0100
To: cygwin@cygwin.com
Subject: Re: Cygwin tools to read/write NTFS alternate data streams?
Message-ID: <ZaAaIs7D7DMO4qw3@calimero.vinschen.de>
Mail-Followup-To: cygwin@cygwin.com
References: <CANH4o6N7UONfYy1ir7WZXpOnthSxF=fcqaPe37dPsdU_AoPoLw@mail.gmail.com>
 <ZWmsvW0bmko_9Qcc@calimero.vinschen.de>
 <CANH4o6M7s1h8+atQVdr+uAOgUHKPyomP4zoobvvbW97ebSR=sw@mail.gmail.com>
 <ZZwCIjfdP6Qh-y5d@calimero.vinschen.de>
 <CANH4o6NPjo1d-KBxZUo1+tVrZJNcT5ieYX0Hc42ZV0pXLoUtgw@mail.gmail.com>
MIME-Version: 1.0
Content-Disposition: inline
In-Reply-To: <CANH4o6NPjo1d-KBxZUo1+tVrZJNcT5ieYX0Hc42ZV0pXLoUtgw@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="utf-8"
Errors-To: cygwin-bounces+archive-cygwin=delorie.com@cygwin.com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie.com@cygwin.com>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 40BGfgXs015662

On Jan 11 15:00, Martin Wege via Cygwin wrote:
> On Mon, Jan 8, 2024 at 3:11 PM Corinna Vinschen via Cygwin
> <cygwin@cygwin.com> wrote:
> so this is IMO OK.

Yeah, but...

It's not just an open flag, it requires extending functionality of other
APIs and, for full support, tools, see
https://docs.oracle.com/cd/E19253-01/816-5175/6mbba7f02/.

It's also rather weird to call alternate data streams "extended
attributes", because that's just a small part of streams and it's
already supported via the Linux functions getxattr(2) and friends, see
https://man7.org/linux/man-pages/man2/getxattr.2.html

> > Apart from that, this sounds like a nice idea for Cygwin 3.6,
> > provided somebody implements it, https://cygwin.com/acronyms/#SHTDI
> >
> > Assuming we can live without actually having a subdir and just
> > allowing to open and create a file with the O_XATTR flag, it might be
> > pretty simple to implement.  The path handling code would just have to
> > drop the colon from the list of characters converted to the private-use
> > Unicode area.
> >
> > Implementing the subdir is a bit more complicated, especially when
> > taking opendir/readdir of that virtual subdir into account, but it
> > would certainly be doable.
> 
> How do other OSes implement the O_XATTR subdir?

IDK.  But there are a few points we have to keep in mind from the
Solaris man page:

- Given fd is an open file descriptor,

    openat(fd, ".", O_RDONLY|O_XATTR);

  opens the virtual subdir containing the ADS of a file.  It's the
  only valid way to open the virtual dir.  That's a bit of a relief
  because it simplifies handling this in openat(2).

    openat(fd, "foo", ...|O_XATTR);

  allows to create or open an ADS for an open file fd.

- unlinkat, renameat, fstatat, fchownat, futimesat and fdopendir need to
  be made ADS-aware.  They only work on ADS if the fd arg already
  resolves to an ADS, or if fd is the virtual ADS dir of a file and
  (except in case of fdopendir) the path argument is the name of an
  existing ADS.

- pathconf needs to support a new flag XATTR_ENABLED.

This can be made to work given the current fhandler framework in Cygwin,
but again, https://cygwin.com/acronyms/#SHTDI

FTR, I'm generally not a friend of ADS, because they look like a builtin
security problem.  They don't show up in standard directory listings,
and you can't even see that a file has ADS, except you look for them
explicitely.  This is a really user-unfriendly interface.


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

