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 /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_SENDFILE_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_SENDFILE_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h> 33*7c478bd9Sstevel@tonic-gate 34*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 35*7c478bd9Sstevel@tonic-gate extern "C" { 36*7c478bd9Sstevel@tonic-gate #endif 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 39*7c478bd9Sstevel@tonic-gate #include <sys/uio.h> 40*7c478bd9Sstevel@tonic-gate 41*7c478bd9Sstevel@tonic-gate /* 42*7c478bd9Sstevel@tonic-gate * Structure used by sendfilev() 43*7c478bd9Sstevel@tonic-gate */ 44*7c478bd9Sstevel@tonic-gate typedef struct sendfilevec { 45*7c478bd9Sstevel@tonic-gate int sfv_fd; 46*7c478bd9Sstevel@tonic-gate uint_t sfv_flag; 47*7c478bd9Sstevel@tonic-gate off_t sfv_off; 48*7c478bd9Sstevel@tonic-gate size_t sfv_len; 49*7c478bd9Sstevel@tonic-gate } sendfilevec_t; 50*7c478bd9Sstevel@tonic-gate 51*7c478bd9Sstevel@tonic-gate #define SFV_NOWAIT 1 52*7c478bd9Sstevel@tonic-gate 53*7c478bd9Sstevel@tonic-gate #if defined(_LARGEFILE64_SOURCE) 54*7c478bd9Sstevel@tonic-gate /* 55*7c478bd9Sstevel@tonic-gate * For 32-bit apps accessing largefile offsets 56*7c478bd9Sstevel@tonic-gate * using sendfilev64. 57*7c478bd9Sstevel@tonic-gate */ 58*7c478bd9Sstevel@tonic-gate typedef struct sendfilevec64 { 59*7c478bd9Sstevel@tonic-gate int sfv_fd; 60*7c478bd9Sstevel@tonic-gate uint_t sfv_flag; 61*7c478bd9Sstevel@tonic-gate off64_t sfv_off; 62*7c478bd9Sstevel@tonic-gate size_t sfv_len; 63*7c478bd9Sstevel@tonic-gate } sendfilevec64_t; 64*7c478bd9Sstevel@tonic-gate #endif /* _LARGEFILE64_SOURCE */ 65*7c478bd9Sstevel@tonic-gate 66*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 67*7c478bd9Sstevel@tonic-gate /* 68*7c478bd9Sstevel@tonic-gate * For 32-bit app on a 64-bit kernel to copyin the data. 69*7c478bd9Sstevel@tonic-gate */ 70*7c478bd9Sstevel@tonic-gate typedef struct ksendfilevec32 { 71*7c478bd9Sstevel@tonic-gate int sfv_fd; 72*7c478bd9Sstevel@tonic-gate uint_t sfv_flag; 73*7c478bd9Sstevel@tonic-gate off32_t sfv_off; 74*7c478bd9Sstevel@tonic-gate size32_t sfv_len; 75*7c478bd9Sstevel@tonic-gate } ksendfilevec32_t; 76*7c478bd9Sstevel@tonic-gate 77*7c478bd9Sstevel@tonic-gate /* 78*7c478bd9Sstevel@tonic-gate * For 32-bit app on a 64-bit kernel in largefile environment 79*7c478bd9Sstevel@tonic-gate * (sendfilev64) to copyin data. Use pack(4) on amd64 kernel 80*7c478bd9Sstevel@tonic-gate * to make sizeof(ksendfilevec64_t) == sizeof(sendfilevec64_t). 81*7c478bd9Sstevel@tonic-gate */ 82*7c478bd9Sstevel@tonic-gate 83*7c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 84*7c478bd9Sstevel@tonic-gate #pragma pack(4) 85*7c478bd9Sstevel@tonic-gate #endif 86*7c478bd9Sstevel@tonic-gate 87*7c478bd9Sstevel@tonic-gate typedef struct ksendfilevec64 { 88*7c478bd9Sstevel@tonic-gate int sfv_fd; 89*7c478bd9Sstevel@tonic-gate uint_t sfv_flag; 90*7c478bd9Sstevel@tonic-gate off64_t sfv_off; 91*7c478bd9Sstevel@tonic-gate size32_t sfv_len; 92*7c478bd9Sstevel@tonic-gate } ksendfilevec64_t; 93*7c478bd9Sstevel@tonic-gate 94*7c478bd9Sstevel@tonic-gate #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 95*7c478bd9Sstevel@tonic-gate #pragma pack() 96*7c478bd9Sstevel@tonic-gate #endif 97*7c478bd9Sstevel@tonic-gate 98*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 99*7c478bd9Sstevel@tonic-gate 100*7c478bd9Sstevel@tonic-gate 101*7c478bd9Sstevel@tonic-gate /* The sfv_fd can be a file descriptor or self proc */ 102*7c478bd9Sstevel@tonic-gate #define SFV_FD_SELF (-2) 103*7c478bd9Sstevel@tonic-gate 104*7c478bd9Sstevel@tonic-gate /* System call subcodes */ 105*7c478bd9Sstevel@tonic-gate #define SENDFILEV 0 106*7c478bd9Sstevel@tonic-gate #define SENDFILEV64 1 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate #ifndef _KERNEL 109*7c478bd9Sstevel@tonic-gate /* large file compilation environment setup */ 110*7c478bd9Sstevel@tonic-gate #if !defined(_LP64) && _FILE_OFFSET_BITS == 64 111*7c478bd9Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME 112*7c478bd9Sstevel@tonic-gate #pragma redefine_extname sendfilev sendfilev64 113*7c478bd9Sstevel@tonic-gate #pragma redefine_extname sendfile sendfile64 114*7c478bd9Sstevel@tonic-gate #else /* __PRAGMA_REDEFINE_EXTNAME */ 115*7c478bd9Sstevel@tonic-gate #define sendfilev sendfilev64 116*7c478bd9Sstevel@tonic-gate #define sendfile sendfile64 117*7c478bd9Sstevel@tonic-gate #endif /* __PRAGMA_REDEFINE_EXTNAME */ 118*7c478bd9Sstevel@tonic-gate #endif /* !_LP64 && _FILE_OFFSET_BITS == 64 */ 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate /* In the LP64 compilation environment, the APIs are already large file */ 121*7c478bd9Sstevel@tonic-gate #if defined(_LP64) && defined(_LARGEFILE64_SOURCE) 122*7c478bd9Sstevel@tonic-gate #ifdef __PRAGMA_REDEFINE_EXTNAME 123*7c478bd9Sstevel@tonic-gate #pragma redefine_extname sendfilev64 sendfilev 124*7c478bd9Sstevel@tonic-gate #pragma redefine_extname sendfile64 sendfile 125*7c478bd9Sstevel@tonic-gate #else /* __PRAGMA_REDEFINE_EXTNAME */ 126*7c478bd9Sstevel@tonic-gate #define sendfilev64 sendfilev 127*7c478bd9Sstevel@tonic-gate #define sendfile64 sendfile 128*7c478bd9Sstevel@tonic-gate #endif /* __PRAGMA_REDEFINE_EXTNAME */ 129*7c478bd9Sstevel@tonic-gate #endif /* _LP64 && _LARGEFILE64_SOURCE */ 130*7c478bd9Sstevel@tonic-gate 131*7c478bd9Sstevel@tonic-gate #ifdef __STDC__ 132*7c478bd9Sstevel@tonic-gate extern ssize_t sendfilev(int, const struct sendfilevec *, int, size_t *); 133*7c478bd9Sstevel@tonic-gate extern ssize_t sendfile(int, int, off_t *, size_t); 134*7c478bd9Sstevel@tonic-gate /* Transitional largefile interface */ 135*7c478bd9Sstevel@tonic-gate #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ 136*7c478bd9Sstevel@tonic-gate !defined(__PRAGMA_REDEFINE_EXTNAME)) 137*7c478bd9Sstevel@tonic-gate extern ssize_t sendfilev64(int, const struct sendfilevec64 *, int, size_t *); 138*7c478bd9Sstevel@tonic-gate extern ssize_t sendfile64(int, int, off64_t *, size_t); 139*7c478bd9Sstevel@tonic-gate #endif 140*7c478bd9Sstevel@tonic-gate #else /* __STDC__ */ 141*7c478bd9Sstevel@tonic-gate extern int sendfilev(); 142*7c478bd9Sstevel@tonic-gate extern int sendfile(); 143*7c478bd9Sstevel@tonic-gate #if defined(_LARGEFILE64_SOURCE) && !((_FILE_OFFSET_BITS == 64) && \ 144*7c478bd9Sstevel@tonic-gate !defined(__PRAGMA_REDEFINE_EXTNAME)) 145*7c478bd9Sstevel@tonic-gate extern int sendfilev64(); 146*7c478bd9Sstevel@tonic-gate extern int sendfile64(); 147*7c478bd9Sstevel@tonic-gate #endif 148*7c478bd9Sstevel@tonic-gate #endif /* __STDC__ */ 149*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 150*7c478bd9Sstevel@tonic-gate 151*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 152*7c478bd9Sstevel@tonic-gate } 153*7c478bd9Sstevel@tonic-gate #endif 154*7c478bd9Sstevel@tonic-gate 155*7c478bd9Sstevel@tonic-gate #endif /* _SYS_SENDFILE_H */ 156