cachefiles.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef _LINUX_CACHEFILES_H
  3. #define _LINUX_CACHEFILES_H
  4. #include <linux/types.h>
  5. #include <linux/ioctl.h>
  6. /*
  7. * Fscache ensures that the maximum length of cookie key is 255. The volume key
  8. * is controlled by netfs, and generally no bigger than 255.
  9. */
  10. #define CACHEFILES_MSG_MAX_SIZE 1024
  11. enum cachefiles_opcode {
  12. CACHEFILES_OP_OPEN,
  13. CACHEFILES_OP_CLOSE,
  14. CACHEFILES_OP_READ,
  15. };
  16. /*
  17. * Message Header
  18. *
  19. * @msg_id a unique ID identifying this message
  20. * @opcode message type, CACHEFILE_OP_*
  21. * @len message length, including message header and following data
  22. * @object_id a unique ID identifying a cache file
  23. * @data message type specific payload
  24. */
  25. struct cachefiles_msg {
  26. __u32 msg_id;
  27. __u32 opcode;
  28. __u32 len;
  29. __u32 object_id;
  30. __u8 data[];
  31. };
  32. /*
  33. * @data contains the volume_key followed directly by the cookie_key. volume_key
  34. * is a NUL-terminated string; @volume_key_size indicates the size of the volume
  35. * key in bytes. cookie_key is binary data, which is netfs specific;
  36. * @cookie_key_size indicates the size of the cookie key in bytes.
  37. *
  38. * @fd identifies an anon_fd referring to the cache file.
  39. */
  40. struct cachefiles_open {
  41. __u32 volume_key_size;
  42. __u32 cookie_key_size;
  43. __u32 fd;
  44. __u32 flags;
  45. __u8 data[];
  46. };
  47. /*
  48. * @off indicates the starting offset of the requested file range
  49. * @len indicates the length of the requested file range
  50. */
  51. struct cachefiles_read {
  52. __u64 off;
  53. __u64 len;
  54. };
  55. /*
  56. * Reply for READ request
  57. * @arg for this ioctl is the @id field of READ request.
  58. */
  59. #define CACHEFILES_IOC_READ_COMPLETE _IOW(0x98, 1, int)
  60. #endif