108e0e7c8SDavid Howells /* AFS common types 208e0e7c8SDavid Howells * 308e0e7c8SDavid Howells * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved. 408e0e7c8SDavid Howells * Written by David Howells (dhowells@redhat.com) 508e0e7c8SDavid Howells * 608e0e7c8SDavid Howells * This program is free software; you can redistribute it and/or 708e0e7c8SDavid Howells * modify it under the terms of the GNU General Public License 808e0e7c8SDavid Howells * as published by the Free Software Foundation; either version 908e0e7c8SDavid Howells * 2 of the License, or (at your option) any later version. 1008e0e7c8SDavid Howells */ 1108e0e7c8SDavid Howells 1208e0e7c8SDavid Howells #ifndef AFS_H 1308e0e7c8SDavid Howells #define AFS_H 1408e0e7c8SDavid Howells 1508e0e7c8SDavid Howells #include <linux/in.h> 1608e0e7c8SDavid Howells 1791a90380SDavid Howells #define AFS_MAXCELLNAME 64 /* Maximum length of a cell name */ 1891a90380SDavid Howells #define AFS_MAXVOLNAME 64 /* Maximum length of a volume name */ 1991a90380SDavid Howells #define AFS_MAXNSERVERS 8 /* Maximum servers in a basic volume record */ 2091a90380SDavid Howells #define AFS_NMAXNSERVERS 13 /* Maximum servers in a N/U-class volume record */ 2191a90380SDavid Howells #define AFS_MAXTYPES 3 /* Maximum number of volume types */ 2291a90380SDavid Howells #define AFSNAMEMAX 256 /* Maximum length of a filename plus NUL */ 2391a90380SDavid Howells #define AFSPATHMAX 1024 /* Maximum length of a pathname plus NUL */ 2491a90380SDavid Howells #define AFSOPAQUEMAX 1024 /* Maximum length of an opaque field */ 2500d3b7a4SDavid Howells 2608e0e7c8SDavid Howells typedef unsigned afs_volid_t; 2708e0e7c8SDavid Howells typedef unsigned afs_vnodeid_t; 2808e0e7c8SDavid Howells typedef unsigned long long afs_dataversion_t; 2908e0e7c8SDavid Howells 3008e0e7c8SDavid Howells typedef enum { 3108e0e7c8SDavid Howells AFSVL_RWVOL, /* read/write volume */ 3208e0e7c8SDavid Howells AFSVL_ROVOL, /* read-only volume */ 3308e0e7c8SDavid Howells AFSVL_BACKVOL, /* backup volume */ 3408e0e7c8SDavid Howells } __attribute__((packed)) afs_voltype_t; 3508e0e7c8SDavid Howells 3608e0e7c8SDavid Howells typedef enum { 3708e0e7c8SDavid Howells AFS_FTYPE_INVALID = 0, 3808e0e7c8SDavid Howells AFS_FTYPE_FILE = 1, 3908e0e7c8SDavid Howells AFS_FTYPE_DIR = 2, 4008e0e7c8SDavid Howells AFS_FTYPE_SYMLINK = 3, 4108e0e7c8SDavid Howells } afs_file_type_t; 4208e0e7c8SDavid Howells 43e8d6c554SDavid Howells typedef enum { 44e8d6c554SDavid Howells AFS_LOCK_READ = 0, /* read lock request */ 45e8d6c554SDavid Howells AFS_LOCK_WRITE = 1, /* write lock request */ 46e8d6c554SDavid Howells } afs_lock_type_t; 47e8d6c554SDavid Howells 48e8d6c554SDavid Howells #define AFS_LOCKWAIT (5 * 60) /* time until a lock times out (seconds) */ 49e8d6c554SDavid Howells 5008e0e7c8SDavid Howells /* 5108e0e7c8SDavid Howells * AFS file identifier 5208e0e7c8SDavid Howells */ 5308e0e7c8SDavid Howells struct afs_fid { 5408e0e7c8SDavid Howells afs_volid_t vid; /* volume ID */ 5508e0e7c8SDavid Howells afs_vnodeid_t vnode; /* file index within volume */ 5608e0e7c8SDavid Howells unsigned 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 { 7008e0e7c8SDavid Howells struct afs_fid fid; /* file identifier */ 7108e0e7c8SDavid Howells unsigned version; /* callback version */ 7208e0e7c8SDavid Howells unsigned expiry; /* time at which expires */ 7308e0e7c8SDavid Howells afs_callback_type_t type; /* type of callback */ 7408e0e7c8SDavid Howells }; 7508e0e7c8SDavid Howells 7608e0e7c8SDavid Howells #define AFSCBMAX 50 /* maximum callbacks transferred per bulk op */ 7708e0e7c8SDavid Howells 78f044c884SDavid Howells struct afs_uuid { 79f044c884SDavid Howells __be32 time_low; /* low part of timestamp */ 80f044c884SDavid Howells __be16 time_mid; /* mid part of timestamp */ 81f044c884SDavid Howells __be16 time_hi_and_version; /* high part of timestamp and version */ 8203dc2cfcSDavid Howells __s8 clock_seq_hi_and_reserved; /* clock seq hi and variant */ 8303dc2cfcSDavid Howells __s8 clock_seq_low; /* clock seq low */ 8403dc2cfcSDavid Howells __s8 node[6]; /* spatially unique node ID (MAC addr) */ 85f044c884SDavid Howells }; 86f044c884SDavid Howells 8708e0e7c8SDavid Howells /* 8808e0e7c8SDavid Howells * AFS volume information 8908e0e7c8SDavid Howells */ 9008e0e7c8SDavid Howells struct afs_volume_info { 9108e0e7c8SDavid Howells afs_volid_t vid; /* volume ID */ 9208e0e7c8SDavid Howells afs_voltype_t type; /* type of this volume */ 9308e0e7c8SDavid Howells afs_volid_t type_vids[5]; /* volume ID's for possible types for this vol */ 9408e0e7c8SDavid Howells 9508e0e7c8SDavid Howells /* list of fileservers serving this volume */ 9608e0e7c8SDavid Howells size_t nservers; /* number of entries used in servers[] */ 9708e0e7c8SDavid Howells struct { 9808e0e7c8SDavid Howells struct in_addr addr; /* fileserver address */ 9908e0e7c8SDavid Howells } servers[8]; 10008e0e7c8SDavid Howells }; 10108e0e7c8SDavid Howells 10208e0e7c8SDavid Howells /* 10300d3b7a4SDavid Howells * AFS security ACE access mask 10400d3b7a4SDavid Howells */ 10500d3b7a4SDavid Howells typedef u32 afs_access_t; 10600d3b7a4SDavid Howells #define AFS_ACE_READ 0x00000001U /* - permission to read a file/dir */ 10700d3b7a4SDavid Howells #define AFS_ACE_WRITE 0x00000002U /* - permission to write/chmod a file */ 10800d3b7a4SDavid Howells #define AFS_ACE_INSERT 0x00000004U /* - permission to create dirent in a dir */ 10900d3b7a4SDavid Howells #define AFS_ACE_LOOKUP 0x00000008U /* - permission to lookup a file/dir in a dir */ 11000d3b7a4SDavid Howells #define AFS_ACE_DELETE 0x00000010U /* - permission to delete a dirent from a dir */ 11100d3b7a4SDavid Howells #define AFS_ACE_LOCK 0x00000020U /* - permission to lock a file */ 11200d3b7a4SDavid Howells #define AFS_ACE_ADMINISTER 0x00000040U /* - permission to change ACL */ 11300d3b7a4SDavid Howells #define AFS_ACE_USER_A 0x01000000U /* - 'A' user-defined permission */ 11400d3b7a4SDavid Howells #define AFS_ACE_USER_B 0x02000000U /* - 'B' user-defined permission */ 11500d3b7a4SDavid Howells #define AFS_ACE_USER_C 0x04000000U /* - 'C' user-defined permission */ 11600d3b7a4SDavid Howells #define AFS_ACE_USER_D 0x08000000U /* - 'D' user-defined permission */ 11700d3b7a4SDavid Howells #define AFS_ACE_USER_E 0x10000000U /* - 'E' user-defined permission */ 11800d3b7a4SDavid Howells #define AFS_ACE_USER_F 0x20000000U /* - 'F' user-defined permission */ 11900d3b7a4SDavid Howells #define AFS_ACE_USER_G 0x40000000U /* - 'G' user-defined permission */ 12000d3b7a4SDavid Howells #define AFS_ACE_USER_H 0x80000000U /* - 'H' user-defined permission */ 12100d3b7a4SDavid Howells 12200d3b7a4SDavid Howells /* 12308e0e7c8SDavid Howells * AFS file status information 12408e0e7c8SDavid Howells */ 12508e0e7c8SDavid Howells struct afs_file_status { 12608e0e7c8SDavid Howells unsigned if_version; /* interface version */ 12708e0e7c8SDavid Howells #define AFS_FSTATUS_VERSION 1 12808e0e7c8SDavid Howells 12908e0e7c8SDavid Howells afs_file_type_t type; /* file type */ 13008e0e7c8SDavid Howells unsigned nlink; /* link count */ 131260a9803SDavid Howells u64 size; /* file size */ 13208e0e7c8SDavid Howells afs_dataversion_t data_version; /* current data version */ 133260a9803SDavid Howells u32 author; /* author ID */ 134a0a5386aSEric W. Biederman kuid_t owner; /* owner ID */ 135a0a5386aSEric W. Biederman kgid_t group; /* group ID */ 13600d3b7a4SDavid Howells afs_access_t caller_access; /* access rights for authenticated caller */ 13700d3b7a4SDavid Howells afs_access_t anon_access; /* access rights for unauthenticated caller */ 13808e0e7c8SDavid Howells umode_t mode; /* UNIX mode */ 139260a9803SDavid Howells struct afs_fid parent; /* parent dir ID for non-dirs only */ 14008e0e7c8SDavid Howells time_t mtime_client; /* last time client changed data */ 14108e0e7c8SDavid Howells time_t mtime_server; /* last time server changed data */ 142e8d6c554SDavid Howells s32 lock_count; /* file lock count (0=UNLK -1=WRLCK +ve=#RDLCK */ 14308e0e7c8SDavid Howells }; 14408e0e7c8SDavid Howells 14508e0e7c8SDavid Howells /* 146260a9803SDavid Howells * AFS file status change request 147260a9803SDavid Howells */ 148260a9803SDavid Howells 149260a9803SDavid Howells #define AFS_SET_MTIME 0x01 /* set the mtime */ 150260a9803SDavid Howells #define AFS_SET_OWNER 0x02 /* set the owner ID */ 151260a9803SDavid Howells #define AFS_SET_GROUP 0x04 /* set the group ID (unsupported?) */ 152260a9803SDavid Howells #define AFS_SET_MODE 0x08 /* set the UNIX mode */ 153260a9803SDavid Howells #define AFS_SET_SEG_SIZE 0x10 /* set the segment size (unsupported) */ 154260a9803SDavid Howells 155260a9803SDavid Howells /* 15608e0e7c8SDavid Howells * AFS volume synchronisation information 15708e0e7c8SDavid Howells */ 15808e0e7c8SDavid Howells struct afs_volsync { 15908e0e7c8SDavid Howells time_t creation; /* volume creation time */ 16008e0e7c8SDavid Howells }; 16108e0e7c8SDavid Howells 16245222b9eSDavid Howells /* 16345222b9eSDavid Howells * AFS volume status record 16445222b9eSDavid Howells */ 16545222b9eSDavid Howells struct afs_volume_status { 16645222b9eSDavid Howells u32 vid; /* volume ID */ 16745222b9eSDavid Howells u32 parent_id; /* parent volume ID */ 16845222b9eSDavid Howells u8 online; /* true if volume currently online and available */ 16945222b9eSDavid Howells u8 in_service; /* true if volume currently in service */ 17045222b9eSDavid Howells u8 blessed; /* same as in_service */ 17145222b9eSDavid Howells u8 needs_salvage; /* true if consistency checking required */ 17245222b9eSDavid Howells u32 type; /* volume type (afs_voltype_t) */ 17345222b9eSDavid Howells u32 min_quota; /* minimum space set aside (blocks) */ 17445222b9eSDavid Howells u32 max_quota; /* maximum space this volume may occupy (blocks) */ 17545222b9eSDavid Howells u32 blocks_in_use; /* space this volume currently occupies (blocks) */ 17645222b9eSDavid Howells u32 part_blocks_avail; /* space available in volume's partition */ 17745222b9eSDavid Howells u32 part_max_blocks; /* size of volume's partition */ 17845222b9eSDavid Howells }; 17945222b9eSDavid Howells 18045222b9eSDavid Howells #define AFS_BLOCK_SIZE 1024 18145222b9eSDavid Howells 18291a90380SDavid Howells /* 18391a90380SDavid Howells * XDR encoding of UUID in AFS. 18491a90380SDavid Howells */ 18591a90380SDavid Howells struct afs_uuid__xdr { 18691a90380SDavid Howells __be32 time_low; 18791a90380SDavid Howells __be32 time_mid; 18891a90380SDavid Howells __be32 time_hi_and_version; 18991a90380SDavid Howells __be32 clock_seq_hi_and_reserved; 19091a90380SDavid Howells __be32 clock_seq_low; 19191a90380SDavid Howells __be32 node[6]; 19291a90380SDavid Howells }; 19391a90380SDavid Howells 19408e0e7c8SDavid Howells #endif /* AFS_H */ 195