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