Problems with xattr / v2.1.6 Monterey (Intel)

All your general support questions for OpenZFS on OS X.

Re: Problems with xattr / v2.1.6 Monterey (Intel)

Postby lundman » Wed Feb 22, 2023 3:07 am

Yeah, so setxattr(com.apple.ResourceFork) doesn't create a vnode. Using "../namedfork/rsrc" will create a vnode, so
now we have 2 things and looks like I need to synchronise them.. I'll have to think about this.

symlink now gives error:

# xattr -sw com.apple.ResourceFork HelloWorld /Volumes/BOOM/moore
xattr: [Errno 1] Operation not permitted: '/Volumes/BOOM/moore'
User avatar
lundman
 
Posts: 1335
Joined: Thu Mar 06, 2014 2:05 pm
Location: Tokyo, Japan

Re: Problems with xattr / v2.1.6 Monterey (Intel)

Postby roemer » Wed Feb 22, 2023 3:16 am

Thanks again.

I also tried to sync files with ResourceForks using rsync. Rsync seems to write them as extended attributes - and then I can't read the resource fork of the synced copy via the special path, while I could do so on the source file before the rsync.
Copying of resource forks on APFS using rsync -aX works fine.
roemer
 
Posts: 73
Joined: Sat Mar 15, 2014 2:32 pm

Re: Problems with xattr / v2.1.6 Monterey (Intel)

Postby lundman » Wed Feb 22, 2023 5:52 pm

roemer wrote:Testing FILENAME/..namedfork/rsrc, it seems to work if one writes and reads via that special path, but if you write the extended attribute directly using xattr, you cannot read it via the special path:


OK this one is actually quite fun.

The first call of; "echo HelloWorld > test/..namedfork/rsrc" will call "vnop_makenamedstream()", so it creates an xattr_dir entry under "com.apple.ResourceFork" and give the vnode to XNU.

You can now "cat" it fine.

The using "xattr -w com.apple.ResourceFork" we are called via "vnop_setxattr()", where we go an write a regular "com.apple.ResourceFork",
which is preferentially be an xattr=SA. Ie, cached in nvlist array.

The following "cat" calls zfs_dirlook("com.apple.ResourceFork") inside the xattr directory, which of course, does not exist. (as it is cached as a nvlist).

Good luck pointing a vnode to a cached nvlist too.

Questions:

1) Why is it always using xattr=sa? I didn't set it, but maybe its the default now

2) We need to make "com.apple.ResourceFork" be forced to always be an xattr=dir type. Some minor reduction of speed from it.
User avatar
lundman
 
Posts: 1335
Joined: Thu Mar 06, 2014 2:05 pm
Location: Tokyo, Japan

Re: Problems with xattr / v2.1.6 Monterey (Intel)

Postby lundman » Wed Feb 22, 2023 5:58 pm

OK, so I had set xattr=sa, so that's a future problem.

It's actually that with compat code, it adds macos:com.apple.ResourceFork.

So two things need a-fixin
User avatar
lundman
 
Posts: 1335
Joined: Thu Mar 06, 2014 2:05 pm
Location: Tokyo, Japan

Re: Problems with xattr / v2.1.6 Monterey (Intel)

Postby lundman » Wed Feb 22, 2023 6:55 pm

Here is a new binary, it attempts to address:

* getnamedstream vs setxattr
* skip setsize only on 0 (patch corruption)

OpenZFSonOsX-2.1.99-Catalina-10.15.pkg
(16.39 MiB) Downloaded 401 times


Code: Select all

zfs-2.1.99-1734_g3ed0210f3
zfs-kmod-2.1.99-1734_g3ed0210f3
User avatar
lundman
 
Posts: 1335
Joined: Thu Mar 06, 2014 2:05 pm
Location: Tokyo, Japan

Re: Problems with xattr / v2.1.6 Monterey (Intel)

Postby roemer » Thu Feb 23, 2023 12:20 am

Very nice. I tried the latest version on 10.15.7 - not exhaustively, just the tests we discussed recently - and it seems to solve (most) issues:
  • I can create or read com.apple.ResourceFork either using setattr() or with /..namedfork/rsrc
  • setting an icon on a directory or a file now works
  • attempt to set com.apple.ResourceFork on a symlink fails now as expected: "[Errno 1] Operation not permitted"
  • I tried this successfully with both xattr=on and xattr=sa
The only two things left are the 'archived' bsd flag (which we said is not urgent), and setting an empty xattr on a file without any existing xattr still fails, even using your example code instead of the xattr script:
Code: Select all
touch testfile
mysetxattr testfile
   setting empty org.attr.empty on testfile failed: setxattr -1
xattr -w org.attr.something "hello world" testfile
mysetxattr testfile
   setting empty org.attr.empty on testfile OK: setxattr 0
roemer
 
Posts: 73
Joined: Sat Mar 15, 2014 2:32 pm

Re: Problems with xattr / v2.1.6 Monterey (Intel)

Postby o3x_prokyon » Fri Feb 24, 2023 9:41 am

Great work, thanks! Everything seems to work as expected now. Locking directories and setting icons is possible again and no complaints on setting xattr any more. Perfect!
o3x_prokyon
 
Posts: 33
Joined: Thu Dec 01, 2022 1:17 pm

Re: Problems with xattr / v2.1.6 Monterey (Intel)

Postby lundman » Sat Feb 25, 2023 1:50 am

OK I think this will fix the emtpty-xattrs as first xattr

OpenZFSonOsX-2.1.99-Catalina-10.15.pkg
(16.39 MiB) Downloaded 426 times
User avatar
lundman
 
Posts: 1335
Joined: Thu Mar 06, 2014 2:05 pm
Location: Tokyo, Japan

Re: Problems with xattr / v2.1.6 Monterey (Intel)

Postby roemer » Sat Feb 25, 2023 11:06 pm

Yes, this indeed solves the empty-xattr problem.
Many thanks!

It does however also write empty com.apple.ResourceFork attributes...
APFS and HFS seem to silently ignore empty com.apple.ResourceFork xattr - they are just not written without any error in the same way they ignore empty FinderInfos. Should ZFS ignore empty ResourceForks similar to empty com.apple.FInderInfo?

I also played around with an existing dataset which was written back in the days of 1.9.4 (or even older).
There I find several files with an existing com.apple.ResourceFork that I can list and print using the xattr command (so taking it as an extended attribute), but when I try to access them with the ..namedfork/rsrc special path, I get a "XYZ/..namedfork/rsrc: No such file or directory" error.
Are resource forks written differently nowadays, or do I need to set some dataset property to make this work?
roemer
 
Posts: 73
Joined: Sat Mar 15, 2014 2:32 pm

Re: Problems with xattr / v2.1.6 Monterey (Intel)

Postby lundman » Sat Feb 25, 2023 11:31 pm

OK so is there a difference to hfs/apfs in the current behavior? Cos we could make sure to remove empty xattrs. What creates them?



Compared to 1.9.4, yeah we probably are doing things differently, certainly didn't have the not-SA bypass in it then.
User avatar
lundman
 
Posts: 1335
Joined: Thu Mar 06, 2014 2:05 pm
Location: Tokyo, Japan

PreviousNext

Return to General Help

Who is online

Users browsing this forum: Google [Bot] and 24 guests