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