sfakeroot

manipulate files faking root privileges
git clone git://git.vx21.xyz/sfakeroot
Log | Files | Refs | README | LICENSE

statx.c (775B)


      1 #include <stdio.h>
      2 #include <fcntl.h>
      3 #include <sys/stat.h>
      4 #include "../sfakeroot.h"
      5 
      6 int test(int argc __attribute__((unused)), char *argv[])
      7 {
      8 #if USE_STATX
      9     struct stat st_expected;
     10     struct statx stxbuf;
     11 
     12     if (stat(argv[0], &st_expected) == -1)
     13     {
     14         fprintf(stderr, "stat failed\n");
     15         return 1;
     16     }
     17 
     18     if (statx(AT_FDCWD, argv[0], 0, 0, &stxbuf) == -1) {
     19         fprintf(stderr, "statx failed\n");
     20         return 1;
     21     }
     22 
     23     if (stxbuf.stx_uid == 0
     24     && stxbuf.stx_gid == 0
     25     && stxbuf.stx_ino == st_expected.st_ino) {
     26         return 0;
     27     }
     28 
     29     return 1;
     30 #else
     31     (void) argv;
     32     return 0;
     33 #endif
     34 }
     35 
     36 int main(int argc __attribute__((unused)), char *argv[])
     37 {
     38 #if USE_STATX
     39     return 0;
     40 #else
     41     return test(argc, argv);
     42 #endif
     43 }