@@ -7,7 +7,6 @@ use std::ptr;
7
7
use libc;
8
8
9
9
use crate :: errno:: Errno ;
10
- use crate :: off_t;
11
10
use crate :: Result ;
12
11
13
12
/// Copy up to `count` bytes to `out_fd` from `in_fd` starting at `offset`.
@@ -27,7 +26,7 @@ use crate::Result;
27
26
pub fn sendfile < F1 : AsFd , F2 : AsFd > (
28
27
out_fd : F1 ,
29
28
in_fd : F2 ,
30
- offset : Option < & mut off_t > ,
29
+ offset : Option < & mut i64 > ,
31
30
count : usize ,
32
31
) -> Result < usize > {
33
32
let offset = offset
@@ -174,19 +173,19 @@ cfg_if! {
174
173
pub fn sendfile<F1 : AsFd , F2 : AsFd >(
175
174
in_fd: F1 ,
176
175
out_sock: F2 ,
177
- offset: off_t ,
176
+ offset: i64 ,
178
177
count: Option <usize >,
179
178
headers: Option <& [ & [ u8 ] ] >,
180
179
trailers: Option <& [ & [ u8 ] ] >,
181
180
flags: SfFlags ,
182
181
readahead: u16
183
- ) -> ( Result <( ) >, off_t ) {
182
+ ) -> ( Result <( ) >, i64 ) {
184
183
// Readahead goes in upper 16 bits
185
184
// Flags goes in lower 16 bits
186
185
// see `man 2 sendfile`
187
186
let ra32 = u32 :: from( readahead) ;
188
187
let flags: u32 = ( ra32 << 16 ) | ( flags. bits( ) as u32 ) ;
189
- let mut bytes_sent: off_t = 0 ;
188
+ let mut bytes_sent: i64 = 0 ;
190
189
let hdtr = headers. or( trailers) . map( |_| SendfileHeaderTrailer :: new( headers, trailers) ) ;
191
190
let hdtr_ptr = hdtr. as_ref( ) . map_or( ptr:: null( ) , |s| & s. 0 as * const libc:: sf_hdtr) ;
192
191
let return_code = unsafe {
@@ -195,7 +194,7 @@ cfg_if! {
195
194
offset,
196
195
count. unwrap_or( 0 ) ,
197
196
hdtr_ptr as * mut libc:: sf_hdtr,
198
- & mut bytes_sent as * mut off_t ,
197
+ & mut bytes_sent as * mut i64 ,
199
198
flags as c_int)
200
199
} ;
201
200
( Errno :: result( return_code) . and( Ok ( ( ) ) ) , bytes_sent)
@@ -224,12 +223,12 @@ cfg_if! {
224
223
pub fn sendfile<F1 : AsFd , F2 : AsFd >(
225
224
in_fd: F1 ,
226
225
out_sock: F2 ,
227
- offset: off_t ,
226
+ offset: i64 ,
228
227
count: Option <usize >,
229
228
headers: Option <& [ & [ u8 ] ] >,
230
229
trailers: Option <& [ & [ u8 ] ] >,
231
- ) -> ( Result <( ) >, off_t ) {
232
- let mut bytes_sent: off_t = 0 ;
230
+ ) -> ( Result <( ) >, i64 ) {
231
+ let mut bytes_sent: i64 = 0 ;
233
232
let hdtr = headers. or( trailers) . map( |_| SendfileHeaderTrailer :: new( headers, trailers) ) ;
234
233
let hdtr_ptr = hdtr. as_ref( ) . map_or( ptr:: null( ) , |s| & s. 0 as * const libc:: sf_hdtr) ;
235
234
let return_code = unsafe {
@@ -238,7 +237,7 @@ cfg_if! {
238
237
offset,
239
238
count. unwrap_or( 0 ) ,
240
239
hdtr_ptr as * mut libc:: sf_hdtr,
241
- & mut bytes_sent as * mut off_t ,
240
+ & mut bytes_sent as * mut i64 ,
242
241
0 )
243
242
} ;
244
243
( Errno :: result( return_code) . and( Ok ( ( ) ) ) , bytes_sent)
@@ -270,19 +269,19 @@ cfg_if! {
270
269
pub fn sendfile<F1 : AsFd , F2 : AsFd >(
271
270
in_fd: F1 ,
272
271
out_sock: F2 ,
273
- offset: off_t ,
274
- count: Option <off_t >,
272
+ offset: i64 ,
273
+ count: Option <i64 >,
275
274
headers: Option <& [ & [ u8 ] ] >,
276
275
trailers: Option <& [ & [ u8 ] ] >
277
- ) -> ( Result <( ) >, off_t ) {
276
+ ) -> ( Result <( ) >, i64_t ) {
278
277
let mut len = count. unwrap_or( 0 ) ;
279
278
let hdtr = headers. or( trailers) . map( |_| SendfileHeaderTrailer :: new( headers, trailers) ) ;
280
279
let hdtr_ptr = hdtr. as_ref( ) . map_or( ptr:: null( ) , |s| & s. 0 as * const libc:: sf_hdtr) ;
281
280
let return_code = unsafe {
282
281
libc:: sendfile( in_fd. as_fd( ) . as_raw_fd( ) ,
283
282
out_sock. as_fd( ) . as_raw_fd( ) ,
284
283
offset,
285
- & mut len as * mut off_t ,
284
+ & mut len as * mut i64 ,
286
285
hdtr_ptr as * mut libc:: sf_hdtr,
287
286
0 )
288
287
} ;
0 commit comments