blob: 3f4e460c6655ab3e259d7e17e6b6bbe8dfdb0036 [file] [log] [blame]
David Howells08e0e7c2007-04-26 15:55:03 -07001/* AFS common types
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 *
David Howells08e0e7c2007-04-26 15:55:03 -07003 * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 * Written by David Howells (dhowells@redhat.com)
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
David Howells08e0e7c2007-04-26 15:55:03 -070012#ifndef AFS_H
13#define AFS_H
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
David Howells08e0e7c2007-04-26 15:55:03 -070015#include <linux/in.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
David Howells91a90382017-11-02 15:27:46 +000017#define AFS_MAXCELLNAME 64 /* Maximum length of a cell name */
18#define AFS_MAXVOLNAME 64 /* Maximum length of a volume name */
19#define AFS_MAXNSERVERS 8 /* Maximum servers in a basic volume record */
20#define AFS_NMAXNSERVERS 13 /* Maximum servers in a N/U-class volume record */
21#define AFS_MAXTYPES 3 /* Maximum number of volume types */
22#define AFSNAMEMAX 256 /* Maximum length of a filename plus NUL */
23#define AFSPATHMAX 1024 /* Maximum length of a pathname plus NUL */
24#define AFSOPAQUEMAX 1024 /* Maximum length of an opaque field */
David Howells00d3b7a2007-04-26 15:57:07 -070025
David Howells94f699c2019-05-16 13:21:59 +010026#define AFS_VL_MAX_LIFESPAN (120 * HZ)
27#define AFS_PROBE_MAX_LIFESPAN (30 * HZ)
28
David Howells3b6492d2018-10-20 00:57:57 +010029typedef u64 afs_volid_t;
30typedef u64 afs_vnodeid_t;
31typedef u64 afs_dataversion_t;
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33typedef enum {
34 AFSVL_RWVOL, /* read/write volume */
35 AFSVL_ROVOL, /* read-only volume */
36 AFSVL_BACKVOL, /* backup volume */
37} __attribute__((packed)) afs_voltype_t;
38
39typedef enum {
40 AFS_FTYPE_INVALID = 0,
41 AFS_FTYPE_FILE = 1,
42 AFS_FTYPE_DIR = 2,
43 AFS_FTYPE_SYMLINK = 3,
44} afs_file_type_t;
45
David Howellse8d6c552007-07-15 23:40:12 -070046typedef enum {
47 AFS_LOCK_READ = 0, /* read lock request */
48 AFS_LOCK_WRITE = 1, /* write lock request */
49} afs_lock_type_t;
50
51#define AFS_LOCKWAIT (5 * 60) /* time until a lock times out (seconds) */
52
Linus Torvalds1da177e2005-04-16 15:20:36 -070053/*
54 * AFS file identifier
55 */
David Howellsec268152007-04-26 15:49:28 -070056struct afs_fid {
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 afs_volid_t vid; /* volume ID */
David Howells3b6492d2018-10-20 00:57:57 +010058 afs_vnodeid_t vnode; /* Lower 64-bits of file index within volume */
59 u32 vnode_hi; /* Upper 32-bits of file index */
60 u32 unique; /* unique ID number (file index version) */
Linus Torvalds1da177e2005-04-16 15:20:36 -070061};
62
Linus Torvalds1da177e2005-04-16 15:20:36 -070063/*
64 * AFS callback notification
65 */
66typedef enum {
67 AFSCM_CB_UNTYPED = 0, /* no type set on CB break */
68 AFSCM_CB_EXCLUSIVE = 1, /* CB exclusive to CM [not implemented] */
69 AFSCM_CB_SHARED = 2, /* CB shared by other CM's */
70 AFSCM_CB_DROPPED = 3, /* CB promise cancelled by file server */
71} afs_callback_type_t;
72
David Howellsec268152007-04-26 15:49:28 -070073struct afs_callback {
David Howells12d8e952018-10-20 00:57:58 +010074 time64_t expires_at; /* Time at which expires */
David Howells7c712452019-05-14 15:35:44 +010075 //unsigned version; /* Callback version */
76 //afs_callback_type_t type; /* Type of callback */
David Howells5cf9dd52018-04-09 21:12:31 +010077};
78
79struct afs_callback_break {
80 struct afs_fid fid; /* File identifier */
David Howells06aeb292018-10-20 00:57:58 +010081 //struct afs_callback cb; /* Callback details */
Linus Torvalds1da177e2005-04-16 15:20:36 -070082};
83
David Howells08e0e7c2007-04-26 15:55:03 -070084#define AFSCBMAX 50 /* maximum callbacks transferred per bulk op */
Linus Torvalds1da177e2005-04-16 15:20:36 -070085
David Howellsf044c882017-11-02 15:27:45 +000086struct afs_uuid {
87 __be32 time_low; /* low part of timestamp */
88 __be16 time_mid; /* mid part of timestamp */
89 __be16 time_hi_and_version; /* high part of timestamp and version */
David Howells03dc2cf2017-11-02 15:27:49 +000090 __s8 clock_seq_hi_and_reserved; /* clock seq hi and variant */
91 __s8 clock_seq_low; /* clock seq low */
92 __s8 node[6]; /* spatially unique node ID (MAC addr) */
David Howellsf044c882017-11-02 15:27:45 +000093};
94
Linus Torvalds1da177e2005-04-16 15:20:36 -070095/*
96 * AFS volume information
97 */
David Howellsec268152007-04-26 15:49:28 -070098struct afs_volume_info {
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 afs_volid_t vid; /* volume ID */
100 afs_voltype_t type; /* type of this volume */
101 afs_volid_t type_vids[5]; /* volume ID's for possible types for this vol */
David Howells08e0e7c2007-04-26 15:55:03 -0700102
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 /* list of fileservers serving this volume */
104 size_t nservers; /* number of entries used in servers[] */
105 struct {
106 struct in_addr addr; /* fileserver address */
107 } servers[8];
108};
109
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110/*
David Howells00d3b7a2007-04-26 15:57:07 -0700111 * AFS security ACE access mask
112 */
113typedef u32 afs_access_t;
114#define AFS_ACE_READ 0x00000001U /* - permission to read a file/dir */
115#define AFS_ACE_WRITE 0x00000002U /* - permission to write/chmod a file */
116#define AFS_ACE_INSERT 0x00000004U /* - permission to create dirent in a dir */
117#define AFS_ACE_LOOKUP 0x00000008U /* - permission to lookup a file/dir in a dir */
118#define AFS_ACE_DELETE 0x00000010U /* - permission to delete a dirent from a dir */
119#define AFS_ACE_LOCK 0x00000020U /* - permission to lock a file */
120#define AFS_ACE_ADMINISTER 0x00000040U /* - permission to change ACL */
121#define AFS_ACE_USER_A 0x01000000U /* - 'A' user-defined permission */
122#define AFS_ACE_USER_B 0x02000000U /* - 'B' user-defined permission */
123#define AFS_ACE_USER_C 0x04000000U /* - 'C' user-defined permission */
124#define AFS_ACE_USER_D 0x08000000U /* - 'D' user-defined permission */
125#define AFS_ACE_USER_E 0x10000000U /* - 'E' user-defined permission */
126#define AFS_ACE_USER_F 0x20000000U /* - 'F' user-defined permission */
127#define AFS_ACE_USER_G 0x40000000U /* - 'G' user-defined permission */
128#define AFS_ACE_USER_H 0x80000000U /* - 'H' user-defined permission */
129
130/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 * AFS file status information
132 */
David Howellsec268152007-04-26 15:49:28 -0700133struct afs_file_status {
David Howells5cf9dd52018-04-09 21:12:31 +0100134 u64 size; /* file size */
135 afs_dataversion_t data_version; /* current data version */
David Howellsd4936802018-10-20 00:57:58 +0100136 struct timespec64 mtime_client; /* Last time client changed data */
137 struct timespec64 mtime_server; /* Last time server changed data */
138 s64 author; /* author ID */
139 s64 owner; /* owner ID */
140 s64 group; /* group ID */
David Howells00d3b7a2007-04-26 15:57:07 -0700141 afs_access_t caller_access; /* access rights for authenticated caller */
142 afs_access_t anon_access; /* access rights for unauthenticated caller */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 umode_t mode; /* UNIX mode */
David Howellsd4936802018-10-20 00:57:58 +0100144 afs_file_type_t type; /* file type */
145 u32 nlink; /* link count */
David Howellse8d6c552007-07-15 23:40:12 -0700146 s32 lock_count; /* file lock count (0=UNLK -1=WRLCK +ve=#RDLCK */
David Howellsd4936802018-10-20 00:57:58 +0100147 u32 abort_code; /* Abort if bulk-fetching this failed */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148};
149
David Howells87182752019-05-09 16:17:05 +0100150struct afs_status_cb {
151 struct afs_file_status status;
152 struct afs_callback callback;
David Howells39db9812019-05-14 12:33:10 +0100153 unsigned int cb_break; /* Pre-op callback break counter */
David Howellsa38a7552019-05-14 12:29:11 +0100154 bool have_status; /* True if status record was retrieved */
David Howells87182752019-05-09 16:17:05 +0100155 bool have_cb; /* True if cb record was retrieved */
David Howellsa38a7552019-05-14 12:29:11 +0100156 bool have_error; /* True if status.abort_code indicates an error */
David Howells87182752019-05-09 16:17:05 +0100157};
158
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159/*
David Howells260a9802007-04-26 15:59:35 -0700160 * AFS file status change request
161 */
David Howells260a9802007-04-26 15:59:35 -0700162
163#define AFS_SET_MTIME 0x01 /* set the mtime */
164#define AFS_SET_OWNER 0x02 /* set the owner ID */
165#define AFS_SET_GROUP 0x04 /* set the group ID (unsupported?) */
166#define AFS_SET_MODE 0x08 /* set the UNIX mode */
167#define AFS_SET_SEG_SIZE 0x10 /* set the segment size (unsupported) */
168
169/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 * AFS volume synchronisation information
171 */
David Howellsec268152007-04-26 15:49:28 -0700172struct afs_volsync {
David Howellsd4936802018-10-20 00:57:58 +0100173 time64_t creation; /* volume creation time */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174};
175
David Howells45222b92007-05-10 22:22:20 -0700176/*
177 * AFS volume status record
178 */
179struct afs_volume_status {
David Howellsd4936802018-10-20 00:57:58 +0100180 afs_volid_t vid; /* volume ID */
181 afs_volid_t parent_id; /* parent volume ID */
David Howells45222b92007-05-10 22:22:20 -0700182 u8 online; /* true if volume currently online and available */
183 u8 in_service; /* true if volume currently in service */
184 u8 blessed; /* same as in_service */
185 u8 needs_salvage; /* true if consistency checking required */
186 u32 type; /* volume type (afs_voltype_t) */
David Howellsd4936802018-10-20 00:57:58 +0100187 u64 min_quota; /* minimum space set aside (blocks) */
188 u64 max_quota; /* maximum space this volume may occupy (blocks) */
189 u64 blocks_in_use; /* space this volume currently occupies (blocks) */
190 u64 part_blocks_avail; /* space available in volume's partition */
191 u64 part_max_blocks; /* size of volume's partition */
192 s64 vol_copy_date;
193 s64 vol_backup_date;
David Howells45222b92007-05-10 22:22:20 -0700194};
195
196#define AFS_BLOCK_SIZE 1024
197
David Howells91a90382017-11-02 15:27:46 +0000198/*
199 * XDR encoding of UUID in AFS.
200 */
201struct afs_uuid__xdr {
202 __be32 time_low;
203 __be32 time_mid;
204 __be32 time_hi_and_version;
205 __be32 clock_seq_hi_and_reserved;
206 __be32 clock_seq_low;
207 __be32 node[6];
208};
209
David Howells08e0e7c2007-04-26 15:55:03 -0700210#endif /* AFS_H */