X-Recipient: archive-cygwin AT delorie DOT com DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 71C183860753 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com; s=default; t=1704981685; bh=C6nysilbhn7FiBIw+ujKv2K76O3VQAiyl2LjcjhKZFU=; h=References:In-Reply-To:Date:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=RJzZy1wmdTNYI2nMVnYpAOCzPke4EEbUULGmYrNCFs5YHM1WkD+M7S1uwyKG48q2f +/s0D0ESTo2hnqMOgpNtIQiyplXDsyNa1cWwSgfUu9F4wPt1Tu71ejvkFwSlUOS1Hx ZuK80S7gCO6OnI2JnWtNKDksLb2xrPMydilmJcM0= X-Original-To: cygwin AT cygwin DOT com Delivered-To: cygwin AT cygwin DOT com DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 181EE385E44E ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 181EE385E44E ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704981657; cv=none; b=mtjQqnJtADcUBmqDZzLKARhV6uk+NIAVncm4qwaUSKFJALXHPaV4mSEkT96XSri969Cww2fzQdxmPYyv8N3Wob2M0ot9nISGc9eCQUkSaiYUZxzkc/zj+u+xxRzS9x1W0haVwwQ4Dwm4OptsEZsrsUVPt4WioPpBLe5RqnySws4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704981657; c=relaxed/simple; bh=ErmPjRckpUiozB6BT6ILOG//11AqQvk+7gSYlLwNDNE=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=AKQjUe90RjS+3Gz+C0EFmL/JrsQf6OgUOaMX6olN5bhu9qIuQpEjLDrrvqmTl3cJUCD7xnCRquIT02qGGOlaQf6/6eR2Gi7hsIQ/05GvarxzWcrLTATkf+YrK/UNxIlPJ63/GUqS/1UhJqKegb93AjhS+Wnio8vJNUmhLAAnC6A= ARC-Authentication-Results: i=1; server2.sourceware.org X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704981654; x=1705586454; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Bg+vUakeK/OgX7iJCNYeLVyunvYzo3XcnJHlC7EM50I=; b=U3eMnJQlaEvSfD81XUESTs6+CYvowlyIHai9vrt55MwIWSbcbeKb66Di27B2CzHjMj +p4G8sKqTwy2M72j1XUXfB/gepPbbT6r8gQ7/9VhNDl7OosLP5S1jAdnWkh7bhacjnny Ug/UP/s5XBfh6ilaY05iYTFJnwJL/DoLvxBp9hafFWECi/i++ChoZTzkiAghjRjysat1 o8MEm68pDSVKZCwn/3JVOCNpbllD2Hq0m5JFrz7GLvvOh7inoEoO/AjXqYDggNdMxccN +WJj0a/pnk0CCdM/N0UGXGCeaQTpNO9TPafwE0qe3tfFJgq+3xF296335fQDv9aPrwDq QsbA== X-Gm-Message-State: AOJu0Ywr6o5FdICfi+aF2/ofucxU9ufAu4IivjaRDSd8Fww34MVTRLZC ulF9Tz0GEofUlqnEyNEhkhulViOCplKdDfV/2oOJYkcQ X-Google-Smtp-Source: AGHT+IG2iih/Y4G46U9Qy6GozePMq0wWthvxvHTd3tPYG//ZjWK96d93/7azbl2H8M7HxOuUK++aZv680wAlGkI2rQc= X-Received: by 2002:a05:6870:4513:b0:205:db34:8ea0 with SMTP id e19-20020a056870451300b00205db348ea0mr1126610oao.6.1704981653782; Thu, 11 Jan 2024 06:00:53 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 11 Jan 2024 15:00:41 +0100 Message-ID: Subject: Re: Cygwin tools to read/write NTFS alternate data streams? To: cygwin AT cygwin DOT com X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: cygwin AT cygwin DOT com X-Mailman-Version: 2.1.30 List-Id: General Cygwin discussions and problem reports List-Archive: List-Post: List-Help: List-Subscribe: , From: Martin Wege via Cygwin Reply-To: Martin Wege Content-Type: text/plain; charset="utf-8" Sender: "Cygwin" Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 40BE1S9q010850 On Mon, Jan 8, 2024 at 3:11 PM Corinna Vinschen via Cygwin wrote: > > On Dec 18 18:47, Martin Wege via Cygwin wrote: > > On Fri, Dec 1, 2023 at 10:52 AM Corinna Vinschen via Cygwin > > wrote: > > > > > > On Nov 30 04:55, Martin Wege via Cygwin wrote: > > > > Hello, > > > > > > > > Does Cygwin have tools (modified /usr/bin/dd ?) to read/write NTFS > > > > alternate data streams? > > > > > > No. As you know, the colon is translated to a normal filename > > > character, and there's no POSIX-like API to expose ADS raw to user > > > space. > > > > > > There is, however, an old function we still expose to user space > > > for backward compat: > > > > > > #include > > > > > > int cygwin_attach_handle_to_fd (char *name, > > > int fd, > > > HANDLE handle, > > > mode_t bin, > > > DWORD myaccess); > > > > > > This allows to sneak in a HANDLE into a Cygwin file descriptor > > > representation, kind of like this: > > > > > > HANDLE h; > > > int fd; > > > > > > h = CreateFile ("foo:bar", GENERIC_READ, FILE_SHARE_VALID_FLAGS, > > > NULL, OPEN_EXISTING, 0, NULL); > > > if (h != INVALID_HANDLE_VALUE) > > > { > > > fd = cygwin_attach_handle_to_fd ("foo", -1, h, 0, GENERIC_READ); > > > if (fd < 0) > > > bail_out; > > > } > > > > > > For the bin parameter, only 0, O_BINARY or O_TEXT are acceptable, > > > for myaccess, only GENERIC_READ and/or GENERIC_WRITE are acceptable. > > > > Could this be abstracted into O_XATTR support, i.e. openat() file with > > O_XATTR, and then have access to the alternate data streams in a > > (virtual) subdir? > > I'm not too hot on adding more open(2) flags, the reason being, > that we have room left for only 7 more flags in the 32 bit mode. > Nobody knows what comes along officially in future. Right, but Solaris, Illumos, and Opengroup draft already have O_XATTR, so this is IMO OK. Also, it would provide a good abstraction for alternate data stream support, which is compatible with Windows, OSX, Solaris, Illumos, and NTFS, ZFS, SMB, NFSv4. > > 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? Thanks, Martin -- 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