access.c 428 B

1234567891011121314
  1. #include <stdio.h>
  2. #include <unistd.h>
  3. int main() {
  4. if (access("example_dir/1-never-gonna-give-you-up", R_OK | W_OK)) {
  5. perror("access");
  6. return 1;
  7. }
  8. if (!access("example_dir/1-never-gonna-give-you-up", X_OK)) {
  9. puts("Accessing a file with X_OK worked even though it... probably... shouldn't?");
  10. puts("Please run `chmod 644 example_dir/*` and try again.");
  11. return 1;
  12. }
  13. }