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 263b6492dfSDavid Howells typedef u64 afs_volid_t; 273b6492dfSDavid Howells typedef u64 afs_vnodeid_t; 283b6492dfSDavid Howells typedef u64 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 */ 553b6492dfSDavid Howells afs_vnodeid_t vnode; /* Lower 64-bits of file index within volume */ 563b6492dfSDavid Howells u32 vnode_hi; /* Upper 32-bits of file index */ 573b6492dfSDavid Howells u32 unique; /* unique ID number (file index version) */ 5808e0e7c8SDavid Howells }; 5908e0e7c8SDavid Howells 6008e0e7c8SDavid Howells /* 6108e0e7c8SDavid Howells * AFS callback notification 6208e0e7c8SDavid Howells */ 6308e0e7c8SDavid Howells typedef enum { 6408e0e7c8SDavid Howells AFSCM_CB_UNTYPED = 0, /* no type set on CB break */ 6508e0e7c8SDavid Howells AFSCM_CB_EXCLUSIVE = 1, /* CB exclusive to CM [not implemented] */ 6608e0e7c8SDavid Howells AFSCM_CB_SHARED = 2, /* CB shared by other CM's */ 6708e0e7c8SDavid Howells AFSCM_CB_DROPPED = 3, /* CB promise cancelled by file server */ 6808e0e7c8SDavid Howells } afs_callback_type_t; 6908e0e7c8SDavid Howells 7008e0e7c8SDavid Howells struct afs_callback { 715cf9dd55SDavid Howells unsigned version; /* Callback version */ 725cf9dd55SDavid Howells unsigned expiry; /* Time at which expires */ 735cf9dd55SDavid Howells afs_callback_type_t type; /* Type of callback */ 745cf9dd55SDavid Howells }; 755cf9dd55SDavid Howells 765cf9dd55SDavid Howells struct afs_callback_break { 775cf9dd55SDavid Howells struct afs_fid fid; /* File identifier */ 7806aeb297SDavid Howells //struct afs_callback cb; /* Callback details */ 7908e0e7c8SDavid Howells }; 8008e0e7c8SDavid Howells 8108e0e7c8SDavid Howells #define AFSCBMAX 50 /* maximum callbacks transferred per bulk op */ 8208e0e7c8SDavid Howells 83f044c884SDavid Howells struct afs_uuid { 84f044c884SDavid Howells __be32 time_low; /* low part of timestamp */ 85f044c884SDavid Howells __be16 time_mid; /* mid part of timestamp */ 86f044c884SDavid Howells __be16 time_hi_and_version; /* high part of timestamp and version */ 8703dc2cfcSDavid Howells __s8 clock_seq_hi_and_reserved; /* clock seq hi and variant */ 8803dc2cfcSDavid Howells __s8 clock_seq_low; /* clock seq low */ 8903dc2cfcSDavid Howells __s8 node[6]; /* spatially unique node ID (MAC addr) */ 90f044c884SDavid Howells }; 91f044c884SDavid Howells 9208e0e7c8SDavid Howells /* 9308e0e7c8SDavid Howells * AFS volume information 9408e0e7c8SDavid Howells */ 9508e0e7c8SDavid Howells struct afs_volume_info { 9608e0e7c8SDavid Howells afs_volid_t vid; /* volume ID */ 9708e0e7c8SDavid Howells afs_voltype_t type; /* type of this volume */ 9808e0e7c8SDavid Howells afs_volid_t type_vids[5]; /* volume ID's for possible types for this vol */ 9908e0e7c8SDavid Howells 10008e0e7c8SDavid Howells /* list of fileservers serving this volume */ 10108e0e7c8SDavid Howells size_t nservers; /* number of entries used in servers[] */ 10208e0e7c8SDavid Howells struct { 10308e0e7c8SDavid Howells struct in_addr addr; /* fileserver address */ 10408e0e7c8SDavid Howells } servers[8]; 10508e0e7c8SDavid Howells }; 10608e0e7c8SDavid Howells 10708e0e7c8SDavid Howells /* 10800d3b7a4SDavid Howells * AFS security ACE access mask 10900d3b7a4SDavid Howells */ 11000d3b7a4SDavid Howells typedef u32 afs_access_t; 11100d3b7a4SDavid Howells #define AFS_ACE_READ 0x00000001U /* - permission to read a file/dir */ 11200d3b7a4SDavid Howells #define AFS_ACE_WRITE 0x00000002U /* - permission to write/chmod a file */ 11300d3b7a4SDavid Howells #define AFS_ACE_INSERT 0x00000004U /* - permission to create dirent in a dir */ 11400d3b7a4SDavid Howells #define AFS_ACE_LOOKUP 0x00000008U /* - permission to lookup a file/dir in a dir */ 11500d3b7a4SDavid Howells #define AFS_ACE_DELETE 0x00000010U /* - permission to delete a dirent from a dir */ 11600d3b7a4SDavid Howells #define AFS_ACE_LOCK 0x00000020U /* - permission to lock a file */ 11700d3b7a4SDavid Howells #define AFS_ACE_ADMINISTER 0x00000040U /* - permission to change ACL */ 11800d3b7a4SDavid Howells #define AFS_ACE_USER_A 0x01000000U /* - 'A' user-defined permission */ 11900d3b7a4SDavid Howells #define AFS_ACE_USER_B 0x02000000U /* - 'B' user-defined permission */ 12000d3b7a4SDavid Howells #define AFS_ACE_USER_C 0x04000000U /* - 'C' user-defined permission */ 12100d3b7a4SDavid Howells #define AFS_ACE_USER_D 0x08000000U /* - 'D' user-defined permission */ 12200d3b7a4SDavid Howells #define AFS_ACE_USER_E 0x10000000U /* - 'E' user-defined permission */ 12300d3b7a4SDavid Howells #define AFS_ACE_USER_F 0x20000000U /* - 'F' user-defined permission */ 12400d3b7a4SDavid Howells #define AFS_ACE_USER_G 0x40000000U /* - 'G' user-defined permission */ 12500d3b7a4SDavid Howells #define AFS_ACE_USER_H 0x80000000U /* - 'H' user-defined permission */ 12600d3b7a4SDavid Howells 12700d3b7a4SDavid Howells /* 12808e0e7c8SDavid Howells * AFS file status information 12908e0e7c8SDavid Howells */ 13008e0e7c8SDavid Howells struct afs_file_status { 1315cf9dd55SDavid Howells u64 size; /* file size */ 1325cf9dd55SDavid Howells afs_dataversion_t data_version; /* current data version */ 1335cf9dd55SDavid Howells time_t mtime_client; /* last time client changed data */ 1345cf9dd55SDavid Howells time_t mtime_server; /* last time server changed data */ 1355cf9dd55SDavid Howells unsigned abort_code; /* Abort if bulk-fetching this failed */ 13608e0e7c8SDavid Howells 13708e0e7c8SDavid Howells afs_file_type_t type; /* file type */ 13808e0e7c8SDavid Howells unsigned nlink; /* link count */ 139260a9803SDavid Howells u32 author; /* author ID */ 140dd9fbcb8SDavid Howells u32 owner; /* owner ID */ 141dd9fbcb8SDavid Howells u32 group; /* group ID */ 14200d3b7a4SDavid Howells afs_access_t caller_access; /* access rights for authenticated caller */ 14300d3b7a4SDavid Howells afs_access_t anon_access; /* access rights for unauthenticated caller */ 14408e0e7c8SDavid Howells umode_t mode; /* UNIX mode */ 145e8d6c554SDavid Howells s32 lock_count; /* file lock count (0=UNLK -1=WRLCK +ve=#RDLCK */ 14608e0e7c8SDavid Howells }; 14708e0e7c8SDavid Howells 14808e0e7c8SDavid Howells /* 149260a9803SDavid Howells * AFS file status change request 150260a9803SDavid Howells */ 151260a9803SDavid Howells 152260a9803SDavid Howells #define AFS_SET_MTIME 0x01 /* set the mtime */ 153260a9803SDavid Howells #define AFS_SET_OWNER 0x02 /* set the owner ID */ 154260a9803SDavid Howells #define AFS_SET_GROUP 0x04 /* set the group ID (unsupported?) */ 155260a9803SDavid Howells #define AFS_SET_MODE 0x08 /* set the UNIX mode */ 156260a9803SDavid Howells #define AFS_SET_SEG_SIZE 0x10 /* set the segment size (unsupported) */ 157260a9803SDavid Howells 158260a9803SDavid Howells /* 15908e0e7c8SDavid Howells * AFS volume synchronisation information 16008e0e7c8SDavid Howells */ 16108e0e7c8SDavid Howells struct afs_volsync { 16208e0e7c8SDavid Howells time_t creation; /* volume creation time */ 16308e0e7c8SDavid Howells }; 16408e0e7c8SDavid Howells 16545222b9eSDavid Howells /* 16645222b9eSDavid Howells * AFS volume status record 16745222b9eSDavid Howells */ 16845222b9eSDavid Howells struct afs_volume_status { 16945222b9eSDavid Howells u32 vid; /* volume ID */ 17045222b9eSDavid Howells u32 parent_id; /* parent volume ID */ 17145222b9eSDavid Howells u8 online; /* true if volume currently online and available */ 17245222b9eSDavid Howells u8 in_service; /* true if volume currently in service */ 17345222b9eSDavid Howells u8 blessed; /* same as in_service */ 17445222b9eSDavid Howells u8 needs_salvage; /* true if consistency checking required */ 17545222b9eSDavid Howells u32 type; /* volume type (afs_voltype_t) */ 17645222b9eSDavid Howells u32 min_quota; /* minimum space set aside (blocks) */ 17745222b9eSDavid Howells u32 max_quota; /* maximum space this volume may occupy (blocks) */ 17845222b9eSDavid Howells u32 blocks_in_use; /* space this volume currently occupies (blocks) */ 17945222b9eSDavid Howells u32 part_blocks_avail; /* space available in volume's partition */ 18045222b9eSDavid Howells u32 part_max_blocks; /* size of volume's partition */ 18145222b9eSDavid Howells }; 18245222b9eSDavid Howells 18345222b9eSDavid Howells #define AFS_BLOCK_SIZE 1024 18445222b9eSDavid Howells 18591a90380SDavid Howells /* 18691a90380SDavid Howells * XDR encoding of UUID in AFS. 18791a90380SDavid Howells */ 18891a90380SDavid Howells struct afs_uuid__xdr { 18991a90380SDavid Howells __be32 time_low; 19091a90380SDavid Howells __be32 time_mid; 19191a90380SDavid Howells __be32 time_hi_and_version; 19291a90380SDavid Howells __be32 clock_seq_hi_and_reserved; 19391a90380SDavid Howells __be32 clock_seq_low; 19491a90380SDavid Howells __be32 node[6]; 19591a90380SDavid Howells }; 19691a90380SDavid Howells 19708e0e7c8SDavid Howells #endif /* AFS_H */ 198