2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS)
13 * In which the structures needed to facilitate interception of file system
14 * related system calls by a user process ("agent", or "venus").
17 #define RT_VERSION 3 /* Version number, should be incremented
18 before incompatible changes are released */
20 * Version 1 - April 4/84.
21 * Version 2 - May 4/84.
22 * Version 3 - May 30/85.
23 * Version 4 - June 19/85.
26 /* Maximum number of arguments to a system call */
27 #define RT_MAX_ARGS ( (sizeof u.u_arg) / (sizeof (int)) )
32 /* Maximum size of combined string or structure arguments passed between
33 the kernel and a venus */
34 #define RT_MAXDATASIZE (MAXPATHLEN*2)
36 /* The format of the message passed between Venus and the kernel */
37 struct intercept_message {
38 u_short im_type; /* Message type */
39 u_short im_dsize; /* Number of bytes in im_data */
40 int im_client; /* The process id of the client side of the
42 short im_uid; /* The effective user id of the client */
43 short im_gid; /* The effective group id of the client */
44 int im_seq; /* The sequence number of this transaction.
46 afs_int32 im_wdfid[3]; /* Current directory on the remote file system
48 int im_error; /* u.u_error copied from this */
49 char im_follow1; /* 1=>follow last component of first pathname
50 if symbolic link; 0=>don't */
51 char im_follow2; /* ditto for second pathname */
52 afs_int32 im_pag; /* process authentication group */
53 /* im_arg contains a representation of the arguments to the intercepted
54 system call, when transmitted from the kernel to Venus.
55 Returned values are passed back from Venus to the kernel the same way */
57 int im_aval; /* Value of the argument
58 OR index of argument in im_data */
59 int im_asize; /* If im_aval is the index of an argument in
60 im_data, then this is its size in bytes.
61 Otherwise this is 0. */
62 } im_arg[RT_MAX_ARGS];
63 char im_data[RT_MAXDATASIZE];
64 /* Variable length field containing string
65 or structure arguments */
66 /* No fields should be added here, the record may be truncated on
67 transmission in either direction to an appropriate size */
72 #define RT_HEADERSIZE ((sizeof (struct intercept_message)) - RT_MAXDATASIZE)
75 /* The following shouldn't be done in this manner, but there doesn't
76 seem to be an easy mechanism to discover the device id. The auto-
77 config stuff is only for real devices, I think.
86 /* Sleep priorities */
87 #define RMT_NOINT_PRI (PINOD+1)/* Sleep with signal handling enabled */
88 #define RMT_INTOK_PRI (PSLEP-1)/* Disallow aborts due to signal handling */
90 /* Private data used by the remote intercept routines in the kernel */
91 /* Note: this was originally designed for only a single remote device.
92 To make it work for multiple devices, I simply unfolded the code
93 by turning this into an array (1 entry per device) and using a macro
94 in the code to reference the appropriate entry. */
96 int rt_flags; /* for flag values, see below */
97 int rt_seq; /* sequence number generator */
98 char rt_open; /* 1 if the device is open */ /* XXX UNALIGNED */
99 struct proc *rt_selproc; /* process waiting for select */
100 char rt_attach; /* wait channel for process waiting to attach
102 char rt_read; /* wait channel for a venus waiting for an
104 char rt_reply; /* wait channel for a client process waiting
106 struct intercept_message rt_imr; /* buffer for agent reads */
107 struct intercept_message rt_imw; /* buffer for agent writes */
112 /* Hack to unfold code for multiple devices */
114 #define devhack(dev) register struct remote *rmtp = &remote[minor(dev)]
116 /* Flags for rmt.rt_flags */
117 #define RT_RBUF 1 /* processing venus read request */
118 #define RT_WBUF 2 /* processing venus write request */
119 #define RT_SENDING 4 /* sending the structure to the venus */
120 #define RT_REPLY 8 /* reply from venus to client */
121 #define RT_SIGNAL 16 /* signal occured, want to send message to
122 venus at next opportunity */
124 /* This bogus stuff is used for rename/link */
126 int func; /* This used to be a function in BSD 4.2... */
131 enum {havePath, isLocal, haveDev, isRemote} state;
134 extern struct inode *RemoteNamei();
135 extern int RemoteMaybe();
139 * Message type codes for messages sent from the kernel.
140 * NB: the kernel ignores the type field on reply (it merely matches
141 * sequence numbers). Unexpected messages from an venus are ignored (they
142 * may have been destined for a process which has died in the meantime).
143 * At all times, the kernel tries to maintain its own integrity, so that
144 * in the worst case an venus restart should work fine.
148 * In the capsule descriptions below, "(?)" means that the flagged item
149 * is probably a good candidate for negotiation.
153 /* For debugging purposes in kernel */
156 /* From kernel: 0: uninterpreted part of pathname
158 * NB: uid/gid for this call are the real (not effective) uid/gid's.
160 * if im_error == EABSPATH1 then:
161 * 0: Resolved absolute path name.
162 * NB: return value is implicit in im_error.
166 /* From kernel: 0: uninterpreted part of pathname
168 * 0: new pathname (with ..'s removed, symbolic
169 * links NOT expanded).
170 * length<MAXPATHLEN. Null terminated.
173 * im_wdfid: the file identifier (volume, vnode, unique)
174 * of the new working directory.
176 * if im_error == EABSPATH1 then:
177 * 0: Resolved absolute path name.
181 /* From kernel: 0: uninterpreted part of pathname
184 * if im_error == EABSPATH1 then:
185 * 0: Resolved absolute path name.
189 /* From kernel: 0: uninterpreted part of pathname
193 * if im_error == EABSPATH1 then:
194 * 0: Resolved absolute path name.
198 /* From kernel: 0: file identifier.
199 * im_error: either 0 or one of the error codes
200 * listed below (RTE_*, see RT_open).
201 * Response: im_error (for programs that want to know)
202 * N.B.: close MUST always cleanup state; it will never be issued
203 * twice for the same identifier. If RT_signal is received during
204 * a close, venus can use this as a hint to return early from the
205 * close. Venus should not return EINTR for this system call, however.
209 /* From kernel: 0: file identifier
215 /* From kernel: 0: file identifier
222 /* Not implemented */
225 /* From kernel: 0: file identifier
231 /* From kernel: 0: file identifier.
232 * Response: 0: struct stat
237 /* From kernel: 0: file identifier.
241 #define RT_ftruncate 12
242 /* From kernel: 0: file identifier.
243 * 1: truncated length. (? right now, kernel truncates
249 /* From kernel: 0: the uninterpreted part of the original path
250 * 1: the uninterpreted part of the pathname which
251 * will be the new link
253 * if im_error == EABSPATH1 or EABSPATH2 then:
254 * 0: Resolved absolute path name.
258 /* Obsolete--not generated by the kernel. The im_follow1
259 field is used in conjunction with RT_stat to implement
260 lstat. VICE I will continue to work since it does not
261 distinguish between stat and lstat */
264 /* From kernel: 0: uninterpreted part of pathname
267 * if im_error == EABSPATH1 then:
268 * 0: Resolved absolute path name.
272 /* From kernel: 0: uninterpreted part of pathname
276 * 0: file identifier assigned (for subsequent
277 * messages dealing with open files).
278 * 1: pathname of the local, cached file.
280 * Note: the returned filename is not created, truncated(?),
281 * or otherwise fiddled with by the kernel. It must
282 * exist and must be a plain file. N.B: Protection modes
283 * are ignored when it is finally opened. The exec bit,
284 * however, should never be set unless the file is
285 * really executable. (It should never be set for
286 * directories). If there are problems opening the
287 * file, the user gets an error, the kernel gets a close
288 * message (possibly with one of the RTE_* errors, below,
291 * 0: file identifier assigned (for subsequent
292 * messages dealing with open files).
293 * 1: device where the file resides.
294 * 2: inode number of the file.
296 * if im_error == EABSPATH1 then:
297 * 0: Resolved absolute path name.
298 * (?) Non-blocking open.
301 #define RT_readlink 17
302 /* From kernel: 0: uninterpreted part of link pathname
303 * Response: 0: number of characters read from link
304 * 1: contents of link (not null terminated). Size must not be
305 * greater than MAXPATHLEN (because this is checked by the
306 * kernel intercept code).
308 * if im_error == EABSPATH1 then:
309 * 0: Resolved absolute path name.
313 /* From kernel: 0: uninterpreted part of original pathname
314 * 1: ditto for new pathname
316 * if im_error == EABSPATH1 or EABSPATH2 then:
317 * 0: Resolved absolute path name.
321 /* From kernel: 0: uninterpreted part of pathname
323 * if im_error == EABSPATH1 then:
324 * 0: Resolved absolute path name.
328 /* From kernel: 0: uninterpreted part of pathname
329 * Response: 0: struct stat
331 * if im_error == EABSPATH1 then:
332 * 0: Resolved absolute path name.
333 * Note: this now implements the lstat call, as well,
334 * by means of the im_follow1 field in the header.
337 #define RT_symlink 21
338 /* From kernel: 0: the string value of the new symbolic link.
339 * 1: the uninterpreted part of the pathname to
342 * if im_error == EABSPATH1 then:
343 * 0: Resolved absolute path name.
346 #define RT_truncate 22
347 /* From kernel: 0: uninterpreted part of pathname
348 * 1: truncated length
350 * if im_error == EABSPATH1 then:
351 * 0: Resolved absolute path name.
355 /* From kernel: 0: uninterpreted part of pathname
357 * if im_error == EABSPATH1 then:
358 * 0: Resolved absolute path name.
362 /* From kernel: 0: uninterpreted part of pathname
363 * 1: struct timeval tvp[2]
365 * if im_error == EABSPATH1 then:
366 * 0: Resolved absolute path name.
370 /* Request to abort the previous operation requested WITH THE
371 * SAME im_seq FIELD. No action is expected on the part of
372 * the venus--this is merely advice that the operation may
373 * be completed early. VENUS SHOULD NOT REPLY TO THIS MESSAGE.
374 * The error returned on final completion by the venus need not
375 * acknowledge that the system call was interrupted. The interrupt
376 * will occur at the end of the system call regardless. EINTR
377 * should be returned if the system call actually is aborted.
378 * VENUS MAY RETURN EARLY FROM A C L O S E SYSTEM CALL, BUT MUST STILL
379 * CLEANUP STATE FOR THE CLOSE--ANOTHER CLOSE CALL FOR THE SAME
380 * DESCRIPTOR WILL NEVER BE ISSUED.
381 * RT_signal messages for which a reply has already been issued
382 * sholuld be ignored by venus.
387 * From kernel: 0: file identifier
388 * 1: command (see below)
389 * 2: uninterpreted data (up to RT_MAXDATASIZE).
390 * Response: 0: data to be returned to user
392 * NOTE: the information passed to/from venus is not in the
393 * same format as that coming to/from the user. See the file
400 * From kernel: 0: uninterpreted part of pathname
401 * 1: command (as in RT_ioctl)
402 * 2: uninterpreted data
403 * Note: argument 3, do not follow symbolic links, is
404 * obsolete; this is compatible with VICE I, since the
405 * field was ignored anyway.
406 * Response: 0: data to be returned to user
408 * if im_error == EABSPATH1 then:
409 * 0: Resolved absolute path name.
413 /* Error codes -- each is set by the kernel for the explicit error indicated.
414 * These are set in im_error (which should normally be 0 in every message from
415 * the kernel). Errors of this form indicate that the venus process has
416 * almost certainly done something wrong. The associated user process gets an
417 * ERFS (remote file system error) for each of these error types.
420 /* The following error codes all occur at open (exec?) and are sent by the
421 * kernel with the associated close message for the file identifier returned
425 #define RTE_BADARG 1 /* The size of a structure or string argument returned
426 by the venus to the kernel is bogus.
427 (the im_size field is not zero, or part of the
428 argument is outside the message buffer, or the
429 argument is too large) */
431 #define RTE_NOFILE 2 /* The file name (or inode, in VICE II) returned to
432 the kernel, to open or exec in lieu of the original
433 name supplied by the process cannot be opened or
436 #define RTE_NOTREG 3 /* The file (or inode, in VICE II) returned to the
437 kernel, to open or exec in lieu of the original
438 name supplied by the process, is not a IF_REG
439 type file, i.e. it is a device, socket, or
443 /* The following error codes are set by Venus when a pathname argument supplied
444 * by the kernel resolves to an absolute pathname outside of the name space
445 * of this venus. The resolved absolute pathname is returned in argument 0.
446 * The kernel is expected to retry the system call with this new information.
447 * The kernel never passes this error on to the original issuer of the system
450 #define EABSPATH1 126 /* The first pathname, or only pathname, of a system
451 call resolved to an absolute pathname */
452 #define EABSPATH2 127 /* The second pathname of the rename or link system
453 call resolved to an absolute pathname */