Skip to content

Commit 392c474

Browse files
committed
stat: add feat_selinux cfg alias
1 parent 3edccc6 commit 392c474

4 files changed

Lines changed: 20 additions & 10 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
[lib]
1919
path = "src/stat.rs"
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 = "feat_selinux", any(target_os = "android", target_os = "linux")) },
11+
}
12+
}

src/uu/stat/src/stat.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,8 +1033,8 @@ impl Stater {
10331033
file: &OsString,
10341034
file_type: FileType,
10351035
from_user: bool,
1036-
#[cfg(feature = "selinux")] follow_symbolic_links: bool,
1037-
#[cfg(not(feature = "selinux"))] _: bool,
1036+
#[cfg(selinux)] follow_symbolic_links: bool,
1037+
#[cfg(not(selinux))] _: bool,
10381038
) -> Result<(), i32> {
10391039
match *t {
10401040
Token::Byte(byte) => write_raw_byte(byte),
@@ -1060,10 +1060,7 @@ impl Stater {
10601060
'B' => OutputType::Unsigned(512),
10611061
// SELinux security context string
10621062
'C' => {
1063-
#[cfg(all(
1064-
feature = "selinux",
1065-
any(target_os = "linux", target_os = "android")
1066-
))]
1063+
#[cfg(selinux)]
10671064
{
10681065
if uucore::selinux::is_selinux_enabled() {
10691066
match uucore::selinux::get_selinux_security_context(
@@ -1079,10 +1076,7 @@ impl Stater {
10791076
OutputType::Str(translate!("stat-selinux-unsupported-system"))
10801077
}
10811078
}
1082-
#[cfg(not(all(
1083-
feature = "selinux",
1084-
any(target_os = "linux", target_os = "android")
1085-
)))]
1079+
#[cfg(not(selinux))]
10861080
{
10871081
OutputType::Str(translate!("stat-selinux-unsupported-os"))
10881082
}

0 commit comments

Comments
 (0)