xref: /openbmc/linux/fs/afs/protocol_yfs.h (revision 74a22e8f)
1 /* YFS protocol bits
2  *
3  * Copyright (C) 2018 Red Hat, Inc. All Rights Reserved.
4  * 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 Licence
8  * as published by the Free Software Foundation; either version
9  * 2 of the Licence, or (at your option) any later version.
10  */
11 
12 #define YFS_FS_SERVICE	2500
13 #define YFS_CM_SERVICE	2501
14 
15 #define YFSCBMAX 1024
16 
17 enum YFS_CM_Operations {
18 	YFSCBProbe		= 206,	/* probe client */
19 	YFSCBGetLock		= 207,	/* get contents of CM lock table */
20 	YFSCBXStatsVersion	= 209,	/* get version of extended statistics */
21 	YFSCBGetXStats		= 210,	/* get contents of extended statistics data */
22 	YFSCBInitCallBackState3	= 213,	/* initialise callback state, version 3 */
23 	YFSCBProbeUuid		= 214,	/* check the client hasn't rebooted */
24 	YFSCBGetServerPrefs	= 215,
25 	YFSCBGetCellServDV	= 216,
26 	YFSCBGetLocalCell	= 217,
27 	YFSCBGetCacheConfig	= 218,
28 	YFSCBGetCellByNum	= 65537,
29 	YFSCBTellMeAboutYourself = 65538, /* get client capabilities */
30 	YFSCBCallBack		= 64204,
31 };
32 
33 enum YFS_FS_Operations {
34 	YFSFETCHACL		= 64131, /* YFS Fetch file AFS3 ACL */
35 	YFSFETCHSTATUS		= 64132, /* YFS Fetch file status */
36 	YFSSTOREACL		= 64134, /* YFS Store file AFS3 ACL */
37 	YFSSTORESTATUS		= 64135, /* YFS Store file status */
38 	YFSREMOVEFILE		= 64136, /* YFS Remove a file */
39 	YFSCREATEFILE		= 64137, /* YFS Create a file */
40 	YFSRENAME		= 64138, /* YFS Rename or move a file or directory */
41 	YFSSYMLINK		= 64139, /* YFS Create a symbolic link */
42 	YFSLINK			= 64140, /* YFS Create a hard link */
43 	YFSMAKEDIR		= 64141, /* YFS Create a directory */
44 	YFSREMOVEDIR		= 64142, /* YFS Remove a directory */
45 	YFSGETVOLUMESTATUS	= 64149, /* YFS Get volume status information */
46 	YFSSETVOLUMESTATUS	= 64150, /* YFS Set volume status information */
47 	YFSSETLOCK		= 64156, /* YFS Request a file lock */
48 	YFSEXTENDLOCK		= 64157, /* YFS Extend a file lock */
49 	YFSRELEASELOCK		= 64158, /* YFS Release a file lock */
50 	YFSLOOKUP		= 64161, /* YFS lookup file in directory */
51 	YFSFLUSHCPS		= 64165,
52 	YFSFETCHOPAQUEACL	= 64168, /* YFS Fetch file YFS ACL */
53 	YFSWHOAMI		= 64170,
54 	YFSREMOVEACL		= 64171,
55 	YFSREMOVEFILE2		= 64173,
56 	YFSSTOREOPAQUEACL2	= 64174,
57 	YFSINLINEBULKSTATUS	= 64536, /* YFS Fetch multiple file statuses with errors */
58 	YFSFETCHDATA64		= 64537, /* YFS Fetch file data */
59 	YFSSTOREDATA64		= 64538, /* YFS Store file data */
60 	YFSUPDATESYMLINK	= 64540,
61 };
62 
63 struct yfs_xdr_u64 {
64 	__be32			msw;
65 	__be32			lsw;
66 } __packed;
67 
68 static inline u64 xdr_to_u64(const struct yfs_xdr_u64 x)
69 {
70 	return ((u64)ntohl(x.msw) << 32) | ntohl(x.lsw);
71 }
72 
73 static inline struct yfs_xdr_u64 u64_to_xdr(const u64 x)
74 {
75 	return (struct yfs_xdr_u64){ .msw = htonl(x >> 32), .lsw = htonl(x) };
76 }
77 
78 struct yfs_xdr_vnode {
79 	struct yfs_xdr_u64	lo;
80 	__be32			hi;
81 	__be32			unique;
82 } __packed;
83 
84 struct yfs_xdr_YFSFid {
85 	struct yfs_xdr_u64	volume;
86 	struct yfs_xdr_vnode	vnode;
87 } __packed;
88 
89 
90 struct yfs_xdr_YFSFetchStatus {
91 	__be32			type;
92 	__be32			nlink;
93 	struct yfs_xdr_u64	size;
94 	struct yfs_xdr_u64	data_version;
95 	struct yfs_xdr_u64	author;
96 	struct yfs_xdr_u64	owner;
97 	struct yfs_xdr_u64	group;
98 	__be32			mode;
99 	__be32			caller_access;
100 	__be32			anon_access;
101 	struct yfs_xdr_vnode	parent;
102 	__be32			data_access_protocol;
103 	struct yfs_xdr_u64	mtime_client;
104 	struct yfs_xdr_u64	mtime_server;
105 	__be32			lock_count;
106 	__be32			abort_code;
107 } __packed;
108 
109 struct yfs_xdr_YFSCallBack {
110 	__be32			version;
111 	struct yfs_xdr_u64	expiration_time;
112 	__be32			type;
113 } __packed;
114 
115 struct yfs_xdr_YFSStoreStatus {
116 	__be32			mask;
117 	__be32			mode;
118 	struct yfs_xdr_u64	mtime_client;
119 	struct yfs_xdr_u64	owner;
120 	struct yfs_xdr_u64	group;
121 } __packed;
122 
123 struct yfs_xdr_RPCFlags {
124 	__be32			rpc_flags;
125 } __packed;
126 
127 struct yfs_xdr_YFSVolSync {
128 	struct yfs_xdr_u64	vol_creation_date;
129 	struct yfs_xdr_u64	vol_update_date;
130 	struct yfs_xdr_u64	max_quota;
131 	struct yfs_xdr_u64	blocks_in_use;
132 	struct yfs_xdr_u64	blocks_avail;
133 } __packed;
134 
135 enum yfs_volume_type {
136 	yfs_volume_type_ro = 0,
137 	yfs_volume_type_rw = 1,
138 };
139 
140 #define yfs_FVSOnline		0x1
141 #define yfs_FVSInservice	0x2
142 #define yfs_FVSBlessed		0x4
143 #define yfs_FVSNeedsSalvage	0x8
144 
145 struct yfs_xdr_YFSFetchVolumeStatus {
146 	struct yfs_xdr_u64	vid;
147 	struct yfs_xdr_u64	parent_id;
148 	__be32			flags;
149 	__be32			type;
150 	struct yfs_xdr_u64	max_quota;
151 	struct yfs_xdr_u64	blocks_in_use;
152 	struct yfs_xdr_u64	part_blocks_avail;
153 	struct yfs_xdr_u64	part_max_blocks;
154 	struct yfs_xdr_u64	vol_copy_date;
155 	struct yfs_xdr_u64	vol_backup_date;
156 } __packed;
157 
158 struct yfs_xdr_YFSStoreVolumeStatus {
159 	__be32			mask;
160 	struct yfs_xdr_u64	min_quota;
161 	struct yfs_xdr_u64	max_quota;
162 	struct yfs_xdr_u64	file_quota;
163 } __packed;
164 
165 enum yfs_lock_type {
166 	yfs_LockNone		= -1,
167 	yfs_LockRead		= 0,
168 	yfs_LockWrite		= 1,
169 	yfs_LockExtend		= 2,
170 	yfs_LockRelease		= 3,
171 	yfs_LockMandatoryRead	= 0x100,
172 	yfs_LockMandatoryWrite	= 0x101,
173 	yfs_LockMandatoryExtend	= 0x102,
174 };
175