stat.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* Copyright (C) 2016 Jeremiah Orians
  2. * Copyright (C) 2020 deesix <deesix@tuta.io>
  3. * This file is part of M2-Planet.
  4. *
  5. * M2-Planet is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * M2-Planet 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 M2-Planet. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /*
  19. * chmod() changes the mode of the file specified whose pathname is given in
  20. * pathname, which is dereferenced if it is a symbolic link.
  21. * fchmod() changes the mode of the file referred to by the open file
  22. * descriptor fd.
  23. * The new file mode is specified in mode, which is a bit mask created by
  24. * ORing together zero or more of the following:
  25. * S_ISUID (04000) set-user-ID (set process effective user ID on execve(2))
  26. * S_ISGID (02000) set-group-ID (set process effective group ID on execve(2)
  27. * mandatory locking, as described in fcntl(2); take a new file's group from
  28. * parent directory, as described in chown(2) and mkdir(2))
  29. * S_ISVTX (01000) sticky bit (restricted deletion flag, as described in
  30. * unlink(2))
  31. * S_IRUSR (00400) read by owner
  32. * S_IWUSR (00200) write by owner
  33. * S_IXUSR (00100) execute/search by owner ("search" applies for directories
  34. * , and means that entries within the directory can be accessed)
  35. * S_IRGRP (00040) read by group
  36. * S_IWGRP (00020) write by group
  37. * S_IXGRP (00010) execute/search by group
  38. * S_IROTH (00004) read by others
  39. * S_IWOTH (00002) write by others
  40. * S_IXOTH (00001) execute/search by others
  41. */
  42. int chmod(char *pathname, int mode)
  43. {
  44. asm("SET_X0_FROM_BP" "SUB_X0_16" "DEREF_X0"
  45. "SET_X2_FROM_X0"
  46. "SET_X0_FROM_BP" "SUB_X0_8" "DEREF_X0"
  47. "SET_X1_FROM_X0"
  48. "SET_X0_TO_0"
  49. "SET_X3_FROM_X0"
  50. "SET_X0_TO_FCNTL_H_AT_FDCWD"
  51. "SET_X8_TO_SYS_FCHMODAT"
  52. "SYSCALL");
  53. }