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