1
0

access.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * This file is part of Jehanne.
  3. *
  4. * Copyright (C) 2017 Giacomo Tesio <giacomo@tesio.it>
  5. *
  6. * Jehanne is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, version 2 of the License.
  9. *
  10. * Jehanne is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with Jehanne. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include <u.h>
  19. #include <lib9.h>
  20. void
  21. main(void)
  22. {
  23. char *err = nil;
  24. if(access("/tmp", AEXIST) != 0)
  25. err = "/tmp does not exists";
  26. else if(access("/tmp", AREAD) != 0)
  27. err = "/tmp is not readable";
  28. /* NOTE:
  29. * In Plan 9 access(AWRITE) and access(AEXEC) in directories
  30. * fail despite the actual permission of the directory.
  31. *
  32. else if(access("/tmp", AWRITE) != 0)
  33. err = "/tmp is not writeable";
  34. else if(access("/tmp", AEXEC) != 0)
  35. err = "/tmp is not traversable";
  36. */
  37. if(err == nil){
  38. print("PASS\n");
  39. exits("PASS");
  40. } else {
  41. print("FAIL: %s\n", err);
  42. exits("FAIL");
  43. }
  44. }