xref: /titanic_51/usr/src/uts/common/rpcsvc/autofs_prot.x (revision 3bfb48feb84bb78924286a801c68f80198912fa7)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
539d3e169Sevanl  * Common Development and Distribution License (the "License").
639d3e169Sevanl  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate %/*
22*3bfb48feSsemery % * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate % * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate % */
257c478bd9Sstevel@tonic-gate %
267c478bd9Sstevel@tonic-gate %#pragma ident	"%Z%%M%	%I%	%E% SMI"
277c478bd9Sstevel@tonic-gate %
287c478bd9Sstevel@tonic-gate %#include <sys/vfs.h>
297c478bd9Sstevel@tonic-gate %#include <sys/dirent.h>
307c478bd9Sstevel@tonic-gate %#include <sys/types.h>
317c478bd9Sstevel@tonic-gate %#include <sys/types32.h>
327c478bd9Sstevel@tonic-gate %
337c478bd9Sstevel@tonic-gate %#define	xdr_dev_t xdr_u_int
347c478bd9Sstevel@tonic-gate %#define	xdr_bool_t xdr_bool
357c478bd9Sstevel@tonic-gate %
367c478bd9Sstevel@tonic-gate /*
377c478bd9Sstevel@tonic-gate  * Autofs/automountd communication protocol.
387c478bd9Sstevel@tonic-gate  */
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate const AUTOFS_MAXPATHLEN		= 1024;
417c478bd9Sstevel@tonic-gate const AUTOFS_MAXCOMPONENTLEN	= 255;
427c478bd9Sstevel@tonic-gate const AUTOFS_MAXOPTSLEN		= 1024;
437c478bd9Sstevel@tonic-gate const AUTOFS_DAEMONCOOKIE	= 100000;
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate /*
467c478bd9Sstevel@tonic-gate  * Action Status
477c478bd9Sstevel@tonic-gate  * Automountd replies to autofs indicating whether the operation is done,
487c478bd9Sstevel@tonic-gate  * or further action needs to be taken by autofs.
497c478bd9Sstevel@tonic-gate  */
507c478bd9Sstevel@tonic-gate enum autofs_stat {
517c478bd9Sstevel@tonic-gate 	AUTOFS_ACTION=0,	/* list of actions included */
527c478bd9Sstevel@tonic-gate 	AUTOFS_DONE=1		/* no further action required by kernel */
537c478bd9Sstevel@tonic-gate };
547c478bd9Sstevel@tonic-gate 
557c478bd9Sstevel@tonic-gate /*
567c478bd9Sstevel@tonic-gate  * Used by autofs to either create a link, or mount a new filesystem.
577c478bd9Sstevel@tonic-gate  */
587c478bd9Sstevel@tonic-gate enum autofs_action {
597c478bd9Sstevel@tonic-gate 	AUTOFS_MOUNT_RQ=0,	/* mount request */
607c478bd9Sstevel@tonic-gate 	AUTOFS_LINK_RQ=1,	/* link create */
617c478bd9Sstevel@tonic-gate 	AUTOFS_NONE=2		/* no action */
627c478bd9Sstevel@tonic-gate };
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate enum autofs_res {
657c478bd9Sstevel@tonic-gate 	AUTOFS_OK=0,
667c478bd9Sstevel@tonic-gate 	AUTOFS_NOENT=2,
677c478bd9Sstevel@tonic-gate 	AUTOFS_ECOMM=5,
687c478bd9Sstevel@tonic-gate 	AUTOFS_NOMEM=12,
697c478bd9Sstevel@tonic-gate 	AUTOFS_NOTDIR=20,
707c478bd9Sstevel@tonic-gate 	AUTOFS_SHUTDOWN=1000
717c478bd9Sstevel@tonic-gate };
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate /*
747c478bd9Sstevel@tonic-gate  * Lookup/Mount request.
757c478bd9Sstevel@tonic-gate  * Argument structure passed to both autofs_lookup() and autofs_mount().
767c478bd9Sstevel@tonic-gate  * autofs_lookup():
777c478bd9Sstevel@tonic-gate  *	Query automountd if 'path/subdir/name' exists in 'map'
787c478bd9Sstevel@tonic-gate  * autofs_mount():
797c478bd9Sstevel@tonic-gate  *	Request automountd to mount the map entry associated with
807c478bd9Sstevel@tonic-gate  *	'path/subdir/name' in 'map' given 'opts' options.
817c478bd9Sstevel@tonic-gate  */
827c478bd9Sstevel@tonic-gate struct autofs_lookupargs {
837c478bd9Sstevel@tonic-gate 	string	map<AUTOFS_MAXPATHLEN>;		/* context or map name */
847c478bd9Sstevel@tonic-gate 	string	path<AUTOFS_MAXPATHLEN>;	/* mountpoint */
857c478bd9Sstevel@tonic-gate 	string	name<AUTOFS_MAXCOMPONENTLEN>;	/* entry we're looking for */
867c478bd9Sstevel@tonic-gate 	string	subdir<AUTOFS_MAXPATHLEN>;	/* subdir within map */
877c478bd9Sstevel@tonic-gate 	string	opts<AUTOFS_MAXOPTSLEN>;
887c478bd9Sstevel@tonic-gate 	bool_t	isdirect;			/* direct mountpoint? */
89*3bfb48feSsemery 	uid_t	uid;				/* uid of caller */
907c478bd9Sstevel@tonic-gate };
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate /*
937c478bd9Sstevel@tonic-gate  * Symbolic link information.
947c478bd9Sstevel@tonic-gate  */
957c478bd9Sstevel@tonic-gate struct linka {
967c478bd9Sstevel@tonic-gate 	string	dir<AUTOFS_MAXPATHLEN>;		/* original name */
977c478bd9Sstevel@tonic-gate 	string	link<AUTOFS_MAXPATHLEN>;	/* link (new) name */
987c478bd9Sstevel@tonic-gate };
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate /*
1017c478bd9Sstevel@tonic-gate  * We don't define netbuf in RPCL, we include the header file that
1027c478bd9Sstevel@tonic-gate  * includes it, and implement the xdr function ourselves.
1037c478bd9Sstevel@tonic-gate  */
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate /*
1067c478bd9Sstevel@tonic-gate  * Autofs Mount specific information - used to mount a new
1077c478bd9Sstevel@tonic-gate  * autofs filesystem.
1087c478bd9Sstevel@tonic-gate  */
1097c478bd9Sstevel@tonic-gate struct autofs_args {
1107c478bd9Sstevel@tonic-gate 	struct netbuf	addr;		/* daemon address */
1117c478bd9Sstevel@tonic-gate 	string path<AUTOFS_MAXPATHLEN>;	/* autofs mountpoint */
1127c478bd9Sstevel@tonic-gate 	string opts<AUTOFS_MAXOPTSLEN>;	/* default mount options */
1137c478bd9Sstevel@tonic-gate 	string map<AUTOFS_MAXPATHLEN>;	/* name of map */
1147c478bd9Sstevel@tonic-gate 	string subdir<AUTOFS_MAXPATHLEN>; /* subdir within map */
1157c478bd9Sstevel@tonic-gate 	string key<AUTOFS_MAXCOMPONENTLEN>; /* used in direct mounts only */
1167c478bd9Sstevel@tonic-gate 	int		mount_to;	/* time in sec the fs is to remain */
1177c478bd9Sstevel@tonic-gate 					/* mounted after last reference */
1187c478bd9Sstevel@tonic-gate 	int		rpc_to;		/* timeout for rpc calls */
1197c478bd9Sstevel@tonic-gate 	int		direct;		/* 1 = direct mount */
1207c478bd9Sstevel@tonic-gate };
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate %#ifdef _SYSCALL32
1237c478bd9Sstevel@tonic-gate %/*
1247c478bd9Sstevel@tonic-gate % * This is an LP64 representation of the ILP32 autofs_args data structure
1257c478bd9Sstevel@tonic-gate % * for use by autofs_mount which may receive the data structure "raw"
1267c478bd9Sstevel@tonic-gate % * from a 32-bit program without being processed by XDR.  rpcgen doesn't
1277c478bd9Sstevel@tonic-gate % * need to see this structure since RPC/XDR only deals with the "native"
1287c478bd9Sstevel@tonic-gate % * version of autofs_args.  If this isn't hidden from rpcgen then it will
1297c478bd9Sstevel@tonic-gate % * insist on generating unnecessary code to deal with it.
1307c478bd9Sstevel@tonic-gate % */
1317c478bd9Sstevel@tonic-gate %struct autofs_args32 {
1327c478bd9Sstevel@tonic-gate %	struct netbuf32	addr;		/* daemon address */
1337c478bd9Sstevel@tonic-gate %	caddr32_t	path;		/* autofs mountpoint */
1347c478bd9Sstevel@tonic-gate %	caddr32_t	opts;		/* default mount options */
1357c478bd9Sstevel@tonic-gate %	caddr32_t	map;		/* name of map */
1367c478bd9Sstevel@tonic-gate %	caddr32_t	subdir;		/* subdir within map */
1377c478bd9Sstevel@tonic-gate %	caddr32_t	key;		/* used in direct mounts */
1387c478bd9Sstevel@tonic-gate %	int32_t		mount_to;	/* time in sec the fs is to remain */
1397c478bd9Sstevel@tonic-gate %					/* mounted after last reference */
1407c478bd9Sstevel@tonic-gate %	int32_t		rpc_to;		/* timeout for rpc calls */
1417c478bd9Sstevel@tonic-gate %	int32_t		direct;		/* 1 = direct mount */
1427c478bd9Sstevel@tonic-gate %};
1437c478bd9Sstevel@tonic-gate %#endif	/* _SYSCALL32 */
1447c478bd9Sstevel@tonic-gate 
1457c478bd9Sstevel@tonic-gate /*
1467c478bd9Sstevel@tonic-gate  * Contains the necessary information to notify autofs to
1477c478bd9Sstevel@tonic-gate  * perfom either a new mount or create a symbolic link.
1487c478bd9Sstevel@tonic-gate  */
1497c478bd9Sstevel@tonic-gate union action_list_entry switch (autofs_action action) {
1507c478bd9Sstevel@tonic-gate case AUTOFS_MOUNT_RQ:
1517c478bd9Sstevel@tonic-gate 	struct mounta mounta;
1527c478bd9Sstevel@tonic-gate case AUTOFS_LINK_RQ:
1537c478bd9Sstevel@tonic-gate 	struct linka linka;
1547c478bd9Sstevel@tonic-gate default:
1557c478bd9Sstevel@tonic-gate 	void;
1567c478bd9Sstevel@tonic-gate };
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate /*
1597c478bd9Sstevel@tonic-gate  * List of actions that need to be performed by autofs to
1607c478bd9Sstevel@tonic-gate  * finish the requested operation.
1617c478bd9Sstevel@tonic-gate  */
1627c478bd9Sstevel@tonic-gate struct action_list {
1637c478bd9Sstevel@tonic-gate 	action_list_entry action;
1647c478bd9Sstevel@tonic-gate 	action_list *next;
1657c478bd9Sstevel@tonic-gate };
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate union mount_result_type switch (autofs_stat status) {
1687c478bd9Sstevel@tonic-gate case AUTOFS_ACTION:
1697c478bd9Sstevel@tonic-gate 	action_list *list;
1707c478bd9Sstevel@tonic-gate case AUTOFS_DONE:
1717c478bd9Sstevel@tonic-gate 	int error;
1727c478bd9Sstevel@tonic-gate default:
1737c478bd9Sstevel@tonic-gate 	void;
1747c478bd9Sstevel@tonic-gate };
1757c478bd9Sstevel@tonic-gate 
1767c478bd9Sstevel@tonic-gate /*
1777c478bd9Sstevel@tonic-gate  * Result from mount operation.
1787c478bd9Sstevel@tonic-gate  */
1797c478bd9Sstevel@tonic-gate struct autofs_mountres {
1807c478bd9Sstevel@tonic-gate 	mount_result_type mr_type;
1817c478bd9Sstevel@tonic-gate 	int mr_verbose;
1827c478bd9Sstevel@tonic-gate };
1837c478bd9Sstevel@tonic-gate 
1847c478bd9Sstevel@tonic-gate union lookup_result_type switch (autofs_action action) {
1857c478bd9Sstevel@tonic-gate case AUTOFS_LINK_RQ:
1867c478bd9Sstevel@tonic-gate 	struct linka lt_linka;
1877c478bd9Sstevel@tonic-gate case AUTOFS_MOUNT_RQ:
1887c478bd9Sstevel@tonic-gate 	void;
1897c478bd9Sstevel@tonic-gate default:
1907c478bd9Sstevel@tonic-gate 	void;
1917c478bd9Sstevel@tonic-gate };
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate /*
1947c478bd9Sstevel@tonic-gate  * Result from lookup operation.
1957c478bd9Sstevel@tonic-gate  */
1967c478bd9Sstevel@tonic-gate struct autofs_lookupres {
1977c478bd9Sstevel@tonic-gate 	enum autofs_res lu_res;
1987c478bd9Sstevel@tonic-gate 	lookup_result_type lu_type;
1997c478bd9Sstevel@tonic-gate 	int lu_verbose;
2007c478bd9Sstevel@tonic-gate };
2017c478bd9Sstevel@tonic-gate 
2027c478bd9Sstevel@tonic-gate /*
2037c478bd9Sstevel@tonic-gate  * Unmount operation request
2047c478bd9Sstevel@tonic-gate  * Automountd will issue unmount system call for the
2057c478bd9Sstevel@tonic-gate  * given fstype on the given mntpnt.
2067c478bd9Sstevel@tonic-gate  */
2077c478bd9Sstevel@tonic-gate 
2087c478bd9Sstevel@tonic-gate struct umntrequest {
2097c478bd9Sstevel@tonic-gate 	bool_t isdirect;			/* direct mount? */
2107c478bd9Sstevel@tonic-gate 	string mntresource<AUTOFS_MAXPATHLEN>;	/* mntpnt source */
2117c478bd9Sstevel@tonic-gate 	string mntpnt<AUTOFS_MAXPATHLEN>;	/* mntpnt to unmount */
2127c478bd9Sstevel@tonic-gate 	string fstype<AUTOFS_MAXCOMPONENTLEN>;	/* filesystem type to umount */
2137c478bd9Sstevel@tonic-gate 	string mntopts<AUTOFS_MAXOPTSLEN>;	/* mntpnt options */
2147c478bd9Sstevel@tonic-gate 	struct umntrequest *next;		/* next unmount */
2157c478bd9Sstevel@tonic-gate };
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate /*
2187c478bd9Sstevel@tonic-gate  * Unmount operation result
2197c478bd9Sstevel@tonic-gate  * status = 0 if unmount was successful,
2207c478bd9Sstevel@tonic-gate  * otherwise status = errno.
2217c478bd9Sstevel@tonic-gate  */
2227c478bd9Sstevel@tonic-gate struct umntres {
2237c478bd9Sstevel@tonic-gate 	int status;
2247c478bd9Sstevel@tonic-gate };
2257c478bd9Sstevel@tonic-gate 
2267c478bd9Sstevel@tonic-gate /*
2277c478bd9Sstevel@tonic-gate  * AUTOFS readdir request
2287c478bd9Sstevel@tonic-gate  * Request list of entries in 'rda_map' map starting at the given
2297c478bd9Sstevel@tonic-gate  * offset 'rda_offset', for 'rda_count' bytes.
2307c478bd9Sstevel@tonic-gate  */
2317c478bd9Sstevel@tonic-gate struct autofs_rddirargs {
2327c478bd9Sstevel@tonic-gate 	string	rda_map<AUTOFS_MAXPATHLEN>;
2337c478bd9Sstevel@tonic-gate 	u_int	rda_offset;		/* starting offset */
2347c478bd9Sstevel@tonic-gate 	u_int	rda_count;		/* total size requested */
235*3bfb48feSsemery 	uid_t	uid;			/* uid of caller */
2367c478bd9Sstevel@tonic-gate };
2377c478bd9Sstevel@tonic-gate 
2387c478bd9Sstevel@tonic-gate struct autofsrddir {
2397c478bd9Sstevel@tonic-gate 	u_int	rddir_offset;		/* last offset in list */
2407c478bd9Sstevel@tonic-gate 	u_int	rddir_size;		/* size in bytes of entries */
2417c478bd9Sstevel@tonic-gate 	bool_t	rddir_eof;		/* TRUE if last entry in result */
2427c478bd9Sstevel@tonic-gate 	struct dirent64 *rddir_entries;	/* variable number of entries */
2437c478bd9Sstevel@tonic-gate };
2447c478bd9Sstevel@tonic-gate 
2457c478bd9Sstevel@tonic-gate /*
2467c478bd9Sstevel@tonic-gate  * AUTOFS readdir result.
2477c478bd9Sstevel@tonic-gate  */
2487c478bd9Sstevel@tonic-gate struct autofs_rddirres {
2497c478bd9Sstevel@tonic-gate 	enum autofs_res rd_status;
2507c478bd9Sstevel@tonic-gate 	u_int rd_bufsize;		/* autofs request size (not xdr'ed) */
2517c478bd9Sstevel@tonic-gate 	struct autofsrddir rd_rddir;
2527c478bd9Sstevel@tonic-gate };
253