fcntl.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. #ifndef __FCNTL_C
  19. #define __FCNTL_C
  20. #define O_RDONLY 0
  21. #define O_WRONLY 1
  22. #define O_RDWR 2
  23. #define O_CREAT 00100
  24. #define O_EXCL 00200
  25. #define O_TRUNC 001000
  26. #define O_APPEND 002000
  27. #define S_IXUSR 00100
  28. #define S_IWUSR 00200
  29. #define S_IRUSR 00400
  30. #define S_IRWXU 00700
  31. int _open(char* name, int flag, int mode)
  32. {
  33. asm("SET_X0_FROM_BP" "SUB_X0_24" "DEREF_X0"
  34. "SET_X3_FROM_X0"
  35. "SET_X0_FROM_BP" "SUB_X0_16" "DEREF_X0"
  36. "SET_X2_FROM_X0"
  37. "SET_X0_FROM_BP" "SUB_X0_8" "DEREF_X0"
  38. "SET_X1_FROM_X0"
  39. "SET_X0_TO_FCNTL_H_AT_FDCWD"
  40. "SET_X8_TO_SYS_OPENAT"
  41. "SYSCALL");
  42. }
  43. #define STDIN_FILENO 0
  44. #define STDOUT_FILENO 1
  45. #define STDERR_FILENO 2
  46. #endif