xref: /onnv-gate/usr/src/uts/common/sys/sendfile.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef	_SYS_SENDFILE_H
28*0Sstevel@tonic-gate #define	_SYS_SENDFILE_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #include <sys/feature_tests.h>
33*0Sstevel@tonic-gate 
34*0Sstevel@tonic-gate #ifdef	__cplusplus
35*0Sstevel@tonic-gate extern "C" {
36*0Sstevel@tonic-gate #endif
37*0Sstevel@tonic-gate 
38*0Sstevel@tonic-gate #include <sys/types.h>
39*0Sstevel@tonic-gate #include <sys/uio.h>
40*0Sstevel@tonic-gate 
41*0Sstevel@tonic-gate /*
42*0Sstevel@tonic-gate  * Structure used by sendfilev()
43*0Sstevel@tonic-gate  */
44*0Sstevel@tonic-gate typedef struct sendfilevec {
45*0Sstevel@tonic-gate 	int		sfv_fd;
46*0Sstevel@tonic-gate 	uint_t		sfv_flag;
47*0Sstevel@tonic-gate 	off_t		sfv_off;
48*0Sstevel@tonic-gate 	size_t		sfv_len;
49*0Sstevel@tonic-gate } sendfilevec_t;
50*0Sstevel@tonic-gate 
51*0Sstevel@tonic-gate #define	SFV_NOWAIT	1
52*0Sstevel@tonic-gate 
53*0Sstevel@tonic-gate #if	defined(_LARGEFILE64_SOURCE)
54*0Sstevel@tonic-gate /*
55*0Sstevel@tonic-gate  * For 32-bit apps accessing largefile offsets
56*0Sstevel@tonic-gate  * using sendfilev64.
57*0Sstevel@tonic-gate  */
58*0Sstevel@tonic-gate typedef struct sendfilevec64 {
59*0Sstevel@tonic-gate 	int		sfv_fd;
60*0Sstevel@tonic-gate 	uint_t		sfv_flag;
61*0Sstevel@tonic-gate 	off64_t		sfv_off;
62*0Sstevel@tonic-gate 	size_t		sfv_len;
63*0Sstevel@tonic-gate } sendfilevec64_t;
64*0Sstevel@tonic-gate #endif /* _LARGEFILE64_SOURCE */
65*0Sstevel@tonic-gate 
66*0Sstevel@tonic-gate #if	defined(_SYSCALL32)
67*0Sstevel@tonic-gate /*
68*0Sstevel@tonic-gate  * For 32-bit app on a 64-bit kernel to copyin the data.
69*0Sstevel@tonic-gate  */
70*0Sstevel@tonic-gate typedef struct ksendfilevec32 {
71*0Sstevel@tonic-gate 	int		sfv_fd;
72*0Sstevel@tonic-gate 	uint_t		sfv_flag;
73*0Sstevel@tonic-gate 	off32_t		sfv_off;
74*0Sstevel@tonic-gate 	size32_t	sfv_len;
75*0Sstevel@tonic-gate } ksendfilevec32_t;
76*0Sstevel@tonic-gate 
77*0Sstevel@tonic-gate /*
78*0Sstevel@tonic-gate  * For 32-bit app on a 64-bit kernel in largefile environment
79*0Sstevel@tonic-gate  * (sendfilev64) to copyin data. Use pack(4) on amd64 kernel
80*0Sstevel@tonic-gate  * to make sizeof(ksendfilevec64_t) == sizeof(sendfilevec64_t).
81*0Sstevel@tonic-gate  */
82*0Sstevel@tonic-gate 
83*0Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
84*0Sstevel@tonic-gate #pragma pack(4)
85*0Sstevel@tonic-gate #endif
86*0Sstevel@tonic-gate 
87*0Sstevel@tonic-gate typedef struct ksendfilevec64 {
88*0Sstevel@tonic-gate 	int		sfv_fd;
89*0Sstevel@tonic-gate 	uint_t		sfv_flag;
90*0Sstevel@tonic-gate 	off64_t		sfv_off;
91*0Sstevel@tonic-gate 	size32_t	sfv_len;
92*0Sstevel@tonic-gate } ksendfilevec64_t;
93*0Sstevel@tonic-gate 
94*0Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
95*0Sstevel@tonic-gate #pragma pack()
96*0Sstevel@tonic-gate #endif
97*0Sstevel@tonic-gate 
98*0Sstevel@tonic-gate #endif /* _SYSCALL32 */
99*0Sstevel@tonic-gate 
100*0Sstevel@tonic-gate 
101*0Sstevel@tonic-gate /* The sfv_fd can be a file descriptor or self proc */
102*0Sstevel@tonic-gate #define	SFV_FD_SELF	(-2)
103*0Sstevel@tonic-gate 
104*0Sstevel@tonic-gate /* System call subcodes */
105*0Sstevel@tonic-gate #define	SENDFILEV	0
106*0Sstevel@tonic-gate #define	SENDFILEV64	1
107*0Sstevel@tonic-gate 
108*0Sstevel@tonic-gate #ifndef	_KERNEL
109*0Sstevel@tonic-gate /* large file compilation environment setup */
110*0Sstevel@tonic-gate #if !defined(_LP64) && _FILE_OFFSET_BITS == 64
111*0Sstevel@tonic-gate #ifdef	__PRAGMA_REDEFINE_EXTNAME
112*0Sstevel@tonic-gate #pragma	redefine_extname	sendfilev	sendfilev64
113*0Sstevel@tonic-gate #pragma	redefine_extname	sendfile	sendfile64
114*0Sstevel@tonic-gate #else	/* __PRAGMA_REDEFINE_EXTNAME */
115*0Sstevel@tonic-gate #define	sendfilev			sendfilev64
116*0Sstevel@tonic-gate #define	sendfile			sendfile64
117*0Sstevel@tonic-gate #endif	/* __PRAGMA_REDEFINE_EXTNAME */
118*0Sstevel@tonic-gate #endif	/* !_LP64 && _FILE_OFFSET_BITS == 64 */
119*0Sstevel@tonic-gate 
120*0Sstevel@tonic-gate /* In the LP64 compilation environment, the APIs are already large file */
121*0Sstevel@tonic-gate #if defined(_LP64) && defined(_LARGEFILE64_SOURCE)
122*0Sstevel@tonic-gate #ifdef	__PRAGMA_REDEFINE_EXTNAME
123*0Sstevel@tonic-gate #pragma redefine_extname	sendfilev64	sendfilev
124*0Sstevel@tonic-gate #pragma redefine_extname	sendfile64	sendfile
125*0Sstevel@tonic-gate #else	/* __PRAGMA_REDEFINE_EXTNAME */
126*0Sstevel@tonic-gate #define	sendfilev64			sendfilev
127*0Sstevel@tonic-gate #define	sendfile64			sendfile
128*0Sstevel@tonic-gate #endif	/* __PRAGMA_REDEFINE_EXTNAME */
129*0Sstevel@tonic-gate #endif	/* _LP64 && _LARGEFILE64_SOURCE */
130*0Sstevel@tonic-gate 
131*0Sstevel@tonic-gate #ifdef	__STDC__
132*0Sstevel@tonic-gate extern ssize_t sendfilev(int, const struct sendfilevec *, int, size_t *);
133*0Sstevel@tonic-gate extern ssize_t sendfile(int, int, off_t *, size_t);
134*0Sstevel@tonic-gate /* Transitional largefile interface */
135*0Sstevel@tonic-gate #if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
136*0Sstevel@tonic-gate 	    !defined(__PRAGMA_REDEFINE_EXTNAME))
137*0Sstevel@tonic-gate extern ssize_t sendfilev64(int, const struct sendfilevec64 *, int, size_t *);
138*0Sstevel@tonic-gate extern ssize_t sendfile64(int, int, off64_t *, size_t);
139*0Sstevel@tonic-gate #endif
140*0Sstevel@tonic-gate #else	/* __STDC__ */
141*0Sstevel@tonic-gate extern int sendfilev();
142*0Sstevel@tonic-gate extern int sendfile();
143*0Sstevel@tonic-gate #if	defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \
144*0Sstevel@tonic-gate 	    !defined(__PRAGMA_REDEFINE_EXTNAME))
145*0Sstevel@tonic-gate extern int sendfilev64();
146*0Sstevel@tonic-gate extern int sendfile64();
147*0Sstevel@tonic-gate #endif
148*0Sstevel@tonic-gate #endif	/* __STDC__ */
149*0Sstevel@tonic-gate #endif	/* _KERNEL */
150*0Sstevel@tonic-gate 
151*0Sstevel@tonic-gate #ifdef	__cplusplus
152*0Sstevel@tonic-gate }
153*0Sstevel@tonic-gate #endif
154*0Sstevel@tonic-gate 
155*0Sstevel@tonic-gate #endif	/* _SYS_SENDFILE_H */
156