11//! Get filesystem statistics, non-portably
22//!
33//! See [`statvfs`](crate::sys::statvfs) for a portable alternative.
4- #[ cfg( not( linux_android) ) ]
4+ #[ cfg( not( any ( linux_android, target_os = "cygwin" ) ) ) ]
55use std:: ffi:: CStr ;
66use std:: fmt:: { self , Debug } ;
77use std:: mem;
@@ -19,8 +19,11 @@ use crate::{errno::Errno, NixPath, Result};
1919#[ cfg( target_os = "android" ) ]
2020pub type fsid_t = libc:: __fsid_t ;
2121/// Identifies a mounted file system
22- #[ cfg( not( target_os = "android" ) ) ]
22+ #[ cfg( not( any ( target_os = "android" , target_os = "cygwin" ) ) ) ]
2323pub type fsid_t = libc:: fsid_t ;
24+ /// Identifies a mounted file system
25+ #[ cfg( target_os = "cygwin" ) ]
26+ pub type fsid_t = libc:: c_long ;
2427
2528cfg_if ! {
2629 if #[ cfg( any( linux_android, target_os = "fuchsia" ) ) ] {
@@ -71,6 +74,8 @@ type fs_type_t = libc::c_int;
7174 ) )
7275) ) ]
7376type fs_type_t = libc:: __fsword_t ;
77+ #[ cfg( target_os = "cygwin" ) ]
78+ type fs_type_t = libc:: c_long ;
7479
7580/// Describes the file system type as known by the operating system.
7681#[ cfg( any(
@@ -83,6 +88,7 @@ type fs_type_t = libc::__fsword_t;
8388 target_os = "linux" ,
8489 not( any( target_arch = "s390x" , target_env = "musl" ) )
8590 ) ,
91+ target_os = "cygwin" ,
8692) ) ]
8793#[ derive( Eq , Copy , Clone , PartialEq , Debug ) ]
8894pub struct FsType ( pub fs_type_t ) ;
@@ -301,7 +307,7 @@ impl Statfs {
301307 }
302308
303309 /// Magic code defining system type
304- #[ cfg( not( linux_android) ) ]
310+ #[ cfg( not( any ( linux_android, target_os = "cygwin" ) ) ) ]
305311 pub fn filesystem_type_name ( & self ) -> & str {
306312 let c_str = unsafe { CStr :: from_ptr ( self . 0 . f_fstypename . as_ptr ( ) ) } ;
307313 c_str. to_str ( ) . unwrap ( )
@@ -437,7 +443,7 @@ impl Statfs {
437443 }
438444
439445 /// Size of a block
440- #[ cfg( target_os = "dragonfly" ) ]
446+ #[ cfg( any ( target_os = "dragonfly" , target_os = "cygwin" ) ) ]
441447 pub fn block_size ( & self ) -> libc:: c_long {
442448 self . 0 . f_bsize
443449 }
@@ -518,7 +524,7 @@ impl Statfs {
518524 }
519525
520526 /// Total data blocks in filesystem
521- #[ cfg( target_os = "dragonfly" ) ]
527+ #[ cfg( any ( target_os = "dragonfly" , target_os = "cygwin" ) ) ]
522528 pub fn blocks ( & self ) -> libc:: c_long {
523529 self . 0 . f_blocks
524530 }
@@ -542,7 +548,7 @@ impl Statfs {
542548 }
543549
544550 /// Free blocks in filesystem
545- #[ cfg( target_os = "dragonfly" ) ]
551+ #[ cfg( any ( target_os = "dragonfly" , target_os = "cygwin" ) ) ]
546552 pub fn blocks_free ( & self ) -> libc:: c_long {
547553 self . 0 . f_bfree
548554 }
@@ -560,7 +566,7 @@ impl Statfs {
560566 }
561567
562568 /// Free blocks available to unprivileged user
563- #[ cfg( target_os = "dragonfly" ) ]
569+ #[ cfg( any ( target_os = "dragonfly" , target_os = "cygwin" ) ) ]
564570 pub fn blocks_available ( & self ) -> libc:: c_long {
565571 self . 0 . f_bavail
566572 }
@@ -590,7 +596,7 @@ impl Statfs {
590596 }
591597
592598 /// Total file nodes in filesystem
593- #[ cfg( target_os = "dragonfly" ) ]
599+ #[ cfg( any ( target_os = "dragonfly" , target_os = "cygwin" ) ) ]
594600 pub fn files ( & self ) -> libc:: c_long {
595601 self . 0 . f_files
596602 }
@@ -613,7 +619,7 @@ impl Statfs {
613619 }
614620
615621 /// Free file nodes in filesystem
616- #[ cfg( target_os = "dragonfly" ) ]
622+ #[ cfg( any ( target_os = "dragonfly" , target_os = "cygwin" ) ) ]
617623 pub fn files_free ( & self ) -> libc:: c_long {
618624 self . 0 . f_ffree
619625 }
@@ -639,6 +645,7 @@ impl Statfs {
639645impl Debug for Statfs {
640646 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
641647 let mut ds = f. debug_struct ( "Statfs" ) ;
648+ #[ cfg( not( target_os = "cygwin" ) ) ]
642649 ds. field ( "optimal_transfer_size" , & self . optimal_transfer_size ( ) ) ;
643650 ds. field ( "block_size" , & self . block_size ( ) ) ;
644651 ds. field ( "blocks" , & self . blocks ( ) ) ;
0 commit comments