Skip to content

Commit ecb53c8

Browse files
committed
stat: add selinux cfg alias
1 parent 37d27e0 commit ecb53c8

4 files changed

Lines changed: 20 additions & 12 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/uu/stat/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ workspace = true
1818
path = "src/stat.rs"
1919
doctest = false
2020

21+
[build-dependencies]
22+
cfg_aliases.workspace = true
23+
2124
[dependencies]
2225
clap = { workspace = true }
2326
uucore = { workspace = true, features = [

src/uu/stat/build.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This file is part of the uutils coreutils package.
2+
//
3+
// For the full copyright and license information, please view the LICENSE
4+
// file that was distributed with this source code.
5+
6+
use cfg_aliases::cfg_aliases;
7+
8+
pub fn main() {
9+
cfg_aliases! {
10+
selinux: { all(feature = "selinux", any(target_os = "android", target_os = "linux")) },
11+
}
12+
}

src/uu/stat/src/stat.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,10 +1033,8 @@ impl Stater {
10331033
file: &OsString,
10341034
file_type: FileType,
10351035
from_user: bool,
1036-
#[cfg(all(feature = "selinux", any(target_os = "linux", target_os = "android")))]
1037-
follow_symbolic_links: bool,
1038-
#[cfg(not(all(feature = "selinux", any(target_os = "linux", target_os = "android"))))]
1039-
_: bool,
1036+
#[cfg(selinux)] follow_symbolic_links: bool,
1037+
#[cfg(not(selinux))] _: bool,
10401038
) -> Result<(), i32> {
10411039
match *t {
10421040
Token::Byte(byte) => write_raw_byte(byte),
@@ -1062,10 +1060,7 @@ impl Stater {
10621060
'B' => OutputType::Unsigned(512),
10631061
// SELinux security context string
10641062
'C' => {
1065-
#[cfg(all(
1066-
feature = "selinux",
1067-
any(target_os = "linux", target_os = "android")
1068-
))]
1063+
#[cfg(selinux)]
10691064
{
10701065
if uucore::selinux::is_selinux_enabled() {
10711066
match uucore::selinux::get_selinux_security_context(
@@ -1081,10 +1076,7 @@ impl Stater {
10811076
OutputType::Str(translate!("stat-selinux-unsupported-system"))
10821077
}
10831078
}
1084-
#[cfg(not(all(
1085-
feature = "selinux",
1086-
any(target_os = "linux", target_os = "android")
1087-
)))]
1079+
#[cfg(not(selinux))]
10881080
{
10891081
OutputType::Str(translate!("stat-selinux-unsupported-os"))
10901082
}

0 commit comments

Comments
 (0)