jivanpal / drat

Utility for performing data recovery and analysis of APFS partitions/containers.
GNU General Public License v3.0
164 stars 23 forks source link

'SF_DATALESS' undeclared #1

Closed casperes1996 closed 4 years ago

casperes1996 commented 4 years ago

Compiler: GCC 9.2.0_2 (homebrew.)

When compiling apfs-inspect gcc throws the following error:

In file included from src/apfs/func/btree.h:16,

                 from src/apfs-inspect.c:10:
src/apfs/func/../string/j.h: In function 'get_j_inode_bsd_flags_string':
src/apfs/func/../string/j.h:191:9: error: 'SF_DATALESS' undeclared (first use in this function)
  191 |         SF_DATALESS,
      |         ^~~~~~~~~~~
src/apfs/func/../string/j.h:191:9: note: each undeclared identifier is reported only once for each function it appears in
make: *** [obj/apfs-inspect.o] Error 1

Don't really know what else to add here.

jivanpal commented 4 years ago

From the APFS spec (2019-02-07, p. 68):

j_inode_val_t

[...]

bsd_flags

The inodeʼs BSD flags. uint32_t bsd_flags; For information about these flags, see the chflags(2) man page and the <sys/stat.h> header file.

On my system, the constant SF_DATALESS is defined in <sys/stat.h> as 0x40000000. The library path <sys/stat.h> resolves to /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/stat.h, a file provided by Xcode Command Line Tools. I do not have the full Xcode app installed.

find "$(xcode-select -p)" -name 'stat.h' shows that the following header files are provided by my Xcode installation:

If you are running macOS 10.14 (Mojave) or 10.15 (Catalina) and have Xcode Command Line Tools installed (via xcode-select --install), your setup ought to be similar. It is curious that compilation does not complain about the other constants used in flag_constants[] in src/apfs/string/j.h, since these are all defined in <sys/stat.h>.

In order to diagnose further, please add a comment with the output of the following commands:

jivanpal commented 4 years ago

I have now checked my copy of /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/stat.h, and it appears that all the necessary constants are defined there except for SF_DATALESS, causing compilation failure on Mojave, but not on Catalina.

Please add the line #define SF_DATALESS 0x40000000 to src/string/j.h immediately after line 12 (#include <sys/stat.h>) and let me know if this resolves the issue.

casperes1996 commented 4 years ago

Bingo. Issue resolved.

Cheers

On 24 Nov 2019, at 17.44, Jivan Pal notifications@github.com wrote:

I have now checked my copy of /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/stat.h, and it appears that all the necessary constants are defined there except for SF_DATALESS, causing compilation failure on Mojave.

Please add the line #define SF_DATALESS 0x40000000 to src/string/j.h and let me know if this resolves the issue.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/jivanpal/apfs-tools/issues/1?email_source=notifications&email_token=AHMUPV44Q7OUDIX3TZYETF3QVKVQDA5CNFSM4JQ7Y6VKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFAPQ5Q#issuecomment-557906038, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHMUPVZURYJKC3GDPE7BAFLQVKVQDANCNFSM4JQ7Y6VA.

jivanpal commented 4 years ago

Fixed upstream 🙂