/* * Copyright 2000, International Business Machines Corporation and others. * All Rights Reserved. * * This software has been released under the terms of the IBM Public * License. For details, see the LICENSE file in the top-level source * directory or online at http://www.openafs.org/dl/license10.html */ #if !defined(lint) && !defined(LOCORE) && defined(RCS_HDRS) #endif /* * In which the structures needed to facilitate interception of file system * related system calls by a user process ("agent", or "venus"). */ #define RT_VERSION 3 /* Version number, should be incremented before incompatible changes are released */ /* * Version 1 - April 4/84. * Version 2 - May 4/84. * Version 3 - May 30/85. * Version 4 - June 19/85. */ /* Maximum number of arguments to a system call */ #define RT_MAX_ARGS ( (sizeof u.u_arg) / (sizeof (int)) ) #ifndef KERNEL extern struct user u; #endif /* KERNEL */ /* Maximum size of combined string or structure arguments passed between the kernel and a venus */ #define RT_MAXDATASIZE (MAXPATHLEN*2) /* The format of the message passed between Venus and the kernel */ struct intercept_message { u_short im_type; /* Message type */ u_short im_dsize; /* Number of bytes in im_data */ int im_client; /* The process id of the client side of the transaction */ short im_uid; /* The effective user id of the client */ short im_gid; /* The effective group id of the client */ int im_seq; /* The sequence number of this transaction. Never 0 */ afs_int32 im_wdfid[3]; /* Current directory on the remote file system Vice II only. */ int im_error; /* u.u_error copied from this */ char im_follow1; /* 1=>follow last component of first pathname if symbolic link; 0=>don't */ char im_follow2; /* ditto for second pathname */ afs_int32 im_pag; /* process authentication group */ /* im_arg contains a representation of the arguments to the intercepted system call, when transmitted from the kernel to Venus. Returned values are passed back from Venus to the kernel the same way */ struct im_arg { int im_aval; /* Value of the argument OR index of argument in im_data */ int im_asize; /* If im_aval is the index of an argument in im_data, then this is its size in bytes. Otherwise this is 0. */ } im_arg[RT_MAX_ARGS]; char im_data[RT_MAXDATASIZE]; /* Variable length field containing string or structure arguments */ /* No fields should be added here, the record may be truncated on transmission in either direction to an appropriate size */ }; #define RT_HEADERSIZE ((sizeof (struct intercept_message)) - RT_MAXDATASIZE) #ifdef KERNEL /* The following shouldn't be done in this manner, but there doesn't seem to be an easy mechanism to discover the device id. The auto- config stuff is only for real devices, I think. */ #ifdef sun #define RMT_MAJ 30 #endif #ifdef vax #define RMT_MAJ 33 #endif /* Sleep priorities */ #define RMT_NOINT_PRI (PINOD+1)/* Sleep with signal handling enabled */ #define RMT_INTOK_PRI (PSLEP-1)/* Disallow aborts due to signal handling */ /* Private data used by the remote intercept routines in the kernel */ /* Note: this was originally designed for only a single remote device. To make it work for multiple devices, I simply unfolded the code by turning this into an array (1 entry per device) and using a macro in the code to reference the appropriate entry. */ struct remote { int rt_flags; /* for flag values, see below */ int rt_seq; /* sequence number generator */ char rt_open; /* 1 if the device is open */ /* XXX UNALIGNED */ struct proc *rt_selproc; /* process waiting for select */ char rt_attach; /* wait channel for process waiting to attach this structure */ char rt_read; /* wait channel for a venus waiting for an intercept */ char rt_reply; /* wait channel for a client process waiting for a reply */ struct intercept_message rt_imr; /* buffer for agent reads */ struct intercept_message rt_imw; /* buffer for agent writes */ #include "rfs.h" } remote[NRFS]; #undef NRFS /* Hack to unfold code for multiple devices */ #define rmt (*rmtp) #define devhack(dev) register struct remote *rmtp = &remote[minor(dev)] /* Flags for rmt.rt_flags */ #define RT_RBUF 1 /* processing venus read request */ #define RT_WBUF 2 /* processing venus write request */ #define RT_SENDING 4 /* sending the structure to the venus */ #define RT_REPLY 8 /* reply from venus to client */ #define RT_SIGNAL 16 /* signal occured, want to send message to venus at next opportunity */ /* This bogus stuff is used for rename/link */ struct Name { int func; /* This used to be a function in BSD 4.2... */ int follow; struct buf *buf; char *name; dev_t dev; enum {havePath, isLocal, haveDev, isRemote} state; }; extern struct inode *RemoteNamei(); extern int RemoteMaybe(); #endif /* KERNEL */ /* * Message type codes for messages sent from the kernel. * NB: the kernel ignores the type field on reply (it merely matches * sequence numbers). Unexpected messages from an venus are ignored (they * may have been destined for a process which has died in the meantime). * At all times, the kernel tries to maintain its own integrity, so that * in the worst case an venus restart should work fine. */ /* * In the capsule descriptions below, "(?)" means that the flagged item * is probably a good candidate for negotiation. */ #define RT_BOGUS 0 /* For debugging purposes in kernel */ #define RT_access 1 /* From kernel: 0: uninterpreted part of pathname * 1: mode * NB: uid/gid for this call are the real (not effective) uid/gid's. * Response: im_error * if im_error == EABSPATH1 then: * 0: Resolved absolute path name. * NB: return value is implicit in im_error. */ #define RT_chdir 2 /* From kernel: 0: uninterpreted part of pathname * Vice I response: * 0: new pathname (with ..'s removed, symbolic * links NOT expanded). * length