eminence / procfs

Rust library for reading the Linux procfs filesystem
Other
367 stars 106 forks source link

Permission denied for write-only files. #118

Closed phiresky closed 3 years ago

phiresky commented 3 years ago

procfs::sys::vm::drop_caches(procfs::sys::vm::DropCache::All) fails for me with "Permission denied" (even when running as root as needed). The reason I think is that that file cannot be read (sudo cat /proc/sys/vm/drop_caches shows the same error), only written to (echo 3 | sudo tee /proc/sys/vm/drop_caches works).

phiresky commented 3 years ago

The following works correctly:

std::fs::OpenOptions::new()
            .read(false)
            .write(true)
            .open("/proc/sys/vm/drop_caches")?
            .write_all(b"3")?;
eminence commented 3 years ago

Nice catch, thanks!