Search code examples
macosdropboxflagsstat

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


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

Poking around my Desktop and other folders, I see that ~95% of files have flags value 0x00 but about 5% have value 0x40. So it may be not just a Dropbox implementation detail. I cannot discern any pattern for predicting which files have 0x40 flags. Does anyone know what these values mean? Who is the "user" that is defining them?


Solution

  • The flags can be set with the chflags command line tool or the chflags() system call (see man 2 chflags). The values can be found in "/usr/include/sys/stat.h".

    UF_TRACKED seems to be a bit 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 cannot tell you what "tracked" precisely means, but perhaps this helps already to find more information.