Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /* AFS common types
0003  *
0004  * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved.
0005  * Written by David Howells (dhowells@redhat.com)
0006  */
0007 
0008 #ifndef AFS_H
0009 #define AFS_H
0010 
0011 #include <linux/in.h>
0012 
0013 #define AFS_MAXCELLNAME     256     /* Maximum length of a cell name */
0014 #define AFS_MAXVOLNAME      64      /* Maximum length of a volume name */
0015 #define AFS_MAXNSERVERS     8       /* Maximum servers in a basic volume record */
0016 #define AFS_NMAXNSERVERS    13      /* Maximum servers in a N/U-class volume record */
0017 #define AFS_MAXTYPES        3   /* Maximum number of volume types */
0018 #define AFSNAMEMAX      256     /* Maximum length of a filename plus NUL */
0019 #define AFSPATHMAX      1024    /* Maximum length of a pathname plus NUL */
0020 #define AFSOPAQUEMAX        1024    /* Maximum length of an opaque field */
0021 
0022 #define AFS_VL_MAX_LIFESPAN (120 * HZ)
0023 #define AFS_PROBE_MAX_LIFESPAN  (30 * HZ)
0024 
0025 typedef u64         afs_volid_t;
0026 typedef u64         afs_vnodeid_t;
0027 typedef u64         afs_dataversion_t;
0028 
0029 typedef enum {
0030     AFSVL_RWVOL,            /* read/write volume */
0031     AFSVL_ROVOL,            /* read-only volume */
0032     AFSVL_BACKVOL,          /* backup volume */
0033 } __attribute__((packed)) afs_voltype_t;
0034 
0035 typedef enum {
0036     AFS_FTYPE_INVALID   = 0,
0037     AFS_FTYPE_FILE      = 1,
0038     AFS_FTYPE_DIR       = 2,
0039     AFS_FTYPE_SYMLINK   = 3,
0040 } afs_file_type_t;
0041 
0042 typedef enum {
0043     AFS_LOCK_READ       = 0,    /* read lock request */
0044     AFS_LOCK_WRITE      = 1,    /* write lock request */
0045 } afs_lock_type_t;
0046 
0047 #define AFS_LOCKWAIT        (5 * 60) /* time until a lock times out (seconds) */
0048 
0049 /*
0050  * AFS file identifier
0051  */
0052 struct afs_fid {
0053     afs_volid_t vid;        /* volume ID */
0054     afs_vnodeid_t   vnode;      /* Lower 64-bits of file index within volume */
0055     u32     vnode_hi;   /* Upper 32-bits of file index */
0056     u32     unique;     /* unique ID number (file index version) */
0057 };
0058 
0059 /*
0060  * AFS callback notification
0061  */
0062 typedef enum {
0063     AFSCM_CB_UNTYPED    = 0,    /* no type set on CB break */
0064     AFSCM_CB_EXCLUSIVE  = 1,    /* CB exclusive to CM [not implemented] */
0065     AFSCM_CB_SHARED     = 2,    /* CB shared by other CM's */
0066     AFSCM_CB_DROPPED    = 3,    /* CB promise cancelled by file server */
0067 } afs_callback_type_t;
0068 
0069 struct afs_callback {
0070     time64_t        expires_at; /* Time at which expires */
0071     //unsigned      version;    /* Callback version */
0072     //afs_callback_type_t   type;       /* Type of callback */
0073 };
0074 
0075 struct afs_callback_break {
0076     struct afs_fid      fid;        /* File identifier */
0077     //struct afs_callback   cb;     /* Callback details */
0078 };
0079 
0080 #define AFSCBMAX 50 /* maximum callbacks transferred per bulk op */
0081 
0082 struct afs_uuid {
0083     __be32      time_low;           /* low part of timestamp */
0084     __be16      time_mid;           /* mid part of timestamp */
0085     __be16      time_hi_and_version;        /* high part of timestamp and version  */
0086     __s8        clock_seq_hi_and_reserved;  /* clock seq hi and variant */
0087     __s8        clock_seq_low;          /* clock seq low */
0088     __s8        node[6];            /* spatially unique node ID (MAC addr) */
0089 };
0090 
0091 /*
0092  * AFS volume information
0093  */
0094 struct afs_volume_info {
0095     afs_volid_t     vid;        /* volume ID */
0096     afs_voltype_t       type;       /* type of this volume */
0097     afs_volid_t     type_vids[5];   /* volume ID's for possible types for this vol */
0098 
0099     /* list of fileservers serving this volume */
0100     size_t          nservers;   /* number of entries used in servers[] */
0101     struct {
0102         struct in_addr  addr;       /* fileserver address */
0103     } servers[8];
0104 };
0105 
0106 /*
0107  * AFS security ACE access mask
0108  */
0109 typedef u32 afs_access_t;
0110 #define AFS_ACE_READ        0x00000001U /* - permission to read a file/dir */
0111 #define AFS_ACE_WRITE       0x00000002U /* - permission to write/chmod a file */
0112 #define AFS_ACE_INSERT      0x00000004U /* - permission to create dirent in a dir */
0113 #define AFS_ACE_LOOKUP      0x00000008U /* - permission to lookup a file/dir in a dir */
0114 #define AFS_ACE_DELETE      0x00000010U /* - permission to delete a dirent from a dir */
0115 #define AFS_ACE_LOCK        0x00000020U /* - permission to lock a file */
0116 #define AFS_ACE_ADMINISTER  0x00000040U /* - permission to change ACL */
0117 #define AFS_ACE_USER_A      0x01000000U /* - 'A' user-defined permission */
0118 #define AFS_ACE_USER_B      0x02000000U /* - 'B' user-defined permission */
0119 #define AFS_ACE_USER_C      0x04000000U /* - 'C' user-defined permission */
0120 #define AFS_ACE_USER_D      0x08000000U /* - 'D' user-defined permission */
0121 #define AFS_ACE_USER_E      0x10000000U /* - 'E' user-defined permission */
0122 #define AFS_ACE_USER_F      0x20000000U /* - 'F' user-defined permission */
0123 #define AFS_ACE_USER_G      0x40000000U /* - 'G' user-defined permission */
0124 #define AFS_ACE_USER_H      0x80000000U /* - 'H' user-defined permission */
0125 
0126 /*
0127  * AFS file status information
0128  */
0129 struct afs_file_status {
0130     u64         size;       /* file size */
0131     afs_dataversion_t   data_version;   /* current data version */
0132     struct timespec64   mtime_client;   /* Last time client changed data */
0133     struct timespec64   mtime_server;   /* Last time server changed data */
0134     s64         author;     /* author ID */
0135     s64         owner;      /* owner ID */
0136     s64         group;      /* group ID */
0137     afs_access_t        caller_access;  /* access rights for authenticated caller */
0138     afs_access_t        anon_access;    /* access rights for unauthenticated caller */
0139     umode_t         mode;       /* UNIX mode */
0140     afs_file_type_t     type;       /* file type */
0141     u32         nlink;      /* link count */
0142     s32         lock_count; /* file lock count (0=UNLK -1=WRLCK +ve=#RDLCK */
0143     u32         abort_code; /* Abort if bulk-fetching this failed */
0144 };
0145 
0146 struct afs_status_cb {
0147     struct afs_file_status  status;
0148     struct afs_callback callback;
0149     bool            have_status;    /* True if status record was retrieved */
0150     bool            have_cb;    /* True if cb record was retrieved */
0151     bool            have_error; /* True if status.abort_code indicates an error */
0152 };
0153 
0154 /*
0155  * AFS file status change request
0156  */
0157 
0158 #define AFS_SET_MTIME       0x01        /* set the mtime */
0159 #define AFS_SET_OWNER       0x02        /* set the owner ID */
0160 #define AFS_SET_GROUP       0x04        /* set the group ID (unsupported?) */
0161 #define AFS_SET_MODE        0x08        /* set the UNIX mode */
0162 #define AFS_SET_SEG_SIZE    0x10        /* set the segment size (unsupported) */
0163 
0164 /*
0165  * AFS volume synchronisation information
0166  */
0167 struct afs_volsync {
0168     time64_t        creation;   /* volume creation time */
0169 };
0170 
0171 /*
0172  * AFS volume status record
0173  */
0174 struct afs_volume_status {
0175     afs_volid_t     vid;        /* volume ID */
0176     afs_volid_t     parent_id;  /* parent volume ID */
0177     u8          online;     /* true if volume currently online and available */
0178     u8          in_service; /* true if volume currently in service */
0179     u8          blessed;    /* same as in_service */
0180     u8          needs_salvage;  /* true if consistency checking required */
0181     u32         type;       /* volume type (afs_voltype_t) */
0182     u64         min_quota;  /* minimum space set aside (blocks) */
0183     u64         max_quota;  /* maximum space this volume may occupy (blocks) */
0184     u64         blocks_in_use;  /* space this volume currently occupies (blocks) */
0185     u64         part_blocks_avail; /* space available in volume's partition */
0186     u64         part_max_blocks; /* size of volume's partition */
0187     s64         vol_copy_date;
0188     s64         vol_backup_date;
0189 };
0190 
0191 #define AFS_BLOCK_SIZE  1024
0192 
0193 /*
0194  * XDR encoding of UUID in AFS.
0195  */
0196 struct afs_uuid__xdr {
0197     __be32      time_low;
0198     __be32      time_mid;
0199     __be32      time_hi_and_version;
0200     __be32      clock_seq_hi_and_reserved;
0201     __be32      clock_seq_low;
0202     __be32      node[6];
0203 };
0204 
0205 #endif /* AFS_H */