afs.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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 AFSNAMEMAX 256 /* maximum length of a filename plus NUL */
  17. #define AFSPATHMAX 1024 /* maximum length of a pathname plus NUL */
  18. #define AFSOPAQUEMAX 1024 /* maximum length of an opaque field */
  19. typedef unsigned afs_volid_t;
  20. typedef unsigned afs_vnodeid_t;
  21. typedef unsigned long long afs_dataversion_t;
  22. typedef enum {
  23. AFSVL_RWVOL, /* read/write volume */
  24. AFSVL_ROVOL, /* read-only volume */
  25. AFSVL_BACKVOL, /* backup volume */
  26. } __attribute__((packed)) afs_voltype_t;
  27. typedef enum {
  28. AFS_FTYPE_INVALID = 0,
  29. AFS_FTYPE_FILE = 1,
  30. AFS_FTYPE_DIR = 2,
  31. AFS_FTYPE_SYMLINK = 3,
  32. } afs_file_type_t;
  33. typedef enum {
  34. AFS_LOCK_READ = 0, /* read lock request */
  35. AFS_LOCK_WRITE = 1, /* write lock request */
  36. } afs_lock_type_t;
  37. #define AFS_LOCKWAIT (5 * 60) /* time until a lock times out (seconds) */
  38. /*
  39. * AFS file identifier
  40. */
  41. struct afs_fid {
  42. afs_volid_t vid; /* volume ID */
  43. afs_vnodeid_t vnode; /* file index within volume */
  44. unsigned unique; /* unique ID number (file index version) */
  45. };
  46. /*
  47. * AFS callback notification
  48. */
  49. typedef enum {
  50. AFSCM_CB_UNTYPED = 0, /* no type set on CB break */
  51. AFSCM_CB_EXCLUSIVE = 1, /* CB exclusive to CM [not implemented] */
  52. AFSCM_CB_SHARED = 2, /* CB shared by other CM's */
  53. AFSCM_CB_DROPPED = 3, /* CB promise cancelled by file server */
  54. } afs_callback_type_t;
  55. struct afs_callback {
  56. struct afs_fid fid; /* file identifier */
  57. unsigned version; /* callback version */
  58. unsigned expiry; /* time at which expires */
  59. afs_callback_type_t type; /* type of callback */
  60. };
  61. #define AFSCBMAX 50 /* maximum callbacks transferred per bulk op */
  62. /*
  63. * AFS volume information
  64. */
  65. struct afs_volume_info {
  66. afs_volid_t vid; /* volume ID */
  67. afs_voltype_t type; /* type of this volume */
  68. afs_volid_t type_vids[5]; /* volume ID's for possible types for this vol */
  69. /* list of fileservers serving this volume */
  70. size_t nservers; /* number of entries used in servers[] */
  71. struct {
  72. struct in_addr addr; /* fileserver address */
  73. } servers[8];
  74. };
  75. /*
  76. * AFS security ACE access mask
  77. */
  78. typedef u32 afs_access_t;
  79. #define AFS_ACE_READ 0x00000001U /* - permission to read a file/dir */
  80. #define AFS_ACE_WRITE 0x00000002U /* - permission to write/chmod a file */
  81. #define AFS_ACE_INSERT 0x00000004U /* - permission to create dirent in a dir */
  82. #define AFS_ACE_LOOKUP 0x00000008U /* - permission to lookup a file/dir in a dir */
  83. #define AFS_ACE_DELETE 0x00000010U /* - permission to delete a dirent from a dir */
  84. #define AFS_ACE_LOCK 0x00000020U /* - permission to lock a file */
  85. #define AFS_ACE_ADMINISTER 0x00000040U /* - permission to change ACL */
  86. #define AFS_ACE_USER_A 0x01000000U /* - 'A' user-defined permission */
  87. #define AFS_ACE_USER_B 0x02000000U /* - 'B' user-defined permission */
  88. #define AFS_ACE_USER_C 0x04000000U /* - 'C' user-defined permission */
  89. #define AFS_ACE_USER_D 0x08000000U /* - 'D' user-defined permission */
  90. #define AFS_ACE_USER_E 0x10000000U /* - 'E' user-defined permission */
  91. #define AFS_ACE_USER_F 0x20000000U /* - 'F' user-defined permission */
  92. #define AFS_ACE_USER_G 0x40000000U /* - 'G' user-defined permission */
  93. #define AFS_ACE_USER_H 0x80000000U /* - 'H' user-defined permission */
  94. /*
  95. * AFS file status information
  96. */
  97. struct afs_file_status {
  98. unsigned if_version; /* interface version */
  99. #define AFS_FSTATUS_VERSION 1
  100. afs_file_type_t type; /* file type */
  101. unsigned nlink; /* link count */
  102. u64 size; /* file size */
  103. afs_dataversion_t data_version; /* current data version */
  104. u32 author; /* author ID */
  105. kuid_t owner; /* owner ID */
  106. kgid_t group; /* group ID */
  107. afs_access_t caller_access; /* access rights for authenticated caller */
  108. afs_access_t anon_access; /* access rights for unauthenticated caller */
  109. umode_t mode; /* UNIX mode */
  110. struct afs_fid parent; /* parent dir ID for non-dirs only */
  111. time_t mtime_client; /* last time client changed data */
  112. time_t mtime_server; /* last time server changed data */
  113. s32 lock_count; /* file lock count (0=UNLK -1=WRLCK +ve=#RDLCK */
  114. };
  115. /*
  116. * AFS file status change request
  117. */
  118. #define AFS_SET_MTIME 0x01 /* set the mtime */
  119. #define AFS_SET_OWNER 0x02 /* set the owner ID */
  120. #define AFS_SET_GROUP 0x04 /* set the group ID (unsupported?) */
  121. #define AFS_SET_MODE 0x08 /* set the UNIX mode */
  122. #define AFS_SET_SEG_SIZE 0x10 /* set the segment size (unsupported) */
  123. /*
  124. * AFS volume synchronisation information
  125. */
  126. struct afs_volsync {
  127. time_t creation; /* volume creation time */
  128. };
  129. /*
  130. * AFS volume status record
  131. */
  132. struct afs_volume_status {
  133. u32 vid; /* volume ID */
  134. u32 parent_id; /* parent volume ID */
  135. u8 online; /* true if volume currently online and available */
  136. u8 in_service; /* true if volume currently in service */
  137. u8 blessed; /* same as in_service */
  138. u8 needs_salvage; /* true if consistency checking required */
  139. u32 type; /* volume type (afs_voltype_t) */
  140. u32 min_quota; /* minimum space set aside (blocks) */
  141. u32 max_quota; /* maximum space this volume may occupy (blocks) */
  142. u32 blocks_in_use; /* space this volume currently occupies (blocks) */
  143. u32 part_blocks_avail; /* space available in volume's partition */
  144. u32 part_max_blocks; /* size of volume's partition */
  145. };
  146. #define AFS_BLOCK_SIZE 1024
  147. #endif /* AFS_H */