From b898e54d7a35c5978ca707b903d04da13060471f Mon Sep 17 00:00:00 2001 From: Jeffrey Finkelstein Date: Fri, 21 May 2021 18:23:50 -0400 Subject: [PATCH] truncate: remove read permissions from OpenOptions Remove "read" permissions from the `OpenOptions` when opening a new file just to truncate it. We will never read from the file, only write to it. (Specifically, we will only call `File::set_len()`.) --- src/uu/truncate/src/truncate.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/uu/truncate/src/truncate.rs b/src/uu/truncate/src/truncate.rs index 03b18723c..086e14858 100644 --- a/src/uu/truncate/src/truncate.rs +++ b/src/uu/truncate/src/truncate.rs @@ -189,12 +189,7 @@ fn truncate( }; for filename in &filenames { let path = Path::new(filename); - match OpenOptions::new() - .read(true) - .write(true) - .create(!no_create) - .open(path) - { + match OpenOptions::new().write(true).create(!no_create).open(path) { Ok(file) => { let fsize = match reference { Some(_) => refsize,