@@ -16,79 +16,85 @@ pub type fsid_t = libc::fsid_t;
16
16
pub struct Statfs ( libc:: statfs ) ;
17
17
18
18
#[ cfg( target_os = "freebsd" ) ]
19
- #[ derive( Eq , Copy , Clone , PartialEq , Debug ) ]
20
- pub struct FsType ( pub u32 ) ;
19
+ type fs_type_t = u32 ;
21
20
#[ cfg( target_os = "android" ) ]
22
- #[ derive( Eq , Copy , Clone , PartialEq , Debug ) ]
23
- pub struct FsType ( pub libc:: c_ulong ) ;
21
+ type fs_type_t = libc:: c_ulong ;
24
22
#[ cfg( all( target_os = "linux" , target_arch = "s390x" ) ) ]
25
- #[ derive( Eq , Copy , Clone , PartialEq , Debug ) ]
26
- pub struct FsType ( pub u32 ) ;
23
+ type fs_type_t = libc:: c_uint ;
27
24
#[ cfg( all( target_os = "linux" , target_env = "musl" ) ) ]
28
- #[ derive( Eq , Copy , Clone , PartialEq , Debug ) ]
29
- pub struct FsType ( pub libc:: c_ulong ) ;
25
+ type fs_type_t = libc:: c_ulong ;
30
26
#[ cfg( all( target_os = "linux" , not( any( target_arch = "s390x" , target_env = "musl" ) ) ) ) ]
27
+ type fs_type_t = libc:: __fsword_t ;
28
+
29
+ #[ cfg( any(
30
+ target_os = "freebsd" ,
31
+ target_os = "android" ,
32
+ all( target_os = "linux" , target_arch = "s390x" ) ,
33
+ all( target_os = "linux" , target_env = "musl" ) ,
34
+ all( target_os = "linux" , not( any( target_arch = "s390x" , target_env = "musl" ) ) ) ,
35
+ ) ) ]
31
36
#[ derive( Eq , Copy , Clone , PartialEq , Debug ) ]
32
- pub struct FsType ( pub libc :: c_long ) ;
37
+ pub struct FsType ( pub fs_type_t ) ;
33
38
34
39
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
35
- pub const ADFS_SUPER_MAGIC : FsType = FsType ( libc:: ADFS_SUPER_MAGIC ) ;
40
+ pub const ADFS_SUPER_MAGIC : FsType = FsType ( libc:: ADFS_SUPER_MAGIC as fs_type_t ) ;
36
41
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
37
- pub const AFFS_SUPER_MAGIC : FsType = FsType ( libc:: AFFS_SUPER_MAGIC ) ;
42
+ pub const AFFS_SUPER_MAGIC : FsType = FsType ( libc:: AFFS_SUPER_MAGIC as fs_type_t ) ;
38
43
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
39
- pub const CODA_SUPER_MAGIC : FsType = FsType ( libc:: CODA_SUPER_MAGIC ) ;
44
+ pub const CODA_SUPER_MAGIC : FsType = FsType ( libc:: CODA_SUPER_MAGIC as fs_type_t ) ;
40
45
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
41
- pub const CRAMFS_MAGIC : FsType = FsType ( libc:: CRAMFS_MAGIC ) ;
46
+ pub const CRAMFS_MAGIC : FsType = FsType ( libc:: CRAMFS_MAGIC as fs_type_t ) ;
42
47
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
43
- pub const EFS_SUPER_MAGIC : FsType = FsType ( libc:: EFS_SUPER_MAGIC ) ;
48
+ pub const EFS_SUPER_MAGIC : FsType = FsType ( libc:: EFS_SUPER_MAGIC as fs_type_t ) ;
44
49
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
45
- pub const EXT2_SUPER_MAGIC : FsType = FsType ( libc:: EXT2_SUPER_MAGIC ) ;
50
+ pub const EXT2_SUPER_MAGIC : FsType = FsType ( libc:: EXT2_SUPER_MAGIC as fs_type_t ) ;
46
51
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
47
- pub const EXT3_SUPER_MAGIC : FsType = FsType ( libc:: EXT3_SUPER_MAGIC ) ;
52
+ pub const EXT3_SUPER_MAGIC : FsType = FsType ( libc:: EXT3_SUPER_MAGIC as fs_type_t ) ;
48
53
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
49
- pub const EXT4_SUPER_MAGIC : FsType = FsType ( libc:: EXT4_SUPER_MAGIC ) ;
54
+ pub const EXT4_SUPER_MAGIC : FsType = FsType ( libc:: EXT4_SUPER_MAGIC as fs_type_t ) ;
50
55
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
51
- pub const HPFS_SUPER_MAGIC : FsType = FsType ( libc:: HPFS_SUPER_MAGIC ) ;
56
+ pub const HPFS_SUPER_MAGIC : FsType = FsType ( libc:: HPFS_SUPER_MAGIC as fs_type_t ) ;
52
57
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
53
- pub const HUGETLBFS_MAGIC : FsType = FsType ( libc:: HUGETLBFS_MAGIC ) ;
58
+ pub const HUGETLBFS_MAGIC : FsType = FsType ( libc:: HUGETLBFS_MAGIC as fs_type_t ) ;
54
59
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
55
- pub const ISOFS_SUPER_MAGIC : FsType = FsType ( libc:: ISOFS_SUPER_MAGIC ) ;
60
+ pub const ISOFS_SUPER_MAGIC : FsType = FsType ( libc:: ISOFS_SUPER_MAGIC as fs_type_t ) ;
56
61
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
57
- pub const JFFS2_SUPER_MAGIC : FsType = FsType ( libc:: JFFS2_SUPER_MAGIC ) ;
62
+ pub const JFFS2_SUPER_MAGIC : FsType = FsType ( libc:: JFFS2_SUPER_MAGIC as fs_type_t ) ;
58
63
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
59
- pub const MINIX_SUPER_MAGIC : FsType = FsType ( libc:: MINIX_SUPER_MAGIC ) ;
64
+ pub const MINIX_SUPER_MAGIC : FsType = FsType ( libc:: MINIX_SUPER_MAGIC as fs_type_t ) ;
60
65
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
61
- pub const MINIX_SUPER_MAGIC2 : FsType = FsType ( libc:: MINIX_SUPER_MAGIC2 ) ;
66
+ pub const MINIX_SUPER_MAGIC2 : FsType = FsType ( libc:: MINIX_SUPER_MAGIC2 as fs_type_t ) ;
62
67
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
63
- pub const MINIX2_SUPER_MAGIC : FsType = FsType ( libc:: MINIX2_SUPER_MAGIC ) ;
68
+ pub const MINIX2_SUPER_MAGIC : FsType = FsType ( libc:: MINIX2_SUPER_MAGIC as fs_type_t ) ;
64
69
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
65
- pub const MINIX2_SUPER_MAGIC2 : FsType = FsType ( libc:: MINIX2_SUPER_MAGIC2 ) ;
70
+ pub const MINIX2_SUPER_MAGIC2 : FsType = FsType ( libc:: MINIX2_SUPER_MAGIC2 as fs_type_t ) ;
66
71
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
67
- pub const MSDOS_SUPER_MAGIC : FsType = FsType ( libc:: MSDOS_SUPER_MAGIC ) ;
72
+ pub const MSDOS_SUPER_MAGIC : FsType = FsType ( libc:: MSDOS_SUPER_MAGIC as fs_type_t ) ;
68
73
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
69
- pub const NCP_SUPER_MAGIC : FsType = FsType ( libc:: NCP_SUPER_MAGIC ) ;
74
+ pub const NCP_SUPER_MAGIC : FsType = FsType ( libc:: NCP_SUPER_MAGIC as fs_type_t ) ;
70
75
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
71
- pub const NFS_SUPER_MAGIC : FsType = FsType ( libc:: NFS_SUPER_MAGIC ) ;
76
+ pub const NFS_SUPER_MAGIC : FsType = FsType ( libc:: NFS_SUPER_MAGIC as fs_type_t ) ;
72
77
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
73
- pub const OPENPROM_SUPER_MAGIC : FsType = FsType ( libc:: OPENPROM_SUPER_MAGIC ) ;
78
+ pub const OPENPROM_SUPER_MAGIC : FsType = FsType ( libc:: OPENPROM_SUPER_MAGIC as fs_type_t ) ;
74
79
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
75
- pub const OVERLAYFS_SUPER_MAGIC : FsType = FsType ( libc:: OVERLAYFS_SUPER_MAGIC ) ;
80
+ pub const OVERLAYFS_SUPER_MAGIC : FsType = FsType ( libc:: OVERLAYFS_SUPER_MAGIC as fs_type_t ) ;
76
81
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
77
- pub const PROC_SUPER_MAGIC : FsType = FsType ( libc:: PROC_SUPER_MAGIC ) ;
82
+ pub const PROC_SUPER_MAGIC : FsType = FsType ( libc:: PROC_SUPER_MAGIC as fs_type_t ) ;
78
83
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
79
- pub const QNX4_SUPER_MAGIC : FsType = FsType ( libc:: QNX4_SUPER_MAGIC ) ;
84
+ pub const QNX4_SUPER_MAGIC : FsType = FsType ( libc:: QNX4_SUPER_MAGIC as fs_type_t ) ;
80
85
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
81
- pub const REISERFS_SUPER_MAGIC : FsType = FsType ( libc:: REISERFS_SUPER_MAGIC ) ;
86
+ pub const REISERFS_SUPER_MAGIC : FsType = FsType ( libc:: REISERFS_SUPER_MAGIC as fs_type_t ) ;
82
87
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
83
- pub const SMB_SUPER_MAGIC : FsType = FsType ( libc:: SMB_SUPER_MAGIC ) ;
88
+ pub const SMB_SUPER_MAGIC : FsType = FsType ( libc:: SMB_SUPER_MAGIC as fs_type_t ) ;
84
89
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
85
- pub const TMPFS_MAGIC : FsType = FsType ( libc:: TMPFS_MAGIC ) ;
90
+ pub const TMPFS_MAGIC : FsType = FsType ( libc:: TMPFS_MAGIC as fs_type_t ) ;
86
91
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
87
- pub const USBDEVICE_SUPER_MAGIC : FsType = FsType ( libc:: USBDEVICE_SUPER_MAGIC ) ;
92
+ pub const USBDEVICE_SUPER_MAGIC : FsType = FsType ( libc:: USBDEVICE_SUPER_MAGIC as fs_type_t ) ;
88
93
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
89
- pub const CGROUP_SUPER_MAGIC : FsType = FsType ( libc:: CGROUP_SUPER_MAGIC ) ;
94
+ pub const CGROUP_SUPER_MAGIC : FsType = FsType ( libc:: CGROUP_SUPER_MAGIC as fs_type_t ) ;
90
95
#[ cfg( all( target_os = "linux" , not( target_env = "musl" ) ) ) ]
91
- pub const CGROUP2_SUPER_MAGIC : FsType = FsType ( libc:: CGROUP2_SUPER_MAGIC ) ;
96
+ pub const CGROUP2_SUPER_MAGIC : FsType = FsType ( libc:: CGROUP2_SUPER_MAGIC as fs_type_t ) ;
97
+
92
98
93
99
impl Statfs {
94
100
/// Magic code defining system type
@@ -138,7 +144,7 @@ impl Statfs {
138
144
139
145
/// Optimal transfer block size
140
146
#[ cfg( all( target_os = "linux" , not( any( target_arch = "s390x" , target_env = "musl" ) ) ) ) ]
141
- pub fn optimal_transfer_size ( & self ) -> libc:: c_long {
147
+ pub fn optimal_transfer_size ( & self ) -> libc:: __fsword_t {
142
148
self . 0 . f_bsize
143
149
}
144
150
@@ -177,7 +183,7 @@ impl Statfs {
177
183
/// Size of a block
178
184
// f_bsize on linux: https://github.com/torvalds/linux/blob/master/fs/nfs/super.c#L471
179
185
#[ cfg( all( target_os = "linux" , not( any( target_arch = "s390x" , target_env = "musl" ) ) ) ) ]
180
- pub fn block_size ( & self ) -> libc:: c_long {
186
+ pub fn block_size ( & self ) -> libc:: __fsword_t {
181
187
self . 0 . f_bsize
182
188
}
183
189
@@ -219,7 +225,7 @@ impl Statfs {
219
225
220
226
/// Maximum length of filenames
221
227
#[ cfg( all( target_os = "linux" , not( any( target_arch = "s390x" , target_env = "musl" ) ) ) ) ]
222
- pub fn maximum_name_length ( & self ) -> libc:: c_long {
228
+ pub fn maximum_name_length ( & self ) -> libc:: __fsword_t {
223
229
self . 0 . f_namelen
224
230
}
225
231
@@ -248,7 +254,7 @@ impl Statfs {
248
254
}
249
255
250
256
/// Total data blocks in filesystem
251
- #[ cfg( all( target_os = "linux" , target_env = "musl" ) ) ]
257
+ #[ cfg( all( target_os = "linux" , any ( target_env = "musl" , all ( target_arch = "x86_64" , target_pointer_width = "32" ) ) ) ) ]
252
258
pub fn blocks ( & self ) -> u64 {
253
259
self . 0 . f_blocks
254
260
}
@@ -261,7 +267,7 @@ impl Statfs {
261
267
target_os = "freebsd" ,
262
268
target_os = "openbsd" ,
263
269
target_os = "dragonfly" ,
264
- all( target_os = "linux" , target_env = "musl" )
270
+ all( target_os = "linux" , any ( target_env = "musl" , all ( target_arch = "x86_64" , target_pointer_width = "32" ) ) )
265
271
) ) ) ]
266
272
pub fn blocks ( & self ) -> libc:: c_ulong {
267
273
self . 0 . f_blocks
@@ -286,7 +292,7 @@ impl Statfs {
286
292
}
287
293
288
294
/// Free blocks in filesystem
289
- #[ cfg( all( target_os = "linux" , target_env = "musl" ) ) ]
295
+ #[ cfg( all( target_os = "linux" , any ( target_env = "musl" , all ( target_arch = "x86_64" , target_pointer_width = "32" ) ) ) ) ]
290
296
pub fn blocks_free ( & self ) -> u64 {
291
297
self . 0 . f_bfree
292
298
}
@@ -299,7 +305,7 @@ impl Statfs {
299
305
target_os = "freebsd" ,
300
306
target_os = "openbsd" ,
301
307
target_os = "dragonfly" ,
302
- all( target_os = "linux" , target_env = "musl" )
308
+ all( target_os = "linux" , any ( target_env = "musl" , all ( target_arch = "x86_64" , target_pointer_width = "32" ) ) )
303
309
) ) ) ]
304
310
pub fn blocks_free ( & self ) -> libc:: c_ulong {
305
311
self . 0 . f_bfree
@@ -324,7 +330,7 @@ impl Statfs {
324
330
}
325
331
326
332
/// Free blocks available to unprivileged user
327
- #[ cfg( all( target_os = "linux" , target_env = "musl" ) ) ]
333
+ #[ cfg( all( target_os = "linux" , any ( target_env = "musl" , all ( target_arch = "x86_64" , target_pointer_width = "32" ) ) ) ) ]
328
334
pub fn blocks_available ( & self ) -> u64 {
329
335
self . 0 . f_bavail
330
336
}
@@ -337,7 +343,7 @@ impl Statfs {
337
343
target_os = "freebsd" ,
338
344
target_os = "openbsd" ,
339
345
target_os = "dragonfly" ,
340
- all( target_os = "linux" , target_env = "musl" )
346
+ all( target_os = "linux" , any ( target_env = "musl" , all ( target_arch = "x86_64" , target_pointer_width = "32" ) ) )
341
347
) ) ) ]
342
348
pub fn blocks_available ( & self ) -> libc:: c_ulong {
343
349
self . 0 . f_bavail
@@ -362,8 +368,8 @@ impl Statfs {
362
368
}
363
369
364
370
/// Total file nodes in filesystem
365
- #[ cfg( all( target_os = "linux" , target_env = "musl" ) ) ]
366
- pub fn files ( & self ) -> u64 {
371
+ #[ cfg( all( target_os = "linux" , any ( target_env = "musl" , all ( target_arch = "x86_64" , target_pointer_width = "32" ) ) ) ) ]
372
+ pub fn files ( & self ) -> libc :: fsfilcnt_t {
367
373
self . 0 . f_files
368
374
}
369
375
@@ -375,7 +381,7 @@ impl Statfs {
375
381
target_os = "freebsd" ,
376
382
target_os = "openbsd" ,
377
383
target_os = "dragonfly" ,
378
- all( target_os = "linux" , target_env = "musl" )
384
+ all( target_os = "linux" , any ( target_env = "musl" , all ( target_arch = "x86_64" , target_pointer_width = "32" ) ) )
379
385
) ) ) ]
380
386
pub fn files ( & self ) -> libc:: c_ulong {
381
387
self . 0 . f_files
@@ -385,7 +391,6 @@ impl Statfs {
385
391
#[ cfg( any(
386
392
target_os = "android" ,
387
393
target_os = "ios" ,
388
- all( target_os = "linux" , target_env = "musl" ) ,
389
394
target_os = "macos" ,
390
395
target_os = "openbsd"
391
396
) ) ]
@@ -405,6 +410,12 @@ impl Statfs {
405
410
self . 0 . f_ffree
406
411
}
407
412
413
+ /// Free file nodes in filesystem
414
+ #[ cfg( all( target_os = "linux" , any( target_env = "musl" , all( target_arch = "x86_64" , target_pointer_width = "32" ) ) ) ) ]
415
+ pub fn files_free ( & self ) -> libc:: fsfilcnt_t {
416
+ self . 0 . f_ffree
417
+ }
418
+
408
419
/// Free file nodes in filesystem
409
420
#[ cfg( not( any(
410
421
target_os = "ios" ,
@@ -413,7 +424,7 @@ impl Statfs {
413
424
target_os = "freebsd" ,
414
425
target_os = "openbsd" ,
415
426
target_os = "dragonfly" ,
416
- all( target_os = "linux" , target_env = "musl" )
427
+ all( target_os = "linux" , any ( target_env = "musl" , all ( target_arch = "x86_64" , target_pointer_width = "32" ) ) )
417
428
) ) ) ]
418
429
pub fn files_free ( & self ) -> libc:: c_ulong {
419
430
self . 0 . f_ffree
0 commit comments