filesystem.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * filesystem.h
  3. *
  4. * Copyright (C) 2017 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as
  8. * published by the Free Software Foundation, either version 3 of the
  9. * License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef __MONOLITIHUM_FILESYSTEM_H__
  20. #define __MONOLITIHUM_FILESYSTEM_H__
  21. #include "defs.h"
  22. #include "clock.h"
  23. #include "object.h"
  24. #define PATH_DELIMITER_STRING "/"
  25. #define PATH_DELIMITER_CHAR (*PATH_DELIMITER_STRING)
  26. #define FILE_MODE_READ (1 << 0)
  27. #define FILE_MODE_WRITE (1 << 1)
  28. #define FILE_MODE_SHARE_READ (1 << 2)
  29. #define FILE_MODE_SHARE_WRITE (1 << 3)
  30. #define FILE_MODE_NO_CACHE (1 << 4)
  31. #define FILE_MODE_DELETE_ON_CLOSE (1 << 29)
  32. #define FILE_MODE_CREATE (1 << 30)
  33. #define FILE_MODE_TRUNCATE (1 << 31)
  34. #define FILE_ATTR_DIRECTORY (1 << 0)
  35. #define FILE_ATTR_OWNER_READABLE (1 << 1)
  36. #define FILE_ATTR_OWNER_WRITABLE (1 << 2)
  37. #define FILE_ATTR_WORLD_READABLE (1 << 3)
  38. #define FILE_ATTR_WORLD_WRITABLE (1 << 4)
  39. #define FILE_ATTR_DELETED (1 << 31)
  40. #define MOUNT_FLAG_READONLY (1 << 0)
  41. typedef enum
  42. {
  43. FILE_INFO_ATTRIBUTES,
  44. FILE_INFO_NAME,
  45. FILE_INFO_TIME,
  46. FILE_INFO_SIZE,
  47. FILE_INFO_OWNER,
  48. } file_info_type_t;
  49. typedef struct
  50. {
  51. clock_time_t creation_time;
  52. clock_time_t modification_time;
  53. clock_time_t last_access_time;
  54. } file_time_info_t;
  55. typedef struct
  56. {
  57. dword_t type;
  58. char filename[VARIABLE_SIZE];
  59. } file_event_t;
  60. sysret_t syscall_open_file(const char *path, handle_t *handle, dword_t mode, dword_t attributes);
  61. sysret_t syscall_delete_file(const char *path);
  62. sysret_t syscall_query_file(handle_t handle, file_info_type_t info_type, void *buffer, size_t size);
  63. sysret_t syscall_set_file(handle_t handle, file_info_type_t set_type, void *buffer, size_t size);
  64. sysret_t syscall_list_directory(handle_t handle, char *filename, bool_t continue_scan);
  65. sysret_t syscall_read_file(handle_t handle, void *buffer, qword_t offset, size_t size, size_t *bytes_read);
  66. sysret_t syscall_write_file(handle_t handle, const void *buffer, qword_t offset, size_t size, size_t *bytes_written);
  67. sysret_t syscall_mount(const char *device, const char *mountpoint, const char *filesystem, dword_t flags);
  68. sysret_t syscall_unmount(const char *device);
  69. sysret_t syscall_wait_directory_event(handle_t handle, dword_t event_mask, file_event_t *buffer, size_t size, dword_t timeout);
  70. #endif