@@ -1002,6 +1002,19 @@ pub fn write(fd: RawFd, buf: &[u8]) -> Result<usize> {
1002
1002
Errno :: result ( res) . map ( |r| r as usize )
1003
1003
}
1004
1004
1005
+ // Hard-code constants for Linux since they are not exposed on all target by the
1006
+ // libc crate. This is fine since these constants are part of the stable kernel
1007
+ // ABI.
1008
+ cfg_if ! {
1009
+ if #[ cfg( target_os = "linux" ) ] {
1010
+ const SEEK_DATA : i32 = 3 ;
1011
+ const SEEK_HOLE : i32 = 4 ;
1012
+ } else if #[ cfg( any( target_os = "dragonfly" , target_os = "freebsd" ) ) ] {
1013
+ const SEEK_DATA : i32 = libc:: SEEK_DATA ;
1014
+ const SEEK_HOLE : i32 = libc:: SEEK_HOLE ;
1015
+ }
1016
+ }
1017
+
1005
1018
/// Directive that tells [`lseek`] and [`lseek64`] what the offset is relative to.
1006
1019
///
1007
1020
/// [`lseek`]: ./fn.lseek.html
@@ -1018,21 +1031,15 @@ pub enum Whence {
1018
1031
/// Specify an offset relative to the next location in the file greater than or
1019
1032
/// equal to offset that contains some data. If offset points to
1020
1033
/// some data, then the file offset is set to offset.
1021
- #[ cfg( any( target_os = "dragonfly" , target_os = "freebsd" ,
1022
- all( target_os = "linux" , not( any( target_env = "musl" ,
1023
- target_arch = "mips" ,
1024
- target_arch = "mips64" ) ) ) ) ) ]
1025
- SeekData = libc:: SEEK_DATA ,
1034
+ #[ cfg( any( target_os = "dragonfly" , target_os = "freebsd" , target_os = "linux" ) ) ]
1035
+ SeekData = SEEK_DATA ,
1026
1036
/// Specify an offset relative to the next hole in the file greater than
1027
1037
/// or equal to offset. If offset points into the middle of a hole, then
1028
1038
/// the file offset should be set to offset. If there is no hole past offset,
1029
1039
/// then the file offset should be adjusted to the end of the file (i.e., there
1030
1040
/// is an implicit hole at the end of any file).
1031
- #[ cfg( any( target_os = "dragonfly" , target_os = "freebsd" ,
1032
- all( target_os = "linux" , not( any( target_env = "musl" ,
1033
- target_arch = "mips" ,
1034
- target_arch = "mips64" ) ) ) ) ) ]
1035
- SeekHole = libc:: SEEK_HOLE
1041
+ #[ cfg( any( target_os = "dragonfly" , target_os = "freebsd" , target_os = "linux" ) ) ]
1042
+ SeekHole = SEEK_HOLE ,
1036
1043
}
1037
1044
1038
1045
/// Move the read/write file offset.
0 commit comments