afs.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /* AFS common types
  3. *
  4. * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved.
  5. * Written by David Howells (dhowells@redhat.com)
  6. */
  7. #ifndef AFS_H
  8. #define AFS_H
  9. #include <linux/in.h>
  10. #define AFS_MAXCELLNAME 256 /* Maximum length of a cell name */
  11. #define AFS_MAXVOLNAME 64 /* Maximum length of a volume name */
  12. #define AFS_MAXNSERVERS 8 /* Maximum servers in a basic volume record */
  13. #define AFS_NMAXNSERVERS 13 /* Maximum servers in a N/U-class volume record */
  14. #define AFS_MAXTYPES 3 /* Maximum number of volume types */
  15. #define AFSNAMEMAX 256 /* Maximum length of a filename plus NUL */
  16. #define AFSPATHMAX 1024 /* Maximum length of a pathname plus NUL */
  17. #define AFSOPAQUEMAX 1024 /* Maximum length of an opaque field */
  18. #define AFS_VL_MAX_LIFESPAN (120 * HZ)
  19. #define AFS_PROBE_MAX_LIFESPAN (30 * HZ)
  20. typedef u64 afs_volid_t;
  21. typedef u64 afs_vnodeid_t;
  22. typedef u64 afs_dataversion_t;
  23. typedef enum {
  24. AFSVL_RWVOL, /* read/write volume */
  25. AFSVL_ROVOL, /* read-only volume */
  26. AFSVL_BACKVOL, /* backup volume */
  27. } __attribute__((packed)) afs_voltype_t;
  28. typedef enum {
  29. AFS_FTYPE_INVALID = 0,
  30. AFS_FTYPE_FILE = 1,
  31. AFS_FTYPE_DIR = 2,
  32. AFS_FTYPE_SYMLINK = 3,
  33. } afs_file_type_t;
  34. typedef enum {
  35. AFS_LOCK_READ = 0, /* read lock request */
  36. AFS_LOCK_WRITE = 1, /* write lock request */
  37. } afs_lock_type_t;
  38. #define AFS_LOCKWAIT (5 * 60) /* time until a lock times out (seconds) */
  39. /*
  40. * AFS file identifier
  41. */
  42. struct afs_fid {
  43. afs_volid_t vid; /* volume ID */
  44. afs_vnodeid_t vnode; /* Lower 64-bits of file index within volume */
  45. u32 vnode_hi; /* Upper 32-bits of file index */
  46. u32 unique; /* unique ID number (file index version) */
  47. };
  48. /*
  49. * AFS callback notification
  50. */
  51. typedef enum {
  52. AFSCM_CB_UNTYPED = 0, /* no type set on CB break */
  53. AFSCM_CB_EXCLUSIVE = 1, /* CB exclusive to CM [not implemented] */
  54. AFSCM_CB_SHARED = 2, /* CB shared by other CM's */
  55. AFSCM_CB_DROPPED = 3, /* CB promise cancelled by file server */
  56. } afs_callback_type_t;
  57. struct afs_callback {
  58. time64_t expires_at; /* Time at which expires */
  59. //unsigned version; /* Callback version */
  60. //afs_callback_type_t type; /* Type of callback */
  61. };
  62. struct afs_callback_break {
  63. struct afs_fid fid; /* File identifier */
  64. //struct afs_callback cb; /* Callback details */
  65. };
  66. #define AFSCBMAX 50 /* maximum callbacks transferred per bulk op */
  67. struct afs_uuid {
  68. __be32 time_low; /* low part of timestamp */
  69. __be16 time_mid; /* mid part of timestamp */
  70. __be16 time_hi_and_version; /* high part of timestamp and version */
  71. __s8 clock_seq_hi_and_reserved; /* clock seq hi and variant */
  72. __s8 clock_seq_low; /* clock seq low */
  73. __s8 node[6]; /* spatially unique node ID (MAC addr) */
  74. };
  75. /*
  76. * AFS volume information
  77. */
  78. struct afs_volume_info {
  79. afs_volid_t vid; /* volume ID */
  80. afs_voltype_t type; /* type of this volume */
  81. afs_volid_t type_vids[5]; /* volume ID's for possible types for this vol */
  82. /* list of fileservers serving this volume */
  83. size_t nservers; /* number of entries used in servers[] */
  84. struct {
  85. struct in_addr addr; /* fileserver address */
  86. } servers[8];
  87. };
  88. /*
  89. * AFS security ACE access mask
  90. */
  91. typedef u32 afs_access_t;
  92. #define AFS_ACE_READ 0x00000001U /* - permission to read a file/dir */
  93. #define AFS_ACE_WRITE 0x00000002U /* - permission to write/chmod a file */
  94. #define AFS_ACE_INSERT 0x00000004U /* - permission to create dirent in a dir */
  95. #define AFS_ACE_LOOKUP 0x00000008U /* - permission to lookup a file/dir in a dir */
  96. #define AFS_ACE_DELETE 0x00000010U /* - permission to delete a dirent from a dir */
  97. #define AFS_ACE_LOCK 0x00000020U /* - permission to lock a file */
  98. #define AFS_ACE_ADMINISTER 0x00000040U /* - permission to change ACL */
  99. #define AFS_ACE_USER_A 0x01000000U /* - 'A' user-defined permission */
  100. #define AFS_ACE_USER_B 0x02000000U /* - 'B' user-defined permission */
  101. #define AFS_ACE_USER_C 0x04000000U /* - 'C' user-defined permission */
  102. #define AFS_ACE_USER_D 0x08000000U /* - 'D' user-defined permission */
  103. #define AFS_ACE_USER_E 0x10000000U /* - 'E' user-defined permission */
  104. #define AFS_ACE_USER_F 0x20000000U /* - 'F' user-defined permission */
  105. #define AFS_ACE_USER_G 0x40000000U /* - 'G' user-defined permission */
  106. #define AFS_ACE_USER_H 0x80000000U /* - 'H' user-defined permission */
  107. /*
  108. * AFS file status information
  109. */
  110. struct afs_file_status {
  111. u64 size; /* file size */
  112. afs_dataversion_t data_version; /* current data version */
  113. struct timespec64 mtime_client; /* Last time client changed data */
  114. struct timespec64 mtime_server; /* Last time server changed data */
  115. s64 author; /* author ID */
  116. s64 owner; /* owner ID */
  117. s64 group; /* group ID */
  118. afs_access_t caller_access; /* access rights for authenticated caller */
  119. afs_access_t anon_access; /* access rights for unauthenticated caller */
  120. umode_t mode; /* UNIX mode */
  121. afs_file_type_t type; /* file type */
  122. u32 nlink; /* link count */
  123. s32 lock_count; /* file lock count (0=UNLK -1=WRLCK +ve=#RDLCK */
  124. u32 abort_code; /* Abort if bulk-fetching this failed */
  125. };
  126. struct afs_status_cb {
  127. struct afs_file_status status;
  128. struct afs_callback callback;
  129. bool have_status; /* True if status record was retrieved */
  130. bool have_cb; /* True if cb record was retrieved */
  131. bool have_error; /* True if status.abort_code indicates an error */
  132. };
  133. /*
  134. * AFS file status change request
  135. */
  136. #define AFS_SET_MTIME 0x01 /* set the mtime */
  137. #define AFS_SET_OWNER 0x02 /* set the owner ID */
  138. #define AFS_SET_GROUP 0x04 /* set the group ID (unsupported?) */
  139. #define AFS_SET_MODE 0x08 /* set the UNIX mode */
  140. #define AFS_SET_SEG_SIZE 0x10 /* set the segment size (unsupported) */
  141. /*
  142. * AFS volume synchronisation information
  143. */
  144. struct afs_volsync {
  145. time64_t creation; /* volume creation time */
  146. };
  147. /*
  148. * AFS volume status record
  149. */
  150. struct afs_volume_status {
  151. afs_volid_t vid; /* volume ID */
  152. afs_volid_t parent_id; /* parent volume ID */
  153. u8 online; /* true if volume currently online and available */
  154. u8 in_service; /* true if volume currently in service */
  155. u8 blessed; /* same as in_service */
  156. u8 needs_salvage; /* true if consistency checking required */
  157. u32 type; /* volume type (afs_voltype_t) */
  158. u64 min_quota; /* minimum space set aside (blocks) */
  159. u64 max_quota; /* maximum space this volume may occupy (blocks) */
  160. u64 blocks_in_use; /* space this volume currently occupies (blocks) */
  161. u64 part_blocks_avail; /* space available in volume's partition */
  162. u64 part_max_blocks; /* size of volume's partition */
  163. s64 vol_copy_date;
  164. s64 vol_backup_date;
  165. };
  166. #define AFS_BLOCK_SIZE 1024
  167. /*
  168. * XDR encoding of UUID in AFS.
  169. */
  170. struct afs_uuid__xdr {
  171. __be32 time_low;
  172. __be32 time_mid;
  173. __be32 time_hi_and_version;
  174. __be32 clock_seq_hi_and_reserved;
  175. __be32 clock_seq_low;
  176. __be32 node[6];
  177. };
  178. #endif /* AFS_H */