What are st_flags (custom flags) for a Mac OS X file?

I'm trying to detect when Dropbox is busy updating a file in Dropbox Dropbox on Mac OS X. By running stat (1) or stat (2) in the file, I see that the custom flags for the file (st_flags) are usually 0x40, but while Dropbox updates the file, they change to 0x00 for a couple of seconds.

Getting around my desktop and other folders, I see that ~ 95% of files have 0x00 flag values, but about 5% have 0x40 values. Thus, this may not be just a part of the Dropbox implementation. I cannot distinguish any pattern for predicting which files have the 0x40 flags. Does anyone know what these meanings mean? Who is the "user" who defines them?

+4
source share
2 answers

Flags can be set using the chflags command-line tool or the chflags() system call (see man 2 chflags ). Values ​​can be found in "/usr/include/sys/stat.h".

UF_TRACKED seems a little special. It is documented in "sys / stat.h"

 #define UF_TRACKED 0x00000040 /* file renames and deletes are tracked */ 

but not in the chflags man page.

Unfortunately, I can’t tell you exactly what β€œtracking” means, but perhaps this helps to find additional information.

+6
source

Well, although Martin, in fact, answered this with a very educated conjecture, I enter it as an answer because it is too long to enter as a comment.

Here is the evidence ...

β€’ Indeed, 10.7 is when automatic saving and versions were introduced, so you do not see UF_TRACKED in stat.h in 10.6.

β€’ I tried my experiment on a Mac with Mac OS X 10.7, and it behaves the same as in 10.8.

β€’ There is a template: document files created by some applications, which, after studying some of them, appear to be those that have Autosave and Versions accepted, are those that have UF_TRACKED = 0x40.

β€’ Another experiment. I renamed the change demonstration executable on Mac OS X,

/System/Library/PrivateFrameworks/GenerationalStorage.framework/Versions/A/Support/revisiond

then restarted the Mac and checked the status of the UF_TRACKED document file in Dropbox with 0x40. Then I changed the file on another Mac so Dropbox clicked it on this Mac with the daemon disabled. Result: the state of the UF_TRACKED file changed from 0x40 to 0x00, but this time it did not change to 0x40 after 2 seconds.

β€’ It changed to 0x40 30 seconds after I restored the change daemon to its original name and restarted it. (Obviously, revd starts when it starts with the KeepAlive attribute.)

===================

Thus, the evidence is overwhelming that Martin's assumption is correct. This is the revision Apple daemon, not Dropbox, which sets UF_TRACKED to 0x40. The meaning of this bit is that its viewing of a document is tracked using Lion Auto Save and Versions.

+8
source

Source: https://habr.com/ru/post/1480247/


All Articles