From 07c1de41d975459397945f2e6b2b7f5630912175 Mon Sep 17 00:00:00 2001 From: Chuyan Zhang Date: Sun, 3 Dec 2023 00:58:03 -0800 Subject: remove some assertions... --- ayafs-core/src/filesystem/trait_impl.rs | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'ayafs-core/src/filesystem') 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); -- cgit v1.2.3-70-g09d2