|
8 | 8 | use clap::{Arg, ArgAction, Command, value_parser}; |
9 | 9 | use nix::libc::{S_IRGRP, S_IROTH, S_IRUSR, S_IWGRP, S_IWOTH, S_IWUSR, mode_t}; |
10 | 10 | use nix::sys::stat::{Mode, SFlag, mknod as nix_mknod, umask as nix_umask}; |
| 11 | +use std::io::{self, Write as _}; |
11 | 12 |
|
12 | 13 | use uucore::display::Quotable; |
13 | 14 | use uucore::error::{UResult, USimpleError, UUsageError, set_exit_code}; |
@@ -94,40 +95,37 @@ fn mknod(file_name: &str, config: Config) -> i32 { |
94 | 95 | } |
95 | 96 |
|
96 | 97 | if let Some(err) = mknod_err { |
97 | | - eprintln!( |
| 98 | + let _ = writeln!( |
| 99 | + io::stderr(), |
98 | 100 | "{}: {}", |
99 | 101 | uucore::execution_phrase(), |
100 | | - std::io::Error::from(err) |
| 102 | + io::Error::from(err) |
101 | 103 | ); |
102 | 104 | } |
103 | 105 |
|
104 | 106 | // Apply SELinux context if requested |
105 | 107 | #[cfg(all(feature = "selinux", any(target_os = "android", target_os = "linux")))] |
106 | 108 | if config.set_security_context { |
107 | | - use std::io::Write as _; |
108 | | - |
109 | 109 | if let Err(e) = uucore::selinux::set_selinux_security_context( |
110 | 110 | std::path::Path::new(file_name), |
111 | 111 | config.context.as_ref(), |
112 | 112 | ) { |
113 | 113 | // if it fails, delete the file |
114 | 114 | let _ = std::fs::remove_file(file_name); |
115 | | - let _ = writeln!(std::io::stderr(), "mknod: {e}"); |
| 115 | + let _ = writeln!(io::stderr(), "mknod: {e}"); |
116 | 116 | return 1; |
117 | 117 | } |
118 | 118 | } |
119 | 119 |
|
120 | 120 | // Apply SMACK context if requested |
121 | 121 | #[cfg(all(feature = "smack", target_os = "linux"))] |
122 | 122 | if config.set_security_context { |
123 | | - use std::io::Write as _; |
124 | | - |
125 | 123 | if let Err(e) = |
126 | 124 | uucore::smack::set_smack_label_and_cleanup(file_name, config.context.as_ref(), |p| { |
127 | 125 | std::fs::remove_file(p) |
128 | 126 | }) |
129 | 127 | { |
130 | | - let _ = writeln!(std::io::stderr(), "mknod: {e}"); |
| 128 | + let _ = writeln!(io::stderr(), "mknod: {e}"); |
131 | 129 | return 1; |
132 | 130 | } |
133 | 131 | } |
|
0 commit comments