summaryrefslogtreecommitdiff
path: root/ayafs-core/src/filesystem
diff options
context:
space:
mode:
authorChuyan Zhang <me@zcy.moe>2023-12-03 00:58:03 -0800
committerChuyan Zhang <me@zcy.moe>2023-12-03 00:58:03 -0800
commit07c1de41d975459397945f2e6b2b7f5630912175 (patch)
treee8e276a5627f13da255929d671badd0254541260 /ayafs-core/src/filesystem
parent21a9ce8e53224100f331d9a666bc00c630964724 (diff)
downloadmyfs-master.tar.gz
myfs-master.zip
remove some assertions...HEADmaster
Diffstat (limited to 'ayafs-core/src/filesystem')
-rw-r--r--ayafs-core/src/filesystem/trait_impl.rs26
1 files changed, 17 insertions, 9 deletions
diff --git a/ayafs-core/src/filesystem/trait_impl.rs b/ayafs-core/src/filesystem/trait_impl.rs
index 48afac3..922486d 100644
--- a/ayafs-core/src/filesystem/trait_impl.rs
+++ b/ayafs-core/src/filesystem/trait_impl.rs
@@ -6,11 +6,7 @@ use crate::utils::{from_filetype, from_systime, time_now, to_fileattr, to_filety
use crate::{AyaFS, TTL};
use fuser::TimeOrNow::{Now, SpecificTime};
use fuser::{FileType, Filesystem, KernelConfig, ReplyAttr, ReplyData, ReplyDirectory, ReplyEmpty, ReplyEntry, ReplyOpen, ReplyWrite, Request, TimeOrNow, ReplyStatfs, FileAttr, ReplyCreate};
-use libc::{
- c_int, EACCES, EBADF, EEXIST, EINVAL, EIO, EISDIR, ENAMETOOLONG, ENOENT, ENOSPC, ENOTDIR,
- ENOTEMPTY, EPERM, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY, RENAME_EXCHANGE,
- RENAME_NOREPLACE, R_OK, S_ISGID, S_ISUID, S_IXGRP, S_IXOTH, S_IXUSR, W_OK,
-};
+use libc::{c_int, EACCES, EBADF, EEXIST, EINVAL, EIO, EISDIR, ENAMETOOLONG, ENOENT, ENOSPC, ENOTDIR, ENOTEMPTY, EPERM, O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY, RENAME_EXCHANGE, RENAME_NOREPLACE, R_OK, S_ISGID, S_ISUID, S_IXGRP, S_IXOTH, S_IXUSR, W_OK, EFAULT};
use log::{debug, trace};
use std::ffi::OsStr;
use std::os::unix::ffi::OsStrExt;
@@ -167,7 +163,10 @@ impl Filesystem for AyaFS {
let mut inode = inode.clone();
let (inode_index, _read, write) =
self.file_handle_map.get(&file_handle).unwrap();
- assert_eq!(ino as usize, *inode_index);
+ if *inode_index != ino as usize {
+ reply.error(EFAULT);
+ return;
+ }
if !write {
reply.error(EACCES);
} else {
@@ -1114,7 +1113,10 @@ impl Filesystem for AyaFS {
.get(&fh)
.cloned()
.unwrap();
- assert_eq!(inode_num, ino as usize);
+ if inode_num != ino as usize {
+ reply.error(EFAULT);
+ return;
+ }
if let Some(inode) = self.get_inode(ino as usize) {
if inode.is_dir() {
reply.error(EISDIR);
@@ -1194,7 +1196,10 @@ impl Filesystem for AyaFS {
.get(&fh)
.cloned()
.unwrap();
- assert_eq!(inode_num, ino as usize);
+ if inode_num != ino as usize {
+ reply.error(EFAULT);
+ return;
+ }
if let Some(inode) = self.get_inode(inode_num) {
if inode.is_dir() {
reply.error(EISDIR);
@@ -1336,7 +1341,10 @@ impl Filesystem for AyaFS {
offset: i64,
mut reply: ReplyDirectory,
) {
- assert_eq!(self.file_handle_map.get(&fh).unwrap().0, ino as usize);
+ if self.file_handle_map.get(&fh).unwrap().0 != ino as usize {
+ reply.error(EFAULT);
+ return;
+ }
if let Some(inode) = self.get_inode(ino as usize) {
if !inode.is_dir() {
reply.error(ENOTDIR);