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