12874c5fdSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 208e0e7c8SDavid Howells /* AFS common types 308e0e7c8SDavid Howells * 408e0e7c8SDavid Howells * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved. 508e0e7c8SDavid Howells * Written by David Howells (dhowells@redhat.com) 608e0e7c8SDavid Howells */ 708e0e7c8SDavid Howells 808e0e7c8SDavid Howells #ifndef AFS_H 908e0e7c8SDavid Howells #define AFS_H 1008e0e7c8SDavid Howells 1108e0e7c8SDavid Howells #include <linux/in.h> 1208e0e7c8SDavid Howells 13*7673030eSDavid Howells #define AFS_MAXCELLNAME 253 /* Maximum length of a cell name (DNS limited) */ 1491a90380SDavid Howells #define AFS_MAXVOLNAME 64 /* Maximum length of a volume name */ 1591a90380SDavid Howells #define AFS_MAXNSERVERS 8 /* Maximum servers in a basic volume record */ 1691a90380SDavid Howells #define AFS_NMAXNSERVERS 13 /* Maximum servers in a N/U-class volume record */ 1791a90380SDavid Howells #define AFS_MAXTYPES 3 /* Maximum number of volume types */ 1891a90380SDavid Howells #define AFSNAMEMAX 256 /* Maximum length of a filename plus NUL */ 1991a90380SDavid Howells #define AFSPATHMAX 1024 /* Maximum length of a pathname plus NUL */ 2091a90380SDavid Howells #define AFSOPAQUEMAX 1024 /* Maximum length of an opaque field */ 2100d3b7a4SDavid Howells 22db099c62SDavid Howells #define AFS_VL_MAX_LIFESPAN 120 23db099c62SDavid Howells #define AFS_PROBE_MAX_LIFESPAN 30 2494f699c9SDavid Howells 253b6492dfSDavid Howells typedef u64 afs_volid_t; 263b6492dfSDavid Howells typedef u64 afs_vnodeid_t; 273b6492dfSDavid Howells typedef u64 afs_dataversion_t; 2808e0e7c8SDavid Howells 2908e0e7c8SDavid Howells typedef enum { 3008e0e7c8SDavid Howells AFSVL_RWVOL, /* read/write volume */ 3108e0e7c8SDavid Howells AFSVL_ROVOL, /* read-only volume */ 3208e0e7c8SDavid Howells AFSVL_BACKVOL, /* backup volume */ 3308e0e7c8SDavid Howells } __attribute__((packed)) afs_voltype_t; 3408e0e7c8SDavid Howells 3508e0e7c8SDavid Howells typedef enum { 3608e0e7c8SDavid Howells AFS_FTYPE_INVALID = 0, 3708e0e7c8SDavid Howells AFS_FTYPE_FILE = 1, 3808e0e7c8SDavid Howells AFS_FTYPE_DIR = 2, 3908e0e7c8SDavid Howells AFS_FTYPE_SYMLINK = 3, 4008e0e7c8SDavid Howells } afs_file_type_t; 4108e0e7c8SDavid Howells 42e8d6c554SDavid Howells typedef enum { 43e8d6c554SDavid Howells AFS_LOCK_READ = 0, /* read lock request */ 44e8d6c554SDavid Howells AFS_LOCK_WRITE = 1, /* write lock request */ 45e8d6c554SDavid Howells } afs_lock_type_t; 46e8d6c554SDavid Howells 47e8d6c554SDavid Howells #define AFS_LOCKWAIT (5 * 60) /* time until a lock times out (seconds) */ 48e8d6c554SDavid Howells 4908e0e7c8SDavid Howells /* 5008e0e7c8SDavid Howells * AFS file identifier 5108e0e7c8SDavid Howells */ 5208e0e7c8SDavid Howells struct afs_fid { 5308e0e7c8SDavid Howells afs_volid_t vid; /* volume ID */ 543b6492dfSDavid Howells afs_vnodeid_t vnode; /* Lower 64-bits of file index within volume */ 553b6492dfSDavid Howells u32 vnode_hi; /* Upper 32-bits of file index */ 563b6492dfSDavid Howells u32 unique; /* unique ID number (file index version) */ 5708e0e7c8SDavid Howells }; 5808e0e7c8SDavid Howells 5908e0e7c8SDavid Howells /* 6008e0e7c8SDavid Howells * AFS callback notification 6108e0e7c8SDavid Howells */ 6208e0e7c8SDavid Howells typedef enum { 6308e0e7c8SDavid Howells AFSCM_CB_UNTYPED = 0, /* no type set on CB break */ 6408e0e7c8SDavid Howells AFSCM_CB_EXCLUSIVE = 1, /* CB exclusive to CM [not implemented] */ 6508e0e7c8SDavid Howells AFSCM_CB_SHARED = 2, /* CB shared by other CM's */ 6608e0e7c8SDavid Howells AFSCM_CB_DROPPED = 3, /* CB promise cancelled by file server */ 6708e0e7c8SDavid Howells } afs_callback_type_t; 6808e0e7c8SDavid Howells 6908e0e7c8SDavid Howells struct afs_callback { 7012d8e95aSDavid Howells time64_t expires_at; /* Time at which expires */ 717c712458SDavid Howells //unsigned version; /* Callback version */ 727c712458SDavid Howells //afs_callback_type_t type; /* Type of callback */ 735cf9dd55SDavid Howells }; 745cf9dd55SDavid Howells 755cf9dd55SDavid Howells struct afs_callback_break { 765cf9dd55SDavid Howells struct afs_fid fid; /* File identifier */ 7706aeb297SDavid Howells //struct afs_callback cb; /* Callback details */ 7808e0e7c8SDavid Howells }; 7908e0e7c8SDavid Howells 8008e0e7c8SDavid Howells #define AFSCBMAX 50 /* maximum callbacks transferred per bulk op */ 8108e0e7c8SDavid Howells 82f044c884SDavid Howells struct afs_uuid { 83f044c884SDavid Howells __be32 time_low; /* low part of timestamp */ 84f044c884SDavid Howells __be16 time_mid; /* mid part of timestamp */ 85f044c884SDavid Howells __be16 time_hi_and_version; /* high part of timestamp and version */ 8603dc2cfcSDavid Howells __s8 clock_seq_hi_and_reserved; /* clock seq hi and variant */ 8703dc2cfcSDavid Howells __s8 clock_seq_low; /* clock seq low */ 8803dc2cfcSDavid Howells __s8 node[6]; /* spatially unique node ID (MAC addr) */ 89f044c884SDavid Howells }; 90f044c884SDavid Howells 9108e0e7c8SDavid Howells /* 9208e0e7c8SDavid Howells * AFS volume information 9308e0e7c8SDavid Howells */ 9408e0e7c8SDavid Howells struct afs_volume_info { 9508e0e7c8SDavid Howells afs_volid_t vid; /* volume ID */ 9608e0e7c8SDavid Howells afs_voltype_t type; /* type of this volume */ 9708e0e7c8SDavid Howells afs_volid_t type_vids[5]; /* volume ID's for possible types for this vol */ 9808e0e7c8SDavid Howells 9908e0e7c8SDavid Howells /* list of fileservers serving this volume */ 10008e0e7c8SDavid Howells size_t nservers; /* number of entries used in servers[] */ 10108e0e7c8SDavid Howells struct { 10208e0e7c8SDavid Howells struct in_addr addr; /* fileserver address */ 10308e0e7c8SDavid Howells } servers[8]; 10408e0e7c8SDavid Howells }; 10508e0e7c8SDavid Howells 10608e0e7c8SDavid Howells /* 10700d3b7a4SDavid Howells * AFS security ACE access mask 10800d3b7a4SDavid Howells */ 10900d3b7a4SDavid Howells typedef u32 afs_access_t; 11000d3b7a4SDavid Howells #define AFS_ACE_READ 0x00000001U /* - permission to read a file/dir */ 11100d3b7a4SDavid Howells #define AFS_ACE_WRITE 0x00000002U /* - permission to write/chmod a file */ 11200d3b7a4SDavid Howells #define AFS_ACE_INSERT 0x00000004U /* - permission to create dirent in a dir */ 11300d3b7a4SDavid Howells #define AFS_ACE_LOOKUP 0x00000008U /* - permission to lookup a file/dir in a dir */ 11400d3b7a4SDavid Howells #define AFS_ACE_DELETE 0x00000010U /* - permission to delete a dirent from a dir */ 11500d3b7a4SDavid Howells #define AFS_ACE_LOCK 0x00000020U /* - permission to lock a file */ 11600d3b7a4SDavid Howells #define AFS_ACE_ADMINISTER 0x00000040U /* - permission to change ACL */ 11700d3b7a4SDavid Howells #define AFS_ACE_USER_A 0x01000000U /* - 'A' user-defined permission */ 11800d3b7a4SDavid Howells #define AFS_ACE_USER_B 0x02000000U /* - 'B' user-defined permission */ 11900d3b7a4SDavid Howells #define AFS_ACE_USER_C 0x04000000U /* - 'C' user-defined permission */ 12000d3b7a4SDavid Howells #define AFS_ACE_USER_D 0x08000000U /* - 'D' user-defined permission */ 12100d3b7a4SDavid Howells #define AFS_ACE_USER_E 0x10000000U /* - 'E' user-defined permission */ 12200d3b7a4SDavid Howells #define AFS_ACE_USER_F 0x20000000U /* - 'F' user-defined permission */ 12300d3b7a4SDavid Howells #define AFS_ACE_USER_G 0x40000000U /* - 'G' user-defined permission */ 12400d3b7a4SDavid Howells #define AFS_ACE_USER_H 0x80000000U /* - 'H' user-defined permission */ 12500d3b7a4SDavid Howells 12600d3b7a4SDavid Howells /* 12708e0e7c8SDavid Howells * AFS file status information 12808e0e7c8SDavid Howells */ 12908e0e7c8SDavid Howells struct afs_file_status { 1305cf9dd55SDavid Howells u64 size; /* file size */ 1315cf9dd55SDavid Howells afs_dataversion_t data_version; /* current data version */ 132d4936803SDavid Howells struct timespec64 mtime_client; /* Last time client changed data */ 133d4936803SDavid Howells struct timespec64 mtime_server; /* Last time server changed data */ 134d4936803SDavid Howells s64 author; /* author ID */ 135d4936803SDavid Howells s64 owner; /* owner ID */ 136d4936803SDavid Howells s64 group; /* group ID */ 13700d3b7a4SDavid Howells afs_access_t caller_access; /* access rights for authenticated caller */ 13800d3b7a4SDavid Howells afs_access_t anon_access; /* access rights for unauthenticated caller */ 13908e0e7c8SDavid Howells umode_t mode; /* UNIX mode */ 140d4936803SDavid Howells afs_file_type_t type; /* file type */ 141d4936803SDavid Howells u32 nlink; /* link count */ 142e8d6c554SDavid Howells s32 lock_count; /* file lock count (0=UNLK -1=WRLCK +ve=#RDLCK */ 143d4936803SDavid Howells u32 abort_code; /* Abort if bulk-fetching this failed */ 14408e0e7c8SDavid Howells }; 14508e0e7c8SDavid Howells 14687182759SDavid Howells struct afs_status_cb { 14787182759SDavid Howells struct afs_file_status status; 14887182759SDavid Howells struct afs_callback callback; 149a38a7558SDavid Howells bool have_status; /* True if status record was retrieved */ 15087182759SDavid Howells bool have_cb; /* True if cb record was retrieved */ 151a38a7558SDavid Howells bool have_error; /* True if status.abort_code indicates an error */ 15287182759SDavid Howells }; 15387182759SDavid Howells 15408e0e7c8SDavid Howells /* 155260a9803SDavid Howells * AFS file status change request 156260a9803SDavid Howells */ 157260a9803SDavid Howells 158260a9803SDavid Howells #define AFS_SET_MTIME 0x01 /* set the mtime */ 159260a9803SDavid Howells #define AFS_SET_OWNER 0x02 /* set the owner ID */ 160260a9803SDavid Howells #define AFS_SET_GROUP 0x04 /* set the group ID (unsupported?) */ 161260a9803SDavid Howells #define AFS_SET_MODE 0x08 /* set the UNIX mode */ 162260a9803SDavid Howells #define AFS_SET_SEG_SIZE 0x10 /* set the segment size (unsupported) */ 163260a9803SDavid Howells 164260a9803SDavid Howells /* 16508e0e7c8SDavid Howells * AFS volume synchronisation information 16608e0e7c8SDavid Howells */ 16708e0e7c8SDavid Howells struct afs_volsync { 168d4936803SDavid Howells time64_t creation; /* volume creation time */ 16908e0e7c8SDavid Howells }; 17008e0e7c8SDavid Howells 17145222b9eSDavid Howells /* 17245222b9eSDavid Howells * AFS volume status record 17345222b9eSDavid Howells */ 17445222b9eSDavid Howells struct afs_volume_status { 175d4936803SDavid Howells afs_volid_t vid; /* volume ID */ 176d4936803SDavid Howells afs_volid_t parent_id; /* parent volume ID */ 17745222b9eSDavid Howells u8 online; /* true if volume currently online and available */ 17845222b9eSDavid Howells u8 in_service; /* true if volume currently in service */ 17945222b9eSDavid Howells u8 blessed; /* same as in_service */ 18045222b9eSDavid Howells u8 needs_salvage; /* true if consistency checking required */ 18145222b9eSDavid Howells u32 type; /* volume type (afs_voltype_t) */ 182d4936803SDavid Howells u64 min_quota; /* minimum space set aside (blocks) */ 183d4936803SDavid Howells u64 max_quota; /* maximum space this volume may occupy (blocks) */ 184d4936803SDavid Howells u64 blocks_in_use; /* space this volume currently occupies (blocks) */ 185d4936803SDavid Howells u64 part_blocks_avail; /* space available in volume's partition */ 186d4936803SDavid Howells u64 part_max_blocks; /* size of volume's partition */ 187d4936803SDavid Howells s64 vol_copy_date; 188d4936803SDavid Howells s64 vol_backup_date; 18945222b9eSDavid Howells }; 19045222b9eSDavid Howells 19145222b9eSDavid Howells #define AFS_BLOCK_SIZE 1024 19245222b9eSDavid Howells 19391a90380SDavid Howells /* 19491a90380SDavid Howells * XDR encoding of UUID in AFS. 19591a90380SDavid Howells */ 19691a90380SDavid Howells struct afs_uuid__xdr { 19791a90380SDavid Howells __be32 time_low; 19891a90380SDavid Howells __be32 time_mid; 19991a90380SDavid Howells __be32 time_hi_and_version; 20091a90380SDavid Howells __be32 clock_seq_hi_and_reserved; 20191a90380SDavid Howells __be32 clock_seq_low; 20291a90380SDavid Howells __be32 node[6]; 20391a90380SDavid Howells }; 20491a90380SDavid Howells 20508e0e7c8SDavid Howells #endif /* AFS_H */ 206