On Fri, Dec 1, 2023 at 10:52 AM Corinna Vinschen via Cygwin
<cygwin@cygwin.com> 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 <sys/cygwin.h>
>
>   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?

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

Reply via email to