Skip to content
Snippets Groups Projects
Unverified Commit dc5bd707 authored by Ian Douglas Scott's avatar Ian Douglas Scott
Browse files

futimens: do not require O_RWONLY/O_RDWR

parent fc0af50b
No related branches found
No related tags found
No related merge requests found
......@@ -131,15 +131,17 @@ pub struct FileResource {
block: u64,
flags: usize,
seek: u64,
uid: u32,
}
impl FileResource {
pub fn new(path: String, block: u64, flags: usize, seek: u64) -> FileResource {
pub fn new(path: String, block: u64, flags: usize, seek: u64, uid: u32) -> FileResource {
FileResource {
path: path,
block: block,
flags: flags,
seek: seek,
uid: uid,
}
}
}
......@@ -151,6 +153,7 @@ impl Resource for FileResource {
block: self.block,
flags: self.flags,
seek: self.seek,
uid: self.uid,
}))
}
......@@ -246,9 +249,10 @@ impl Resource for FileResource {
}
fn utimens(&mut self, times: &[TimeSpec], fs: &mut FileSystem) -> Result<usize> {
if self.flags & O_ACCMODE == O_RDWR || self.flags & O_ACCMODE == O_WRONLY {
let mut node = fs.node(self.block)?;
if node.1.uid == self.uid || self.uid == 0 {
if let Some(mtime) = times.get(1) {
let mut node = fs.node(self.block)?;
node.1.mtime = mtime.tv_sec as u64;
node.1.mtime_nsec = mtime.tv_nsec as u32;
......
......@@ -253,7 +253,7 @@ impl Scheme for FileScheme {
0
};
Box::new(FileResource::new(path.to_string(), node.0, flags, seek))
Box::new(FileResource::new(path.to_string(), node.0, flags, seek, uid))
},
None => if flags & O_CREAT == O_CREAT {
let mut last_part = String::new();
......@@ -293,7 +293,7 @@ impl Scheme for FileScheme {
0
};
Box::new(FileResource::new(path.to_string(), node.0, flags, seek))
Box::new(FileResource::new(path.to_string(), node.0, flags, seek, uid))
}
} else {
return Err(Error::new(EPERM));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment