afs.h 6.5 KB

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