File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -138,15 +138,15 @@ cfg_if! {
138138}
139139
140140// SAFETY: path must be null terminated, FD must be manually closed.
141- pub unsafe fn open_readonly ( path : & str ) -> Option < libc:: c_int > {
141+ pub unsafe fn open_readonly ( path : & str ) -> Result < libc:: c_int , Error > {
142142 debug_assert ! ( path. as_bytes( ) . last( ) == Some ( & 0 ) ) ;
143- let fd = open ( path. as_ptr ( ) as * mut _ , libc:: O_RDONLY | libc:: O_CLOEXEC ) ;
143+ let fd = open ( path. as_ptr ( ) as * const _ , libc:: O_RDONLY | libc:: O_CLOEXEC ) ;
144144 if fd < 0 {
145- return None ;
145+ return Err ( last_os_error ( ) ) ;
146146 }
147147 // O_CLOEXEC works on all Unix targets except for older Linux kernels (pre
148148 // 2.6.23), so we also use an ioctl to make sure FD_CLOEXEC is set.
149149 #[ cfg( target_os = "linux" ) ]
150150 libc:: ioctl ( fd, libc:: FIOCLEX ) ;
151- Some ( fd)
151+ Ok ( fd)
152152}
You can’t perform that action at this time.
0 commit comments