mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-04-01 17:35:13 +08:00
Unify how file mode is specified
The lines of code I commented on in #10254 were meant to serve only as examples of the changes I was requesting, not the only instances. Also just use `Mode::from_bits_truncate()` instead of unsafe or unwrapping since we know the modes are correct.
This commit is contained in:
parent
6877773fdd
commit
99bd2e71d0
@ -341,7 +341,7 @@ fn test_autoload() {
|
||||
let fd = wopen_cloexec(
|
||||
path,
|
||||
OFlag::O_RDWR | OFlag::O_CREAT,
|
||||
Mode::from_bits(0o666).unwrap(),
|
||||
Mode::from_bits_truncate(0o666),
|
||||
)
|
||||
.unwrap();
|
||||
write_loop(&fd, "Hello".as_bytes()).unwrap();
|
||||
|
@ -441,11 +441,7 @@ impl EnvUniversal {
|
||||
|
||||
let mut res_fd = None;
|
||||
while res_fd.is_none() {
|
||||
let fd = match wopen_cloexec(
|
||||
&self.vars_path,
|
||||
flags,
|
||||
Mode::S_IRUSR | Mode::S_IWUSR | Mode::S_IRGRP | Mode::S_IROTH,
|
||||
) {
|
||||
let fd = match wopen_cloexec(&self.vars_path, flags, Mode::from_bits_truncate(0o644)) {
|
||||
Ok(fd) => fd,
|
||||
Err(err) => {
|
||||
if err == nix::Error::EINTR {
|
||||
|
@ -128,7 +128,7 @@ const HISTORY_SAVE_MAX: NonZeroUsize = unsafe { NonZeroUsize::new_unchecked(1024
|
||||
const HISTORY_OUTPUT_BUFFER_SIZE: usize = 64 * 1024;
|
||||
|
||||
/// The file access mode we use for creating history files
|
||||
const HISTORY_FILE_MODE: Mode = Mode::S_IRUSR.union(Mode::S_IWUSR);
|
||||
const HISTORY_FILE_MODE: Mode = Mode::from_bits_truncate(0o600);
|
||||
|
||||
/// How many times we retry to save
|
||||
/// Saving may fail if the file is modified in between our opening
|
||||
|
@ -1007,7 +1007,7 @@ const FILE_ERROR: &wstr = L!("An error occurred while redirecting file '%ls'");
|
||||
const NOCLOB_ERROR: &wstr = L!("The file '%ls' already exists");
|
||||
|
||||
/// Base open mode to pass to calls to open.
|
||||
const OPEN_MASK: Mode = unsafe { Mode::from_bits_unchecked(0o666) };
|
||||
const OPEN_MASK: Mode = Mode::from_bits_truncate(0o666);
|
||||
|
||||
/// Provide the fd monitor used for background fillthread operations.
|
||||
fn fd_monitor() -> &'static mut FdMonitor {
|
||||
|
Loading…
x
Reference in New Issue
Block a user