|
root / base / usr / src / uts / common / sys / pathconf.h
pathconf.h C 128 lines 4.1 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *	Copyright 1997 Sun Microsystems, Inc.  All rights reserved.
 *	Use is subject to license terms.
 */

#ifndef	_SYS_PATHCONF_H
#define	_SYS_PATHCONF_H

/*	pathconf.h 1.9 89/06/26 SMI	*/

#include <sys/unistd.h>
#include <sys/types.h>

#ifdef	__cplusplus
extern "C" {
#endif

/*
 * POSIX pathconf information
 *
 * static pathconf kludge notes:
 *	For NFSv2 servers, we've added a vop (vop_cntl) to dig out pathconf
 *	information.  The mount program asked for the information from
 *	a remote mountd daemon.  If it gets it, it passes the info
 *	down in a new args field.  The info is passed in the struct below
 *	in nfsargs.pathconf.  There's a new NFS mount flag so that you know
 *	this is happening.  NFS stores the information locally; when a
 *	pathconf request is made, the request is intercepted at the client
 *	and the information is retrieved from the struct passed down by
 *	mount. It's a kludge that will go away as soon
 *	as we can ask the nfs protocol these sorts of questions (NFSr3).
 *	All code is noted by "static pathconf kludge" comments and is
 *	restricted to nfs code in the kernel.
 */

#define	_BITS		(8 * sizeof (short))
#define	_PC_N		((_PC_LAST + _BITS - 1) / _BITS)
#define	_PC_ISSET(n, a)	(a[(n) / _BITS] & (1 << ((n) % _BITS)))
#define	_PC_SET(n, a)	(a[(n) / _BITS] |= (1 << ((n) % _BITS)))
#define	_PC_ERROR	0

struct	pathcnf {
	/*
	 * pathconf() information
	 */
	int		pc_link_max;	/* max links allowed */
	short		pc_max_canon;	/* max line len for a tty */
	short		pc_max_input;	/* input a tty can eat all once */
	short		pc_name_max;	/* max file name length (dir entry) */
	short		pc_path_max;	/* path name len (/x/y/z/...) */
	short		pc_pipe_buf;	/* size of a pipe (bytes) */
	uchar_t		pc_vdisable;	/* safe char to turn off c_cc[i] */
	char		pc_xxx;		/* alignment padding; cc_t == char */
	short		pc_mask[_PC_N];	/* see below */
#ifdef	_KERNEL
	short		pc_refcnt;	/* number of mounts that use this */
	struct pathcnf	*pc_next;	/* linked list */
#endif
};

#ifdef _SYSCALL32
struct	pathcnf32 {
	/*
	 * pathconf() information
	 */
	int32_t		pc_link_max;	/* max links allowed */
	int16_t		pc_max_canon;	/* max line len for a tty */
	int16_t		pc_max_input;	/* input a tty can eat all once */
	int16_t		pc_name_max;	/* max file name length (dir entry) */
	int16_t		pc_path_max;	/* path name len (/x/y/z/...) */
	int16_t		pc_pipe_buf;	/* size of a pipe (bytes) */
	uint8_t		pc_vdisable;	/* safe char to turn off c_cc[i] */
	int8_t		pc_xxx;		/* alignment padding; cc_t == char */
	int16_t		pc_mask[_PC_N];	/* see below */
#ifdef	_KERNEL
	int16_t		pc_refcnt;	/* number of mounts that use this */
	caddr32_t	pc_next;	/* linked list */
#endif
};
#endif /* _SYSCALL32 */

/*
 * pc_mask is used to encode either
 *	a) boolean values (for chown_restricted and no_trunc)
 *	b) errno on/off (for link, canon, input, name, path, and pipe)
 * The _PC_XXX values are defined in unistd.h; they start at 1 and go up
 * sequentially.
 * _PC_ERROR is used as the first bit to indicate total failure
 * (all info invalid).
 * To check for an error something like
 * 	_PC_ISSET(_PC_PATHMAX, foo.pc_mask) != 0
 * is used.
 */

/*
 * The size of the non-kernel part of the struct.
 */
#ifdef	_KERNEL
#define	PCSIZ		((size_t)(&(((struct pathcnf *)0)->pc_refcnt)))
#define	PCCMP(p1, p2)	bcmp((char *)p1, (char *)p2, PCSIZ)
#endif

#ifdef	__cplusplus
}
#endif

#endif	/* _SYS_PATHCONF_H */