48
48
49
49
#[ inline]
50
50
pub ( crate ) fn open ( path : & CStr , flags : OFlags , mode : Mode ) -> io:: Result < OwnedFd > {
51
+ // Always enable support for large files.
52
+ let flags = flags | OFlags :: from_bits_retain ( c:: O_LARGEFILE ) ;
53
+
51
54
#[ cfg( any( target_arch = "aarch64" , target_arch = "riscv64" ) ) ]
52
55
{
53
56
openat ( CWD . as_fd ( ) , path, flags, mode)
@@ -65,6 +68,9 @@ pub(crate) fn openat(
65
68
flags : OFlags ,
66
69
mode : Mode ,
67
70
) -> io:: Result < OwnedFd > {
71
+ // Always enable support for large files.
72
+ let flags = flags | OFlags :: from_bits_retain ( c:: O_LARGEFILE ) ;
73
+
68
74
unsafe { ret_owned_fd ( syscall_readonly ! ( __NR_openat, dirfd, path, flags, mode) ) }
69
75
}
70
76
@@ -76,6 +82,9 @@ pub(crate) fn openat2(
76
82
mode : Mode ,
77
83
resolve : ResolveFlags ,
78
84
) -> io:: Result < OwnedFd > {
85
+ // Always enable support for large files.
86
+ let flags = flags | OFlags :: from_bits_retain ( c:: O_LARGEFILE ) ;
87
+
79
88
unsafe {
80
89
ret_owned_fd ( syscall_readonly ! (
81
90
__NR_openat2,
@@ -883,17 +892,19 @@ pub(crate) fn fcntl_getfl(fd: BorrowedFd<'_>) -> io::Result<OFlags> {
883
892
#[ cfg( target_pointer_width = "32" ) ]
884
893
unsafe {
885
894
ret_c_uint ( syscall_readonly ! ( __NR_fcntl64, fd, c_uint( F_GETFL ) ) )
886
- . map ( OFlags :: from_bits_truncate )
895
+ . map ( OFlags :: from_bits_retain )
887
896
}
888
897
#[ cfg( target_pointer_width = "64" ) ]
889
898
unsafe {
890
- ret_c_uint ( syscall_readonly ! ( __NR_fcntl, fd, c_uint( F_GETFL ) ) )
891
- . map ( OFlags :: from_bits_truncate)
899
+ ret_c_uint ( syscall_readonly ! ( __NR_fcntl, fd, c_uint( F_GETFL ) ) ) . map ( OFlags :: from_bits_retain)
892
900
}
893
901
}
894
902
895
903
#[ inline]
896
904
pub ( crate ) fn fcntl_setfl ( fd : BorrowedFd < ' _ > , flags : OFlags ) -> io:: Result < ( ) > {
905
+ // Always enable support for large files.
906
+ let flags = flags | OFlags :: from_bits_retain ( c:: O_LARGEFILE ) ;
907
+
897
908
#[ cfg( target_pointer_width = "32" ) ]
898
909
unsafe {
899
910
ret ( syscall_readonly ! ( __NR_fcntl64, fd, c_uint( F_SETFL ) , flags) )
0 commit comments