blob: 2e2887a7d3317653781c9051eaf8dcf44690092f [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
Linus Torvalds1da177e2005-04-16 15:20:36 -070026typedef unsigned afs_volid_t;
27typedef unsigned afs_vnodeid_t;
28typedef unsigned long long afs_dataversion_t;
29
30typedef enum {
31 AFSVL_RWVOL, /* read/write volume */
32 AFSVL_ROVOL, /* read-only volume */
33 AFSVL_BACKVOL, /* backup volume */
34} __attribute__((packed)) afs_voltype_t;
35
36typedef enum {
37 AFS_FTYPE_INVALID = 0,
38 AFS_FTYPE_FILE = 1,
39 AFS_FTYPE_DIR = 2,
40 AFS_FTYPE_SYMLINK = 3,
41} afs_file_type_t;
42
David Howellse8d6c552007-07-15 23:40:12 -070043typedef enum {
44 AFS_LOCK_READ = 0, /* read lock request */
45 AFS_LOCK_WRITE = 1, /* write lock request */
46} afs_lock_type_t;
47
48#define AFS_LOCKWAIT (5 * 60) /* time until a lock times out (seconds) */
49
Linus Torvalds1da177e2005-04-16 15:20:36 -070050/*
51 * AFS file identifier
52 */
David Howellsec268152007-04-26 15:49:28 -070053struct afs_fid {
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 afs_volid_t vid; /* volume ID */
55 afs_vnodeid_t vnode; /* file index within volume */
56 unsigned unique; /* unique ID number (file index version) */
57};
58
Linus Torvalds1da177e2005-04-16 15:20:36 -070059/*
60 * AFS callback notification
61 */
62typedef enum {
63 AFSCM_CB_UNTYPED = 0, /* no type set on CB break */
64 AFSCM_CB_EXCLUSIVE = 1, /* CB exclusive to CM [not implemented] */
65 AFSCM_CB_SHARED = 2, /* CB shared by other CM's */
66 AFSCM_CB_DROPPED = 3, /* CB promise cancelled by file server */
67} afs_callback_type_t;
68
David Howellsec268152007-04-26 15:49:28 -070069struct afs_callback {
Linus Torvalds1da177e2005-04-16 15:20:36 -070070 struct afs_fid fid; /* file identifier */
71 unsigned version; /* callback version */
72 unsigned expiry; /* time at which expires */
73 afs_callback_type_t type; /* type of callback */
74};
75
David Howells08e0e7c2007-04-26 15:55:03 -070076#define AFSCBMAX 50 /* maximum callbacks transferred per bulk op */
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
David Howellsf044c882017-11-02 15:27:45 +000078struct afs_uuid {
79 __be32 time_low; /* low part of timestamp */
80 __be16 time_mid; /* mid part of timestamp */
81 __be16 time_hi_and_version; /* high part of timestamp and version */
David Howells03dc2cf2017-11-02 15:27:49 +000082 __s8 clock_seq_hi_and_reserved; /* clock seq hi and variant */
83 __s8 clock_seq_low; /* clock seq low */
84 __s8 node[6]; /* spatially unique node ID (MAC addr) */
David Howellsf044c882017-11-02 15:27:45 +000085};
86
Linus Torvalds1da177e2005-04-16 15:20:36 -070087/*
88 * AFS volume information
89 */
David Howellsec268152007-04-26 15:49:28 -070090struct afs_volume_info {
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 afs_volid_t vid; /* volume ID */
92 afs_voltype_t type; /* type of this volume */
93 afs_volid_t type_vids[5]; /* volume ID's for possible types for this vol */
David Howells08e0e7c2007-04-26 15:55:03 -070094
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 /* list of fileservers serving this volume */
96 size_t nservers; /* number of entries used in servers[] */
97 struct {
98 struct in_addr addr; /* fileserver address */
99 } servers[8];
100};
101
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102/*
David Howells00d3b7a2007-04-26 15:57:07 -0700103 * AFS security ACE access mask
104 */
105typedef u32 afs_access_t;
106#define AFS_ACE_READ 0x00000001U /* - permission to read a file/dir */
107#define AFS_ACE_WRITE 0x00000002U /* - permission to write/chmod a file */
108#define AFS_ACE_INSERT 0x00000004U /* - permission to create dirent in a dir */
109#define AFS_ACE_LOOKUP 0x00000008U /* - permission to lookup a file/dir in a dir */
110#define AFS_ACE_DELETE 0x00000010U /* - permission to delete a dirent from a dir */
111#define AFS_ACE_LOCK 0x00000020U /* - permission to lock a file */
112#define AFS_ACE_ADMINISTER 0x00000040U /* - permission to change ACL */
113#define AFS_ACE_USER_A 0x01000000U /* - 'A' user-defined permission */
114#define AFS_ACE_USER_B 0x02000000U /* - 'B' user-defined permission */
115#define AFS_ACE_USER_C 0x04000000U /* - 'C' user-defined permission */
116#define AFS_ACE_USER_D 0x08000000U /* - 'D' user-defined permission */
117#define AFS_ACE_USER_E 0x10000000U /* - 'E' user-defined permission */
118#define AFS_ACE_USER_F 0x20000000U /* - 'F' user-defined permission */
119#define AFS_ACE_USER_G 0x40000000U /* - 'G' user-defined permission */
120#define AFS_ACE_USER_H 0x80000000U /* - 'H' user-defined permission */
121
122/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 * AFS file status information
124 */
David Howellsec268152007-04-26 15:49:28 -0700125struct afs_file_status {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 unsigned if_version; /* interface version */
127#define AFS_FSTATUS_VERSION 1
128
129 afs_file_type_t type; /* file type */
130 unsigned nlink; /* link count */
David Howells260a9802007-04-26 15:59:35 -0700131 u64 size; /* file size */
David Howells08e0e7c2007-04-26 15:55:03 -0700132 afs_dataversion_t data_version; /* current data version */
David Howells260a9802007-04-26 15:59:35 -0700133 u32 author; /* author ID */
Eric W. Biedermana0a53862012-02-07 16:20:48 -0800134 kuid_t owner; /* owner ID */
135 kgid_t group; /* group ID */
David Howells00d3b7a2007-04-26 15:57:07 -0700136 afs_access_t caller_access; /* access rights for authenticated caller */
137 afs_access_t anon_access; /* access rights for unauthenticated caller */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 umode_t mode; /* UNIX mode */
David Howells260a9802007-04-26 15:59:35 -0700139 struct afs_fid parent; /* parent dir ID for non-dirs only */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 time_t mtime_client; /* last time client changed data */
141 time_t mtime_server; /* last time server changed data */
David Howellse8d6c552007-07-15 23:40:12 -0700142 s32 lock_count; /* file lock count (0=UNLK -1=WRLCK +ve=#RDLCK */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143};
144
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145/*
David Howells260a9802007-04-26 15:59:35 -0700146 * AFS file status change request
147 */
David Howells260a9802007-04-26 15:59:35 -0700148
149#define AFS_SET_MTIME 0x01 /* set the mtime */
150#define AFS_SET_OWNER 0x02 /* set the owner ID */
151#define AFS_SET_GROUP 0x04 /* set the group ID (unsupported?) */
152#define AFS_SET_MODE 0x08 /* set the UNIX mode */
153#define AFS_SET_SEG_SIZE 0x10 /* set the segment size (unsupported) */
154
155/*
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 * AFS volume synchronisation information
157 */
David Howellsec268152007-04-26 15:49:28 -0700158struct afs_volsync {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 time_t creation; /* volume creation time */
160};
161
David Howells45222b92007-05-10 22:22:20 -0700162/*
163 * AFS volume status record
164 */
165struct afs_volume_status {
166 u32 vid; /* volume ID */
167 u32 parent_id; /* parent volume ID */
168 u8 online; /* true if volume currently online and available */
169 u8 in_service; /* true if volume currently in service */
170 u8 blessed; /* same as in_service */
171 u8 needs_salvage; /* true if consistency checking required */
172 u32 type; /* volume type (afs_voltype_t) */
173 u32 min_quota; /* minimum space set aside (blocks) */
174 u32 max_quota; /* maximum space this volume may occupy (blocks) */
175 u32 blocks_in_use; /* space this volume currently occupies (blocks) */
176 u32 part_blocks_avail; /* space available in volume's partition */
177 u32 part_max_blocks; /* size of volume's partition */
178};
179
180#define AFS_BLOCK_SIZE 1024
181
David Howells91a90382017-11-02 15:27:46 +0000182/*
183 * XDR encoding of UUID in AFS.
184 */
185struct afs_uuid__xdr {
186 __be32 time_low;
187 __be32 time_mid;
188 __be32 time_hi_and_version;
189 __be32 clock_seq_hi_and_reserved;
190 __be32 clock_seq_low;
191 __be32 node[6];
192};
193
David Howells08e0e7c2007-04-26 15:55:03 -0700194#endif /* AFS_H */