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