Polish the function names in FS

This commit is contained in:
LI Qing 2021-01-11 18:47:06 +08:00 committed by Tate, Hongliang Tian
parent d6cd89f03b
commit 8bfef4086f
12 changed files with 36 additions and 36 deletions

@ -29,7 +29,7 @@ impl EventFile {
}) })
} }
pub fn get_host_fd(&self) -> c_int { pub fn host_fd(&self) -> c_int {
self.host_fd.to_raw() as c_int self.host_fd.to_raw() as c_int
} }
} }
@ -73,12 +73,12 @@ impl File for EventFile {
Ok(ret) Ok(ret)
} }
fn get_access_mode(&self) -> Result<AccessMode> { fn access_mode(&self) -> Result<AccessMode> {
Ok(AccessMode::O_RDWR) Ok(AccessMode::O_RDWR)
} }
fn get_status_flags(&self) -> Result<StatusFlags> { fn status_flags(&self) -> Result<StatusFlags> {
let ret = try_libc!(libc::ocall::fcntl_arg0(self.get_host_fd(), libc::F_GETFL)); let ret = try_libc!(libc::ocall::fcntl_arg0(self.host_fd(), libc::F_GETFL));
Ok(StatusFlags::from_bits_truncate(ret as u32)) Ok(StatusFlags::from_bits_truncate(ret as u32))
} }
@ -90,7 +90,7 @@ impl File for EventFile {
| StatusFlags::O_NONBLOCK; | StatusFlags::O_NONBLOCK;
let raw_status_flags = (new_status_flags & valid_flags_mask).bits(); let raw_status_flags = (new_status_flags & valid_flags_mask).bits();
try_libc!(libc::ocall::fcntl_arg1( try_libc!(libc::ocall::fcntl_arg1(
self.get_host_fd(), self.host_fd(),
libc::F_SETFL, libc::F_SETFL,
raw_status_flags as c_int raw_status_flags as c_int
)); ));

@ -71,12 +71,12 @@ pub trait File: Debug + Sync + Send + Any {
return_op_unsupported_error!("ioctl") return_op_unsupported_error!("ioctl")
} }
fn get_access_mode(&self) -> Result<AccessMode> { fn access_mode(&self) -> Result<AccessMode> {
return_op_unsupported_error!("get_access_mode") return_op_unsupported_error!("access_mode")
} }
fn get_status_flags(&self) -> Result<StatusFlags> { fn status_flags(&self) -> Result<StatusFlags> {
return_op_unsupported_error!("get_status_flags") return_op_unsupported_error!("status_flags")
} }
fn set_status_flags(&self, new_status_flags: StatusFlags) -> Result<()> { fn set_status_flags(&self, new_status_flags: StatusFlags) -> Result<()> {

@ -82,8 +82,8 @@ pub fn do_fcntl(fd: FileDesc, cmd: &mut FcntlCmd) -> Result<isize> {
} }
FcntlCmd::GetFl() => { FcntlCmd::GetFl() => {
let file = file_table.get(fd)?; let file = file_table.get(fd)?;
let status_flags = file.get_status_flags()?; let status_flags = file.status_flags()?;
let access_mode = file.get_access_mode()?; let access_mode = file.access_mode()?;
(status_flags.bits() | access_mode as u32) as isize (status_flags.bits() | access_mode as u32) as isize
} }
FcntlCmd::SetFl(flags) => { FcntlCmd::SetFl(flags) => {

@ -98,7 +98,7 @@ fn get_abs_path_by_fd(fd: FileDesc) -> Result<String> {
let path = { let path = {
let file_ref = current!().file(fd)?; let file_ref = current!().file(fd)?;
if let Ok(inode_file) = file_ref.as_inode_file() { if let Ok(inode_file) = file_ref.as_inode_file() {
inode_file.get_abs_path().to_owned() inode_file.abs_path().to_owned()
} else { } else {
return_errno!(EBADF, "not an inode file"); return_errno!(EBADF, "not an inode file");
} }

@ -143,7 +143,11 @@ impl FsView {
/// Lookup INode from the cwd of the process. If path is a symlink, do not dereference it /// Lookup INode from the cwd of the process. If path is a symlink, do not dereference it
pub fn lookup_inode_no_follow(&self, path: &str) -> Result<Arc<dyn INode>> { pub fn lookup_inode_no_follow(&self, path: &str) -> Result<Arc<dyn INode>> {
debug!("lookup_inode: cwd: {:?}, path: {:?}", self.cwd(), path); debug!(
"lookup_inode_no_follow: cwd: {:?}, path: {:?}",
self.cwd(),
path
);
let (dir_path, file_name) = split_path(&path); let (dir_path, file_name) = split_path(&path);
let dir_inode = self.lookup_inode(dir_path)?; let dir_inode = self.lookup_inode(dir_path)?;
Ok(dir_inode.lookup(file_name)?) Ok(dir_inode.lookup(file_name)?)
@ -154,11 +158,7 @@ impl FsView {
// Linux uses 40 as the upper limit for resolving symbolic links, // Linux uses 40 as the upper limit for resolving symbolic links,
// so Occlum use it as a reasonable value // so Occlum use it as a reasonable value
const MAX_SYMLINKS: usize = 40; const MAX_SYMLINKS: usize = 40;
debug!( debug!("lookup_inode: cwd: {:?}, path: {:?}", self.cwd(), path);
"lookup_inode_follow: cwd: {:?}, path: {:?}",
self.cwd(),
path
);
if path.len() > 0 && path.as_bytes()[0] == b'/' { if path.len() > 0 && path.as_bytes()[0] == b'/' {
// absolute path // absolute path
let abs_path = path.trim_start_matches('/'); let abs_path = path.trim_start_matches('/');

@ -149,11 +149,11 @@ impl File for INodeFile {
Ok(name) Ok(name)
} }
fn get_access_mode(&self) -> Result<AccessMode> { fn access_mode(&self) -> Result<AccessMode> {
Ok(self.access_mode.clone()) Ok(self.access_mode.clone())
} }
fn get_status_flags(&self) -> Result<StatusFlags> { fn status_flags(&self) -> Result<StatusFlags> {
let status_flags = self.status_flags.read().unwrap(); let status_flags = self.status_flags.read().unwrap();
Ok(status_flags.clone()) Ok(status_flags.clone())
} }
@ -238,7 +238,7 @@ impl INodeFile {
}) })
} }
pub fn get_abs_path(&self) -> &str { pub fn abs_path(&self) -> &str {
&self.abs_path &self.abs_path
} }
} }

@ -44,11 +44,11 @@ impl File for PipeReader {
self.consumer.pop_slices(bufs) self.consumer.pop_slices(bufs)
} }
fn get_access_mode(&self) -> Result<AccessMode> { fn access_mode(&self) -> Result<AccessMode> {
Ok(AccessMode::O_RDONLY) Ok(AccessMode::O_RDONLY)
} }
fn get_status_flags(&self) -> Result<StatusFlags> { fn status_flags(&self) -> Result<StatusFlags> {
let status_flags = self.status_flags.load(Ordering::Acquire); let status_flags = self.status_flags.load(Ordering::Acquire);
Ok(status_flags.clone()) Ok(status_flags.clone())
} }
@ -107,11 +107,11 @@ impl File for PipeWriter {
return_errno!(ESPIPE, "Pipe does not support seek") return_errno!(ESPIPE, "Pipe does not support seek")
} }
fn get_access_mode(&self) -> Result<AccessMode> { fn access_mode(&self) -> Result<AccessMode> {
Ok(AccessMode::O_WRONLY) Ok(AccessMode::O_WRONLY)
} }
fn get_status_flags(&self) -> Result<StatusFlags> { fn status_flags(&self) -> Result<StatusFlags> {
let status_flags = self.status_flags.load(Ordering::Acquire); let status_flags = self.status_flags.load(Ordering::Acquire);
Ok(status_flags.clone()) Ok(status_flags.clone())
} }

@ -96,7 +96,7 @@ impl StdoutFile {
} }
} }
fn get_host_fd(&self) -> FileDesc { fn host_fd(&self) -> FileDesc {
self.host_fd self.host_fd
} }
} }
@ -181,7 +181,7 @@ impl File for StdoutFile {
let cmd_bits = cmd.cmd_num() as c_int; let cmd_bits = cmd.cmd_num() as c_int;
let cmd_arg_ptr = cmd.arg_ptr() as *mut c_void; let cmd_arg_ptr = cmd.arg_ptr() as *mut c_void;
let host_stdout_fd = self.get_host_fd() as i32; let host_stdout_fd = self.host_fd() as i32;
let cmd_arg_len = cmd.arg_len(); let cmd_arg_len = cmd.arg_len();
let ret = try_libc!({ let ret = try_libc!({
let mut retval: i32 = 0; let mut retval: i32 = 0;
@ -258,7 +258,7 @@ impl StdinFile {
} }
} }
fn get_host_fd(&self) -> FileDesc { fn host_fd(&self) -> FileDesc {
self.host_fd self.host_fd
} }
} }
@ -330,7 +330,7 @@ impl File for StdinFile {
let cmd_bits = cmd.cmd_num() as c_int; let cmd_bits = cmd.cmd_num() as c_int;
let cmd_arg_ptr = cmd.arg_ptr() as *mut c_void; let cmd_arg_ptr = cmd.arg_ptr() as *mut c_void;
let host_stdin_fd = self.get_host_fd() as i32; let host_stdin_fd = self.host_fd() as i32;
let cmd_arg_len = cmd.arg_len(); let cmd_arg_len = cmd.arg_len();
let ret = try_libc!({ let ret = try_libc!({
let mut retval: i32 = 0; let mut retval: i32 = 0;

@ -116,7 +116,7 @@ pub fn do_poll(pollfds: &mut [PollEvent], timeout: *mut timeval_t) -> Result<usi
index_host_pollfds.push(i); index_host_pollfds.push(i);
host_pollfds.push(PollEvent::new(fd, pollfd.events())); host_pollfds.push(PollEvent::new(fd, pollfd.events()));
} else if let Ok(eventfd) = file_ref.as_event() { } else if let Ok(eventfd) = file_ref.as_event() {
let fd = eventfd.get_host_fd() as FileDesc; let fd = eventfd.host_fd() as FileDesc;
index_host_pollfds.push(i); index_host_pollfds.push(i);
host_pollfds.push(PollEvent::new(fd, pollfd.events())); host_pollfds.push(PollEvent::new(fd, pollfd.events()));
} else { } else {
@ -129,7 +129,7 @@ pub fn do_poll(pollfds: &mut [PollEvent], timeout: *mut timeval_t) -> Result<usi
.unwrap() .unwrap()
.get(&current.tid()) .get(&current.tid())
.unwrap() .unwrap()
.get_host_fd(); .host_fd();
debug!( debug!(
"number of ready libos fd is {}; notifier_host_fd is {}", "number of ready libos fd is {}; notifier_host_fd is {}",

@ -50,11 +50,11 @@ impl File for HostSocket {
self.ioctl_impl(cmd) self.ioctl_impl(cmd)
} }
fn get_access_mode(&self) -> Result<AccessMode> { fn access_mode(&self) -> Result<AccessMode> {
Ok(AccessMode::O_RDWR) Ok(AccessMode::O_RDWR)
} }
fn get_status_flags(&self) -> Result<StatusFlags> { fn status_flags(&self) -> Result<StatusFlags> {
let ret = try_libc!(libc::ocall::fcntl_arg0( let ret = try_libc!(libc::ocall::fcntl_arg0(
self.raw_host_fd() as i32, self.raw_host_fd() as i32,
libc::F_GETFL libc::F_GETFL

@ -60,11 +60,11 @@ impl File for Stream {
} }
} }
fn get_access_mode(&self) -> Result<AccessMode> { fn access_mode(&self) -> Result<AccessMode> {
Ok(AccessMode::O_RDWR) Ok(AccessMode::O_RDWR)
} }
fn get_status_flags(&self) -> Result<StatusFlags> { fn status_flags(&self) -> Result<StatusFlags> {
if self.nonblocking() { if self.nonblocking() {
Ok(StatusFlags::O_NONBLOCK) Ok(StatusFlags::O_NONBLOCK)
} else { } else {

@ -603,7 +603,7 @@ impl VMManager {
Some((file_and_offset)) => file_and_offset, Some((file_and_offset)) => file_and_offset,
}; };
let file_writable = file let file_writable = file
.get_access_mode() .access_mode()
.map(|ac| ac.writable()) .map(|ac| ac.writable())
.unwrap_or_default(); .unwrap_or_default();
if !file_writable { if !file_writable {