xref: /titanic_50/usr/src/uts/common/sys/pathconf.h (revision e4b86885570d77af552e9cf94f142f4d744fb8c8)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 /*	pathconf.h 1.9 89/06/26 SMI	*/
32 
33 #include <sys/unistd.h>
34 #include <sys/types.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 /*
41  * POSIX pathconf information
42  *
43  * static pathconf kludge notes:
44  *	For NFSv2 servers, we've added a vop (vop_cntl) to dig out pathconf
45  *	information.  The mount program asked for the information from
46  *	a remote mountd daemon.  If it gets it, it passes the info
47  *	down in a new args field.  The info is passed in the struct below
48  *	in nfsargs.pathconf.  There's a new NFS mount flag so that you know
49  *	this is happening.  NFS stores the information locally; when a
50  *	pathconf request is made, the request is intercepted at the client
51  *	and the information is retrieved from the struct passed down by
52  *	mount. It's a kludge that will go away as soon
53  *	as we can ask the nfs protocol these sorts of questions (NFSr3).
54  *	All code is noted by "static pathconf kludge" comments and is
55  *	restricted to nfs code in the kernel.
56  */
57 
58 #define	_BITS		(8 * sizeof (short))
59 #define	_PC_N		((_PC_LAST + _BITS - 1) / _BITS)
60 #define	_PC_ISSET(n, a)	(a[(n) / _BITS] & (1 << ((n) % _BITS)))
61 #define	_PC_SET(n, a)	(a[(n) / _BITS] |= (1 << ((n) % _BITS)))
62 #define	_PC_ERROR	0
63 
64 struct	pathcnf {
65 	/*
66 	 * pathconf() information
67 	 */
68 	int		pc_link_max;	/* max links allowed */
69 	short		pc_max_canon;	/* max line len for a tty */
70 	short		pc_max_input;	/* input a tty can eat all once */
71 	short		pc_name_max;	/* max file name length (dir entry) */
72 	short		pc_path_max;	/* path name len (/x/y/z/...) */
73 	short		pc_pipe_buf;	/* size of a pipe (bytes) */
74 	uchar_t		pc_vdisable;	/* safe char to turn off c_cc[i] */
75 	char		pc_xxx;		/* alignment padding; cc_t == char */
76 	short		pc_mask[_PC_N];	/* see below */
77 #ifdef	_KERNEL
78 	short		pc_refcnt;	/* number of mounts that use this */
79 	struct pathcnf	*pc_next;	/* linked list */
80 #endif
81 };
82 
83 #ifdef _SYSCALL32
84 struct	pathcnf32 {
85 	/*
86 	 * pathconf() information
87 	 */
88 	int32_t		pc_link_max;	/* max links allowed */
89 	int16_t		pc_max_canon;	/* max line len for a tty */
90 	int16_t		pc_max_input;	/* input a tty can eat all once */
91 	int16_t		pc_name_max;	/* max file name length (dir entry) */
92 	int16_t		pc_path_max;	/* path name len (/x/y/z/...) */
93 	int16_t		pc_pipe_buf;	/* size of a pipe (bytes) */
94 	uint8_t		pc_vdisable;	/* safe char to turn off c_cc[i] */
95 	int8_t		pc_xxx;		/* alignment padding; cc_t == char */
96 	int16_t		pc_mask[_PC_N];	/* see below */
97 #ifdef	_KERNEL
98 	int16_t		pc_refcnt;	/* number of mounts that use this */
99 	caddr32_t	pc_next;	/* linked list */
100 #endif
101 };
102 #endif /* _SYSCALL32 */
103 
104 /*
105  * pc_mask is used to encode either
106  *	a) boolean values (for chown_restricted and no_trunc)
107  *	b) errno on/off (for link, canon, input, name, path, and pipe)
108  * The _PC_XXX values are defined in unistd.h; they start at 1 and go up
109  * sequentially.
110  * _PC_ERROR is used as the first bit to indicate total failure
111  * (all info invalid).
112  * To check for an error something like
113  * 	_PC_ISSET(_PC_PATHMAX, foo.pc_mask) != 0
114  * is used.
115  */
116 
117 /*
118  * The size of the non-kernel part of the struct.
119  */
120 #ifdef	_KERNEL
121 #define	PCSIZ		(int)(&(((struct pathcnf *)0)->pc_refcnt))
122 #define	PCCMP(p1, p2)	bcmp((char *)p1, (char *)p2, PCSIZ)
123 #endif
124 
125 #ifdef	__cplusplus
126 }
127 #endif
128 
129 #endif	/* _SYS_PATHCONF_H */
130