xref: /titanic_51/usr/src/uts/common/sys/pathconf.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  *
22*7c478bd9Sstevel@tonic-gate  *	Copyright 1997 Sun Microsystems, Inc.  All rights reserved.
23*7c478bd9Sstevel@tonic-gate  *	Use is subject to license terms.
24*7c478bd9Sstevel@tonic-gate  */
25*7c478bd9Sstevel@tonic-gate 
26*7c478bd9Sstevel@tonic-gate #ifndef	_SYS_PATHCONF_H
27*7c478bd9Sstevel@tonic-gate #define	_SYS_PATHCONF_H
28*7c478bd9Sstevel@tonic-gate 
29*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
30*7c478bd9Sstevel@tonic-gate 
31*7c478bd9Sstevel@tonic-gate /*	pathconf.h 1.9 89/06/26 SMI	*/
32*7c478bd9Sstevel@tonic-gate 
33*7c478bd9Sstevel@tonic-gate #include <sys/unistd.h>
34*7c478bd9Sstevel@tonic-gate #include <sys/types.h>
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
37*7c478bd9Sstevel@tonic-gate extern "C" {
38*7c478bd9Sstevel@tonic-gate #endif
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate /*
41*7c478bd9Sstevel@tonic-gate  * POSIX pathconf information
42*7c478bd9Sstevel@tonic-gate  *
43*7c478bd9Sstevel@tonic-gate  * static pathconf kludge notes:
44*7c478bd9Sstevel@tonic-gate  *	For NFSv2 servers, we've added a vop (vop_cntl) to dig out pathconf
45*7c478bd9Sstevel@tonic-gate  *	information.  The mount program asked for the information from
46*7c478bd9Sstevel@tonic-gate  *	a remote mountd daemon.  If it gets it, it passes the info
47*7c478bd9Sstevel@tonic-gate  *	down in a new args field.  The info is passed in the struct below
48*7c478bd9Sstevel@tonic-gate  *	in nfsargs.pathconf.  There's a new NFS mount flag so that you know
49*7c478bd9Sstevel@tonic-gate  *	this is happening.  NFS stores the information locally; when a
50*7c478bd9Sstevel@tonic-gate  *	pathconf request is made, the request is intercepted at the client
51*7c478bd9Sstevel@tonic-gate  *	and the information is retrieved from the struct passed down by
52*7c478bd9Sstevel@tonic-gate  *	mount. It's a kludge that will go away as soon
53*7c478bd9Sstevel@tonic-gate  *	as we can ask the nfs protocol these sorts of questions (NFSr3).
54*7c478bd9Sstevel@tonic-gate  *	All code is noted by "static pathconf kludge" comments and is
55*7c478bd9Sstevel@tonic-gate  *	restricted to nfs code in the kernel.
56*7c478bd9Sstevel@tonic-gate  */
57*7c478bd9Sstevel@tonic-gate 
58*7c478bd9Sstevel@tonic-gate #define	_BITS		(8 * sizeof (short))
59*7c478bd9Sstevel@tonic-gate #define	_PC_N		((_PC_LAST + _BITS - 1) / _BITS)
60*7c478bd9Sstevel@tonic-gate #define	_PC_ISSET(n, a)	(a[(n) / _BITS] & (1 << ((n) % _BITS)))
61*7c478bd9Sstevel@tonic-gate #define	_PC_SET(n, a)	(a[(n) / _BITS] |= (1 << ((n) % _BITS)))
62*7c478bd9Sstevel@tonic-gate #define	_PC_ERROR	0
63*7c478bd9Sstevel@tonic-gate 
64*7c478bd9Sstevel@tonic-gate struct	pathcnf {
65*7c478bd9Sstevel@tonic-gate 	/*
66*7c478bd9Sstevel@tonic-gate 	 * pathconf() information
67*7c478bd9Sstevel@tonic-gate 	 */
68*7c478bd9Sstevel@tonic-gate 	int		pc_link_max;	/* max links allowed */
69*7c478bd9Sstevel@tonic-gate 	short		pc_max_canon;	/* max line len for a tty */
70*7c478bd9Sstevel@tonic-gate 	short		pc_max_input;	/* input a tty can eat all once */
71*7c478bd9Sstevel@tonic-gate 	short		pc_name_max;	/* max file name length (dir entry) */
72*7c478bd9Sstevel@tonic-gate 	short		pc_path_max;	/* path name len (/x/y/z/...) */
73*7c478bd9Sstevel@tonic-gate 	short		pc_pipe_buf;	/* size of a pipe (bytes) */
74*7c478bd9Sstevel@tonic-gate 	uchar_t		pc_vdisable;	/* safe char to turn off c_cc[i] */
75*7c478bd9Sstevel@tonic-gate 	char		pc_xxx;		/* alignment padding; cc_t == char */
76*7c478bd9Sstevel@tonic-gate 	short		pc_mask[_PC_N];	/* see below */
77*7c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
78*7c478bd9Sstevel@tonic-gate 	short		pc_refcnt;	/* number of mounts that use this */
79*7c478bd9Sstevel@tonic-gate 	struct pathcnf	*pc_next;	/* linked list */
80*7c478bd9Sstevel@tonic-gate #endif
81*7c478bd9Sstevel@tonic-gate };
82*7c478bd9Sstevel@tonic-gate 
83*7c478bd9Sstevel@tonic-gate #ifdef _SYSCALL32
84*7c478bd9Sstevel@tonic-gate struct	pathcnf32 {
85*7c478bd9Sstevel@tonic-gate 	/*
86*7c478bd9Sstevel@tonic-gate 	 * pathconf() information
87*7c478bd9Sstevel@tonic-gate 	 */
88*7c478bd9Sstevel@tonic-gate 	int32_t		pc_link_max;	/* max links allowed */
89*7c478bd9Sstevel@tonic-gate 	int16_t		pc_max_canon;	/* max line len for a tty */
90*7c478bd9Sstevel@tonic-gate 	int16_t		pc_max_input;	/* input a tty can eat all once */
91*7c478bd9Sstevel@tonic-gate 	int16_t		pc_name_max;	/* max file name length (dir entry) */
92*7c478bd9Sstevel@tonic-gate 	int16_t		pc_path_max;	/* path name len (/x/y/z/...) */
93*7c478bd9Sstevel@tonic-gate 	int16_t		pc_pipe_buf;	/* size of a pipe (bytes) */
94*7c478bd9Sstevel@tonic-gate 	uint8_t		pc_vdisable;	/* safe char to turn off c_cc[i] */
95*7c478bd9Sstevel@tonic-gate 	int8_t		pc_xxx;		/* alignment padding; cc_t == char */
96*7c478bd9Sstevel@tonic-gate 	int16_t		pc_mask[_PC_N];	/* see below */
97*7c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
98*7c478bd9Sstevel@tonic-gate 	int16_t		pc_refcnt;	/* number of mounts that use this */
99*7c478bd9Sstevel@tonic-gate 	caddr32_t	pc_next;	/* linked list */
100*7c478bd9Sstevel@tonic-gate #endif
101*7c478bd9Sstevel@tonic-gate };
102*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */
103*7c478bd9Sstevel@tonic-gate 
104*7c478bd9Sstevel@tonic-gate /*
105*7c478bd9Sstevel@tonic-gate  * pc_mask is used to encode either
106*7c478bd9Sstevel@tonic-gate  *	a) boolean values (for chown_restricted and no_trunc)
107*7c478bd9Sstevel@tonic-gate  *	b) errno on/off (for link, canon, input, name, path, and pipe)
108*7c478bd9Sstevel@tonic-gate  * The _PC_XXX values are defined in unistd.h; they start at 1 and go up
109*7c478bd9Sstevel@tonic-gate  * sequentially.
110*7c478bd9Sstevel@tonic-gate  * _PC_ERROR is used as the first bit to indicate total failure
111*7c478bd9Sstevel@tonic-gate  * (all info invalid).
112*7c478bd9Sstevel@tonic-gate  * To check for an error something like
113*7c478bd9Sstevel@tonic-gate  * 	_PC_ISSET(_PC_PATHMAX, foo.pc_mask) != 0
114*7c478bd9Sstevel@tonic-gate  * is used.
115*7c478bd9Sstevel@tonic-gate  */
116*7c478bd9Sstevel@tonic-gate 
117*7c478bd9Sstevel@tonic-gate /*
118*7c478bd9Sstevel@tonic-gate  * The size of the non-kernel part of the struct.
119*7c478bd9Sstevel@tonic-gate  */
120*7c478bd9Sstevel@tonic-gate #ifdef	_KERNEL
121*7c478bd9Sstevel@tonic-gate #define	PCSIZ		(int)(&(((struct pathcnf *)0)->pc_refcnt))
122*7c478bd9Sstevel@tonic-gate #define	PCCMP(p1, p2)	bcmp((char *)p1, (char *)p2, PCSIZ)
123*7c478bd9Sstevel@tonic-gate #endif
124*7c478bd9Sstevel@tonic-gate 
125*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
126*7c478bd9Sstevel@tonic-gate }
127*7c478bd9Sstevel@tonic-gate #endif
128*7c478bd9Sstevel@tonic-gate 
129*7c478bd9Sstevel@tonic-gate #endif	/* _SYS_PATHCONF_H */
130