1
1
//! Get filesystem statistics, non-portably
2
2
//!
3
3
//! See [`statvfs`](crate::sys::statvfs) for a portable alternative.
4
- #[ cfg( not( linux_android) ) ]
4
+ #[ cfg( not( any ( linux_android, target_os = "cygwin" ) ) ) ]
5
5
use std:: ffi:: CStr ;
6
6
use std:: fmt:: { self , Debug } ;
7
7
use std:: mem;
@@ -19,8 +19,11 @@ use crate::{errno::Errno, NixPath, Result};
19
19
#[ cfg( target_os = "android" ) ]
20
20
pub type fsid_t = libc:: __fsid_t ;
21
21
/// Identifies a mounted file system
22
- #[ cfg( not( target_os = "android" ) ) ]
22
+ #[ cfg( not( any ( target_os = "android" , target_os = "cygwin" ) ) ) ]
23
23
pub 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 ;
24
27
25
28
cfg_if ! {
26
29
if #[ cfg( any( linux_android, target_os = "fuchsia" ) ) ] {
@@ -71,6 +74,8 @@ type fs_type_t = libc::c_int;
71
74
) )
72
75
) ) ]
73
76
type fs_type_t = libc:: __fsword_t ;
77
+ #[ cfg( target_os = "cygwin" ) ]
78
+ type fs_type_t = libc:: c_long ;
74
79
75
80
/// Describes the file system type as known by the operating system.
76
81
#[ cfg( any(
@@ -83,6 +88,7 @@ type fs_type_t = libc::__fsword_t;
83
88
target_os = "linux" ,
84
89
not( any( target_arch = "s390x" , target_env = "musl" ) )
85
90
) ,
91
+ target_os = "cygwin" ,
86
92
) ) ]
87
93
#[ derive( Eq , Copy , Clone , PartialEq , Debug ) ]
88
94
pub struct FsType ( pub fs_type_t ) ;
@@ -301,7 +307,7 @@ impl Statfs {
301
307
}
302
308
303
309
/// Magic code defining system type
304
- #[ cfg( not( linux_android) ) ]
310
+ #[ cfg( not( any ( linux_android, target_os = "cygwin" ) ) ) ]
305
311
pub fn filesystem_type_name ( & self ) -> & str {
306
312
let c_str = unsafe { CStr :: from_ptr ( self . 0 . f_fstypename . as_ptr ( ) ) } ;
307
313
c_str. to_str ( ) . unwrap ( )
@@ -437,7 +443,7 @@ impl Statfs {
437
443
}
438
444
439
445
/// Size of a block
440
- #[ cfg( target_os = "dragonfly" ) ]
446
+ #[ cfg( any ( target_os = "dragonfly" , target_os = "cygwin" ) ) ]
441
447
pub fn block_size ( & self ) -> libc:: c_long {
442
448
self . 0 . f_bsize
443
449
}
@@ -518,7 +524,7 @@ impl Statfs {
518
524
}
519
525
520
526
/// Total data blocks in filesystem
521
- #[ cfg( target_os = "dragonfly" ) ]
527
+ #[ cfg( any ( target_os = "dragonfly" , target_os = "cygwin" ) ) ]
522
528
pub fn blocks ( & self ) -> libc:: c_long {
523
529
self . 0 . f_blocks
524
530
}
@@ -542,7 +548,7 @@ impl Statfs {
542
548
}
543
549
544
550
/// Free blocks in filesystem
545
- #[ cfg( target_os = "dragonfly" ) ]
551
+ #[ cfg( any ( target_os = "dragonfly" , target_os = "cygwin" ) ) ]
546
552
pub fn blocks_free ( & self ) -> libc:: c_long {
547
553
self . 0 . f_bfree
548
554
}
@@ -560,7 +566,7 @@ impl Statfs {
560
566
}
561
567
562
568
/// Free blocks available to unprivileged user
563
- #[ cfg( target_os = "dragonfly" ) ]
569
+ #[ cfg( any ( target_os = "dragonfly" , target_os = "cygwin" ) ) ]
564
570
pub fn blocks_available ( & self ) -> libc:: c_long {
565
571
self . 0 . f_bavail
566
572
}
@@ -590,7 +596,7 @@ impl Statfs {
590
596
}
591
597
592
598
/// Total file nodes in filesystem
593
- #[ cfg( target_os = "dragonfly" ) ]
599
+ #[ cfg( any ( target_os = "dragonfly" , target_os = "cygwin" ) ) ]
594
600
pub fn files ( & self ) -> libc:: c_long {
595
601
self . 0 . f_files
596
602
}
@@ -613,7 +619,7 @@ impl Statfs {
613
619
}
614
620
615
621
/// Free file nodes in filesystem
616
- #[ cfg( target_os = "dragonfly" ) ]
622
+ #[ cfg( any ( target_os = "dragonfly" , target_os = "cygwin" ) ) ]
617
623
pub fn files_free ( & self ) -> libc:: c_long {
618
624
self . 0 . f_ffree
619
625
}
@@ -639,6 +645,7 @@ impl Statfs {
639
645
impl Debug for Statfs {
640
646
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
641
647
let mut ds = f. debug_struct ( "Statfs" ) ;
648
+ #[ cfg( not( target_os = "cygwin" ) ) ]
642
649
ds. field ( "optimal_transfer_size" , & self . optimal_transfer_size ( ) ) ;
643
650
ds. field ( "block_size" , & self . block_size ( ) ) ;
644
651
ds. field ( "blocks" , & self . blocks ( ) ) ;
0 commit comments