Skip to content

Commit 131fdf1

Browse files
bors[bot]flxo
andauthored
Merge #1690
1690: Enable statfs magic constants for target_os = "android" r=rtzoeller a=flxo The statfs magic constants of file systems types are available on target_os android and the cfg guard is updated accordingly. Sync the list of constant with the constants declared in libc. Fixes #1689 Co-authored-by: Felix Obenhuber <[email protected]>
2 parents c59a8c8 + 42f671b commit 131fdf1

File tree

2 files changed

+106
-37
lines changed

2 files changed

+106
-37
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ This project adheres to [Semantic Versioning](https://semver.org/).
99
- Added fine-grained features flags. Most Nix functionality can now be
1010
conditionally enabled. By default, all features are enabled.
1111
(#[1611](https://github.com/nix-rust/nix/pull/1611))
12+
- Added statfs FS type magic constants for `target_os = "android"`
13+
and synced constants with libc v0.2.121.
14+
(#[1690](https://github.com/nix-rust/nix/pull/1690))
1215
- Added `fexecve` on DragonFly.
1316
(#[1577](https://github.com/nix-rust/nix/pull/1577))
1417
- `sys::uio::IoVec` is now `Send` and `Sync`

src/sys/statfs.rs

+103-37
Original file line numberDiff line numberDiff line change
@@ -49,96 +49,162 @@ pub struct FsType(pub fs_type_t);
4949

5050
// These constants are defined without documentation in the Linux headers, so we
5151
// can't very well document them here.
52-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
52+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
5353
#[allow(missing_docs)]
5454
pub const ADFS_SUPER_MAGIC: FsType = FsType(libc::ADFS_SUPER_MAGIC as fs_type_t);
55-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
55+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
5656
#[allow(missing_docs)]
5757
pub const AFFS_SUPER_MAGIC: FsType = FsType(libc::AFFS_SUPER_MAGIC as fs_type_t);
58-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
58+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
59+
#[allow(missing_docs)]
60+
pub const AFS_SUPER_MAGIC: FsType = FsType(libc::AFS_SUPER_MAGIC as fs_type_t);
61+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
62+
#[allow(missing_docs)]
63+
pub const AUTOFS_SUPER_MAGIC: FsType = FsType(libc::AUTOFS_SUPER_MAGIC as fs_type_t);
64+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
65+
#[allow(missing_docs)]
66+
pub const BPF_FS_MAGIC: FsType = FsType(libc::BPF_FS_MAGIC as fs_type_t);
67+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
68+
#[allow(missing_docs)]
69+
pub const BTRFS_SUPER_MAGIC: FsType = FsType(libc::BTRFS_SUPER_MAGIC as fs_type_t);
70+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
71+
#[allow(missing_docs)]
72+
pub const CGROUP2_SUPER_MAGIC: FsType = FsType(libc::CGROUP2_SUPER_MAGIC as fs_type_t);
73+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
74+
#[allow(missing_docs)]
75+
pub const CGROUP_SUPER_MAGIC: FsType = FsType(libc::CGROUP_SUPER_MAGIC as fs_type_t);
76+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
5977
#[allow(missing_docs)]
6078
pub const CODA_SUPER_MAGIC: FsType = FsType(libc::CODA_SUPER_MAGIC as fs_type_t);
61-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
79+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
6280
#[allow(missing_docs)]
6381
pub const CRAMFS_MAGIC: FsType = FsType(libc::CRAMFS_MAGIC as fs_type_t);
64-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
82+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
83+
#[allow(missing_docs)]
84+
pub const DEBUGFS_MAGIC: FsType = FsType(libc::DEBUGFS_MAGIC as fs_type_t);
85+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
86+
#[allow(missing_docs)]
87+
pub const DEVPTS_SUPER_MAGIC: FsType = FsType(libc::DEVPTS_SUPER_MAGIC as fs_type_t);
88+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
89+
#[allow(missing_docs)]
90+
pub const ECRYPTFS_SUPER_MAGIC: FsType = FsType(libc::ECRYPTFS_SUPER_MAGIC as fs_type_t);
91+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
6592
#[allow(missing_docs)]
6693
pub const EFS_SUPER_MAGIC: FsType = FsType(libc::EFS_SUPER_MAGIC as fs_type_t);
67-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
94+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
6895
#[allow(missing_docs)]
6996
pub const EXT2_SUPER_MAGIC: FsType = FsType(libc::EXT2_SUPER_MAGIC as fs_type_t);
70-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
97+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
7198
#[allow(missing_docs)]
7299
pub const EXT3_SUPER_MAGIC: FsType = FsType(libc::EXT3_SUPER_MAGIC as fs_type_t);
73-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
100+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
74101
#[allow(missing_docs)]
75102
pub const EXT4_SUPER_MAGIC: FsType = FsType(libc::EXT4_SUPER_MAGIC as fs_type_t);
76-
#[cfg(all(target_os = "linux", not(any(target_env = "musl", target_env = "uclibc"))))]
103+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
104+
#[allow(missing_docs)]
105+
pub const F2FS_SUPER_MAGIC: FsType = FsType(libc::F2FS_SUPER_MAGIC as fs_type_t);
106+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
77107
#[allow(missing_docs)]
78108
pub const FUSE_SUPER_MAGIC: FsType = FsType(libc::FUSE_SUPER_MAGIC as fs_type_t);
79-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
109+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
110+
#[allow(missing_docs)]
111+
pub const FUTEXFS_SUPER_MAGIC: FsType = FsType(libc::FUTEXFS_SUPER_MAGIC as fs_type_t);
112+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
113+
#[allow(missing_docs)]
114+
pub const HOSTFS_SUPER_MAGIC: FsType = FsType(libc::HOSTFS_SUPER_MAGIC as fs_type_t);
115+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
80116
#[allow(missing_docs)]
81117
pub const HPFS_SUPER_MAGIC: FsType = FsType(libc::HPFS_SUPER_MAGIC as fs_type_t);
82-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
118+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
83119
#[allow(missing_docs)]
84120
pub const HUGETLBFS_MAGIC: FsType = FsType(libc::HUGETLBFS_MAGIC as fs_type_t);
85-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
121+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
86122
#[allow(missing_docs)]
87123
pub const ISOFS_SUPER_MAGIC: FsType = FsType(libc::ISOFS_SUPER_MAGIC as fs_type_t);
88-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
124+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
89125
#[allow(missing_docs)]
90126
pub const JFFS2_SUPER_MAGIC: FsType = FsType(libc::JFFS2_SUPER_MAGIC as fs_type_t);
91-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
127+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
92128
#[allow(missing_docs)]
93-
pub const MINIX_SUPER_MAGIC: FsType = FsType(libc::MINIX_SUPER_MAGIC as fs_type_t);
94-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
95-
#[allow(missing_docs)]
96-
pub const MINIX_SUPER_MAGIC2: FsType = FsType(libc::MINIX_SUPER_MAGIC2 as fs_type_t);
97-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
129+
pub const MINIX2_SUPER_MAGIC2: FsType = FsType(libc::MINIX2_SUPER_MAGIC2 as fs_type_t);
130+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
98131
#[allow(missing_docs)]
99132
pub const MINIX2_SUPER_MAGIC: FsType = FsType(libc::MINIX2_SUPER_MAGIC as fs_type_t);
100-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
133+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
101134
#[allow(missing_docs)]
102-
pub const MINIX2_SUPER_MAGIC2: FsType = FsType(libc::MINIX2_SUPER_MAGIC2 as fs_type_t);
103-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
135+
pub const MINIX3_SUPER_MAGIC: FsType = FsType(libc::MINIX3_SUPER_MAGIC as fs_type_t);
136+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
137+
#[allow(missing_docs)]
138+
pub const MINIX_SUPER_MAGIC2: FsType = FsType(libc::MINIX_SUPER_MAGIC2 as fs_type_t);
139+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
140+
#[allow(missing_docs)]
141+
pub const MINIX_SUPER_MAGIC: FsType = FsType(libc::MINIX_SUPER_MAGIC as fs_type_t);
142+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
104143
#[allow(missing_docs)]
105144
pub const MSDOS_SUPER_MAGIC: FsType = FsType(libc::MSDOS_SUPER_MAGIC as fs_type_t);
106-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
145+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
107146
#[allow(missing_docs)]
108147
pub const NCP_SUPER_MAGIC: FsType = FsType(libc::NCP_SUPER_MAGIC as fs_type_t);
109-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
148+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
110149
#[allow(missing_docs)]
111150
pub const NFS_SUPER_MAGIC: FsType = FsType(libc::NFS_SUPER_MAGIC as fs_type_t);
112-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
151+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
152+
#[allow(missing_docs)]
153+
pub const NILFS_SUPER_MAGIC: FsType = FsType(libc::NILFS_SUPER_MAGIC as fs_type_t);
154+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
155+
#[allow(missing_docs)]
156+
pub const OCFS2_SUPER_MAGIC: FsType = FsType(libc::OCFS2_SUPER_MAGIC as fs_type_t);
157+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
113158
#[allow(missing_docs)]
114159
pub const OPENPROM_SUPER_MAGIC: FsType = FsType(libc::OPENPROM_SUPER_MAGIC as fs_type_t);
115-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
160+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
116161
#[allow(missing_docs)]
117162
pub const OVERLAYFS_SUPER_MAGIC: FsType = FsType(libc::OVERLAYFS_SUPER_MAGIC as fs_type_t);
118-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
163+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
119164
#[allow(missing_docs)]
120165
pub const PROC_SUPER_MAGIC: FsType = FsType(libc::PROC_SUPER_MAGIC as fs_type_t);
121-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
166+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
122167
#[allow(missing_docs)]
123168
pub const QNX4_SUPER_MAGIC: FsType = FsType(libc::QNX4_SUPER_MAGIC as fs_type_t);
124-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
169+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
170+
#[allow(missing_docs)]
171+
pub const QNX6_SUPER_MAGIC: FsType = FsType(libc::QNX6_SUPER_MAGIC as fs_type_t);
172+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
173+
#[allow(missing_docs)]
174+
pub const RDTGROUP_SUPER_MAGIC: FsType = FsType(libc::RDTGROUP_SUPER_MAGIC as fs_type_t);
175+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
125176
#[allow(missing_docs)]
126177
pub const REISERFS_SUPER_MAGIC: FsType = FsType(libc::REISERFS_SUPER_MAGIC as fs_type_t);
127-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
178+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
179+
#[allow(missing_docs)]
180+
pub const SECURITYFS_MAGIC: FsType = FsType(libc::SECURITYFS_MAGIC as fs_type_t);
181+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
182+
#[allow(missing_docs)]
183+
pub const SELINUX_MAGIC: FsType = FsType(libc::SELINUX_MAGIC as fs_type_t);
184+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
185+
#[allow(missing_docs)]
186+
pub const SMACK_MAGIC: FsType = FsType(libc::SMACK_MAGIC as fs_type_t);
187+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
128188
#[allow(missing_docs)]
129189
pub const SMB_SUPER_MAGIC: FsType = FsType(libc::SMB_SUPER_MAGIC as fs_type_t);
130-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
190+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
191+
#[allow(missing_docs)]
192+
pub const SYSFS_MAGIC: FsType = FsType(libc::SYSFS_MAGIC as fs_type_t);
193+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
131194
#[allow(missing_docs)]
132195
pub const TMPFS_MAGIC: FsType = FsType(libc::TMPFS_MAGIC as fs_type_t);
133-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
196+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
134197
#[allow(missing_docs)]
135-
pub const USBDEVICE_SUPER_MAGIC: FsType = FsType(libc::USBDEVICE_SUPER_MAGIC as fs_type_t);
136-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
198+
pub const TRACEFS_MAGIC: FsType = FsType(libc::TRACEFS_MAGIC as fs_type_t);
199+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
137200
#[allow(missing_docs)]
138-
pub const CGROUP_SUPER_MAGIC: FsType = FsType(libc::CGROUP_SUPER_MAGIC as fs_type_t);
139-
#[cfg(all(target_os = "linux", not(target_env = "musl")))]
201+
pub const UDF_SUPER_MAGIC: FsType = FsType(libc::UDF_SUPER_MAGIC as fs_type_t);
202+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
140203
#[allow(missing_docs)]
141-
pub const CGROUP2_SUPER_MAGIC: FsType = FsType(libc::CGROUP2_SUPER_MAGIC as fs_type_t);
204+
pub const USBDEVICE_SUPER_MAGIC: FsType = FsType(libc::USBDEVICE_SUPER_MAGIC as fs_type_t);
205+
#[cfg(any(all(target_os = "linux", not(target_env = "musl")), target_os = "android"))]
206+
#[allow(missing_docs)]
207+
pub const XENFS_SUPER_MAGIC: FsType = FsType(libc::XENFS_SUPER_MAGIC as fs_type_t);
142208

143209

144210
impl Statfs {

0 commit comments

Comments
 (0)