File attributes: questions & enhancements

Any wishes
Locked
JayB
Posts: 192
Joined: Sun Jan 08, 2017 4:38 pm

File attributes: questions & enhancements

Post by JayB » Tue Mar 28, 2017 8:45 pm

REWRITE & CONDENSE (too many posts) ... regarding ^A ("Attributes" panel/window in "Commands")

(1) attributes "System append only" and "System Immutable" can only be removed/unset when booted into single-user mode, so I believe it would be better to change them to read-only in Nimble Commander, i.e. make the tick boxes greyed-out and non-interactive, because you won't be able to change anything in NC anyway, not even in Admin Mode

(2) According to stat.h – https://opensource.apple.com/source/xnu ... .auto.html – the attribute "User Tracked" (UF_TRACKED) has become irrelevant, because macOS "no longer issue[s] notifications for deletes or renames for files which have UF_TRACKED set." Furthermore, the attribute has never shown up in ls -laO, so I'm not sure what should be done with it. Read-only maybe? I guess the user can set the "tracked" attribute, but what's the use outside of Nimble Commander?

(3) "System No Unlink", a valid macOS file attribute, sunlnk with chflags, is missing from Nimble Commander's Attributes panel/window. (It's a system attribute.) Make sure to not include "User No Unlink", uunlnk, because that's FreeBSD only, and it's not part of macOS. (For once, this was a good move by Apple, because setting "No Unlink" should always be done as root. :) )

(4) macOS also has the "restricted" attribute (files protected by SIP, I assume), and it's currently not supported by Nimble Commander. You can set and unset the attribute with root privileges (sudo) in the shell, so it should be "System Restricted" and not greyed-out in NC. (You probably need to have SIP disabled to change this attribute.)

(5) "User Compressed" should be shown as just "Compressed", because in the ls output that's how HFS+ compressed files register. Btw: with the 3rd-party afsctool it's possible to HFS-compress files on macOS in the user space, so in principle it would be possible to make the "Compressed" attribute tick box interactive, and add an HFS compression functionality to NC. However, I would wait until APFS and see if compression is still implemented. Rumor has it that "compressed" will be (finally!) dropped in favor of sparse files, which would introduce the "sparse" attribute to macOS. We'll see.

(6) GENERAL NOTES: it would be nice to have two sections in the Attributes window, one for the user attributes, then a separator line, and the next section for the system attributes; e.g. "Archived" is only for root, and "Opaque" is a user attribute, so a Nimble Commander user would know immediately if he needs to switch to Admin Mode to set or remove an attribute.

(7) MAYBE: maybe there should even be a third section for file attributes not native to macOS, but encountered on other file systems, like "snapshot" & "uunlnk", "sparse", "noarchive" etc. Btw: "snapshot" & "sparse" might make an entrance with APFS. We'll see. I was not able to test it, because I don't have access to "foreign" file systems, but it would astonish me, if macOS weren't able to read file attributes native to other file systems than HFS. (Maybe not all of them, but at least BSD.) Unless macOS has a secret way of setting/unsetting foreign attributes, this should only be read-only in Nimble Commander.
Last edited by JayB on Wed Mar 29, 2017 1:41 am, edited 2 times in total.

User avatar
mike
Posts: 1060
Joined: Thu Jul 16, 2015 5:35 am
Location: Exeter, UK

Re: File attributes: questions & enhancements

Post by mike » Fri Apr 07, 2017 2:01 am

Hi, JayB, sorry for a long response time.
JayB wrote:
Tue Mar 28, 2017 8:45 pm
(1) attributes "System append only" and "System Immutable" can only be removed/unset when booted into single-user mode, so I believe it would be better to change them to read-only in Nimble Commander, i.e. make the tick boxes greyed-out and non-interactive, because you won't be able to change anything in NC anyway, not even in Admin Mode
Good notice, will do.
JayB wrote:
Tue Mar 28, 2017 8:45 pm
(2) According to stat.h – https://opensource.apple.com/source/xnu ... .auto.html – the attribute "User Tracked" (UF_TRACKED) has become irrelevant, because macOS "no longer issue[s] notifications for deletes or renames for files which have UF_TRACKED set." Furthermore, the attribute has never shown up in ls -laO, so I'm not sure what should be done with it. Read-only maybe? I guess the user can set the "tracked" attribute, but what's the use outside of Nimble Commander?
I believe this flag is used nowadays for the "Versions" feature introduced in Lion.
For instance, in my case, many documents created with iWork (Numbers, Pages etc) have this flag set On:
Screen Shot 2017-04-07 at 08.39.05.png
Screen Shot 2017-04-07 at 08.39.05.png (80.69 KiB) Viewed 7236 times
JayB wrote:
Tue Mar 28, 2017 8:45 pm
(3) "System No Unlink", a valid macOS file attribute, sunlnk with chflags, is missing from Nimble Commander's Attributes panel/window. (It's a system attribute.) Make sure to not include "User No Unlink", uunlnk, because that's FreeBSD only, and it's not part of macOS. (For once, this was a good move by Apple, because setting "No Unlink" should always be done as root. )
Right, will add.
Frankly I don't even remember why I missed this one - this code was initially written 4 years ago.
JayB wrote:
Tue Mar 28, 2017 8:45 pm
(4) macOS also has the "restricted" attribute (files protected by SIP, I assume), and it's currently not supported by Nimble Commander. You can set and unset the attribute with root privileges (sudo) in the shell, so it should be "System Restricted" and not greyed-out in NC. (You probably need to have SIP disabled to change this attribute.)
Is it SF_RESTRICTED or something else?
JayB wrote:
Tue Mar 28, 2017 8:45 pm
(5) "User Compressed" should be shown as just "Compressed", because in the ls output that's how HFS+ compressed files register. Btw: with the 3rd-party afsctool it's possible to HFS-compress files on macOS in the user space, so in principle it would be possible to make the "Compressed" attribute tick box interactive, and add an HFS compression functionality to NC. However, I would wait until APFS and see if compression is still implemented. Rumor has it that "compressed" will be (finally!) dropped in favor of sparse files, which would introduce the "sparse" attribute to macOS. We'll see.
I assume "Compressed" was put under "User.." category since the corresponding flag belongs to the Users section of flags: UF_COMPRESSED.
Speaking of a manual compressing - yeah, I dug that area previously. That's possible to implement, but the process is quite obscure and undocumented, and I highly doubted about a demand for such feature. And yes, it's still unclear what type of compression will be supported in APFS.
BTW, spare files and file compression aren't connected from POV of filesystem architecture. For example, NTFS supports both. And it also supports a compression of mutable files... sigh. Honestly, HFS+ is just a piece of crap, and it should have been changed to ZFS almost 10 years ago in Snow Leopard.
JayB wrote:
Tue Mar 28, 2017 8:45 pm
(6) GENERAL NOTES: it would be nice to have two sections in the Attributes window, one for the user attributes, then a separator line, and the next section for the system attributes; e.g. "Archived" is only for root, and "Opaque" is a user attribute, so a Nimble Commander user would know immediately if he needs to switch to Admin Mode to set or remove an attribute.
Good idea!
JayB wrote:
Tue Mar 28, 2017 8:45 pm
7) MAYBE: maybe there should even be a third section for file attributes not native to macOS, but encountered on other file systems, like "snapshot" & "uunlnk", "sparse", "noarchive" etc. Btw: "snapshot" & "sparse" might make an entrance with APFS. We'll see. I was not able to test it, because I don't have access to "foreign" file systems, but it would astonish me, if macOS weren't able to read file attributes native to other file systems than HFS. (Maybe not all of them, but at least BSD.) Unless macOS has a secret way of setting/unsetting foreign attributes, this should only be read-only in Nimble Commander.
Do you know any "legal" way to deal with such attributes?

JayB
Posts: 192
Joined: Sun Jan 08, 2017 4:38 pm

Re: File attributes: questions & enhancements

Post by JayB » Fri Apr 07, 2017 9:14 am

Quick remarks:

(1) user tracked: interesting that the flag is set by some apps (and can be unset: UF_TRACKED), but doesn't appear in ls output; Apple is soooo weird… really :)

(2) restricted: it should be SF_RESTRICTED, but I'm not sure

(3) compressed: you're right, UF_COMPRESSED = user … you can easily notice this, when copying an HFS+ compressed .app bundle like TextEdit.app or an application from the Mac App Store… the duplicate will (or at least: it should) lose the compression, so it's a user attribute/flag; but as you rightly said, setting the compressed flag would be hard… if there's no documented way offered by macOS, then it should be a read-only tickbox in NC; agree: HFS+ is a botch… love that Apple are finally leaving it behind.

(4) foreign file attributes: not sure how to deal with them on an actual code basis; I just thought about this when looking at invisible files that my router (running a Linux variant) had created on a NAS volume, and one of the files had the arch attribute set; however, that's an attribute that macOS is also using, so I can't even say if truly foreign attributes like "sparse" will appear in the ls output of a mounted foreign volume. (Needs testing.) But if they appear in ls, it would mean that macOS has a way to read these attributes, but it may be private/undocumented; FreeBSD can read, set & unset a huge amount of attributes, even the proprietary Windows flags like reparse, but I can't say if that functionality is also somewhere hidden inside macOS.

Locked