Hi all,
I need to read and edit files/directories permissions and extended attributes (both POSIX and ACL) on macOS platform (64bit Mojave 10.14 and Catalina/10.15) using OS calls, not CLI utilities (like chmod or xattr).
For extended attributes I found this solution
https://forum.lazarus.freepascal.org/index.php?topic=24096.0 but SysCall unit is not available on macOS. Any idea how to call syscall() on macOS? It is available in
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/unistd.h and also codes including those related to extended attributes are available in
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/syscall.h#define SYS_getxattr 234
#define SYS_fgetxattr 235
#define SYS_setxattr 236
#define SYS_fsetxattr 237
#define SYS_removexattr 238
#define SYS_fremovexattr 239
#define SYS_listxattr 240
#define SYS_flistxattr 241
Any chance to port syscall.pp, syscall.inc, syscallh.inc and some other necessary *.inc files from FreeBSD to macOS/Darwin? I found that do_syscall() implementation (syscall.inc, syscallh.inc) for other operating systems are the assembler code...
For POSIX/ACL permissions there ara available C functions, but again - no units on macOS platform
https://man.openbsd.org/FreeBSD-11.1/getmode.3https://man.openbsd.org/FreeBSD-11.1/acl_set.3For POSIX permissions I found some useful functions in BaseUnix unit which is fortunetly available on macOS:
https://www.freepascal.org/docs-html/rtl/baseunix/fpaccess.html ,
https://www.freepascal.org/docs-html/rtl/baseunix/fpfstat.html ,
https://www.freepascal.org/docs-html/rtl/baseunix/fpchmod.html ,
https://www.freepascal.org/docs-html/rtl/baseunix/fpchown.html. But all of them use UID/GID only. Any idea how to get real names from UID/GID?
Also I though about another approach - calling all the above functions directly as a C code. I found this:
ftp://ftp.freepascal.org/fpc/docs-pdf/CinFreePascal.pdf. Is it possible do use this technique on macOS?
Best regards,
Inferno