xref: /illumos-gate/usr/src/uts/common/sys/pathconf.h (revision ad9a7bd3)
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
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  *
227c478bd9Sstevel@tonic-gate  *	Copyright 1997 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  *	Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_SYS_PATHCONF_H
277c478bd9Sstevel@tonic-gate #define	_SYS_PATHCONF_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate /*	pathconf.h 1.9 89/06/26 SMI	*/
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #include <sys/unistd.h>
327c478bd9Sstevel@tonic-gate #include <sys/types.h>
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
357c478bd9Sstevel@tonic-gate extern "C" {
367c478bd9Sstevel@tonic-gate #endif
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate /*
397c478bd9Sstevel@tonic-gate  * POSIX pathconf information
407c478bd9Sstevel@tonic-gate  *
417c478bd9Sstevel@tonic-gate  * static pathconf kludge notes:
427c478bd9Sstevel@tonic-gate  *	For NFSv2 servers, we've added a vop (vop_cntl) to dig out pathconf
437c478bd9Sstevel@tonic-gate  *	information.  The mount program asked for the information from
447c478bd9Sstevel@tonic-gate  *	a remote mountd daemon.  If it gets it, it passes the info
457c478bd9Sstevel@tonic-gate  *	down in a new args field.  The info is passed in the struct below
467c478bd9Sstevel@tonic-gate  *	in nfsargs.pathconf.  There's a new NFS mount flag so that you know
477c478bd9Sstevel@tonic-gate  *	this is happening.  NFS stores the information locally; when a
487c478bd9Sstevel@tonic-gate  *	pathconf request is made, the request is intercepted at the client
497c478bd9Sstevel@tonic-gate  *	and the information is retrieved from the struct passed down by
507c478bd9Sstevel@tonic-gate  *	mount. It's a kludge that will go away as soon
517c478bd9Sstevel@tonic-gate  *	as we can ask the nfs protocol these sorts of questions (NFSr3).
527c478bd9Sstevel@tonic-gate  *	All code is noted by "static pathconf kludge" comments and is
537c478bd9Sstevel@tonic-gate  *	restricted to nfs code in the kernel.
547c478bd9Sstevel@tonic-gate  */
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate #define	_BITS		(8 * sizeof (short))
577c478bd9Sstevel@tonic-gate #define	_PC_N		((_PC_LAST + _BITS - 1) / _BITS)
587c478bd9Sstevel@tonic-gate #define	_PC_ISSET(n, a)	(a[(n) / _BITS] & (1 << ((n) % _BITS)))
597c478bd9Sstevel@tonic-gate #define	_PC_SET(n, a)	(a[(n) / _BITS] |= (1 << ((n) % _BITS)))
607c478bd9Sstevel@tonic-gate #define	_PC_ERROR	0
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate struct	pathcnf {
637c478bd9Sstevel@tonic-gate 	/*
647c478bd9Sstevel@tonic-gate 	 * pathconf() information
657c478bd9Sstevel@tonic-gate 	 */
667c478bd9Sstevel@tonic-gate 	int		pc_link_max;	/* max links allowed */
677c478bd9Sstevel@tonic-gate 	short		pc_max_canon;	/* max line len for a tty */
687c478bd9Sstevel@tonic-gate 	short		pc_max_input;	/* input a tty can eat all once */
697c478bd9Sstevel@tonic-gate 	short		pc_name_max;	/* max file name length (dir entry) */
707c478bd9Sstevel@tonic-gate 	short		pc_path_max;	/* path name len (/x/y/z/...) */
717c478bd9Sstevel@tonic-gate 	short		pc_pipe_buf;	/* size of a pipe (bytes) */
727c478bd9Sstevel@tonic-gate 	uchar_t		pc_vdisable;	/* safe char to turn off c_cc[i] */
737c478bd9Sstevel@tonic-gate 	char		pc_xxx;		/* alignment padding; cc_t == char */
747c478bd9Sstevel@tonic-gate 	short		pc_mask[_PC_N];	/* see below */
757c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
767c478bd9Sstevel@tonic-gate 	short		pc_refcnt;	/* number of mounts that use this */
777c478bd9Sstevel@tonic-gate 	struct pathcnf	*pc_next;	/* linked list */
787c478bd9Sstevel@tonic-gate #endif
797c478bd9Sstevel@tonic-gate };
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32
827c478bd9Sstevel@tonic-gate struct	pathcnf32 {
837c478bd9Sstevel@tonic-gate 	/*
847c478bd9Sstevel@tonic-gate 	 * pathconf() information
857c478bd9Sstevel@tonic-gate 	 */
867c478bd9Sstevel@tonic-gate 	int32_t		pc_link_max;	/* max links allowed */
877c478bd9Sstevel@tonic-gate 	int16_t		pc_max_canon;	/* max line len for a tty */
887c478bd9Sstevel@tonic-gate 	int16_t		pc_max_input;	/* input a tty can eat all once */
897c478bd9Sstevel@tonic-gate 	int16_t		pc_name_max;	/* max file name length (dir entry) */
907c478bd9Sstevel@tonic-gate 	int16_t		pc_path_max;	/* path name len (/x/y/z/...) */
917c478bd9Sstevel@tonic-gate 	int16_t		pc_pipe_buf;	/* size of a pipe (bytes) */
927c478bd9Sstevel@tonic-gate 	uint8_t		pc_vdisable;	/* safe char to turn off c_cc[i] */
937c478bd9Sstevel@tonic-gate 	int8_t		pc_xxx;		/* alignment padding; cc_t == char */
947c478bd9Sstevel@tonic-gate 	int16_t		pc_mask[_PC_N];	/* see below */
957c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
967c478bd9Sstevel@tonic-gate 	int16_t		pc_refcnt;	/* number of mounts that use this */
977c478bd9Sstevel@tonic-gate 	caddr32_t	pc_next;	/* linked list */
987c478bd9Sstevel@tonic-gate #endif
997c478bd9Sstevel@tonic-gate };
1007c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate /*
1037c478bd9Sstevel@tonic-gate  * pc_mask is used to encode either
1047c478bd9Sstevel@tonic-gate  *	a) boolean values (for chown_restricted and no_trunc)
1057c478bd9Sstevel@tonic-gate  *	b) errno on/off (for link, canon, input, name, path, and pipe)
1067c478bd9Sstevel@tonic-gate  * The _PC_XXX values are defined in unistd.h; they start at 1 and go up
1077c478bd9Sstevel@tonic-gate  * sequentially.
1087c478bd9Sstevel@tonic-gate  * _PC_ERROR is used as the first bit to indicate total failure
1097c478bd9Sstevel@tonic-gate  * (all info invalid).
1107c478bd9Sstevel@tonic-gate  * To check for an error something like
1117c478bd9Sstevel@tonic-gate  * 	_PC_ISSET(_PC_PATHMAX, foo.pc_mask) != 0
1127c478bd9Sstevel@tonic-gate  * is used.
1137c478bd9Sstevel@tonic-gate  */
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate /*
1167c478bd9Sstevel@tonic-gate  * The size of the non-kernel part of the struct.
1177c478bd9Sstevel@tonic-gate  */
1187c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
119*ad9a7bd3SRichard Lowe #define	PCSIZ		((size_t)(&(((struct pathcnf *)0)->pc_refcnt)))
1207c478bd9Sstevel@tonic-gate #define	PCCMP(p1, p2)	bcmp((char *)p1, (char *)p2, PCSIZ)
1217c478bd9Sstevel@tonic-gate #endif
1227c478bd9Sstevel@tonic-gate 
1237c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1247c478bd9Sstevel@tonic-gate }
1257c478bd9Sstevel@tonic-gate #endif
1267c478bd9Sstevel@tonic-gate 
1277c478bd9Sstevel@tonic-gate #endif	/* _SYS_PATHCONF_H */
128