Add support for fchdir and support cd for fish
This commit is contained in:
		
							parent
							
								
									a54de67431
								
							
						
					
					
						commit
						1acfec6b12
					
				| @ -1,3 +1,7 @@ | |||||||
| #! /usr/bin/fish | #! /usr/bin/fish | ||||||
| command echo "Hello-world-from-fish" | awk '$1=$1' FS="-" OFS=" " > /root/output.txt | command echo "Hello-world-from-fish" | awk '$1=$1' FS="-" OFS=" " > /root/output.txt | ||||||
| cat /root/output.txt | cat /root/output.txt | ||||||
|  | 
 | ||||||
|  | cd /opt/occlum/glibc/lib | ||||||
|  | /usr/bin/busybox ls -al | ||||||
|  | pwd | ||||||
|  | |||||||
							
								
								
									
										1
									
								
								src/libos/Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
								
								
								
								
								
									
									
								
							
						
						
									
										1
									
								
								src/libos/Cargo.lock
									
									
									
										generated
									
									
									
								
							| @ -411,7 +411,6 @@ dependencies = [ | |||||||
| name = "rcore-fs" | name = "rcore-fs" | ||||||
| version = "0.1.0" | version = "0.1.0" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "bitflags", |  | ||||||
|  "spin", |  "spin", | ||||||
| ] | ] | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -94,7 +94,7 @@ impl<'a> Debug for FsPath<'a> { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /// Get the absolute path by file descriptor
 | /// Get the absolute path by file descriptor
 | ||||||
| fn get_abs_path_by_fd(fd: FileDesc) -> Result<String> { | pub 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() { | ||||||
|  | |||||||
| @ -10,7 +10,7 @@ pub use self::fallocate::do_fallocate; | |||||||
| pub use self::fcntl::{do_fcntl, FcntlCmd}; | pub use self::fcntl::{do_fcntl, FcntlCmd}; | ||||||
| pub use self::file_flags::{AccessMode, CreationFlags, StatusFlags}; | pub use self::file_flags::{AccessMode, CreationFlags, StatusFlags}; | ||||||
| pub use self::flock::{Flock, FlockType}; | pub use self::flock::{Flock, FlockType}; | ||||||
| pub use self::fspath::{FsPath, AT_FDCWD}; | pub use self::fspath::{get_abs_path_by_fd, FsPath, AT_FDCWD}; | ||||||
| pub use self::fsync::{do_fdatasync, do_fsync}; | pub use self::fsync::{do_fdatasync, do_fsync}; | ||||||
| pub use self::getdents::{do_getdents, do_getdents64}; | pub use self::getdents::{do_getdents, do_getdents64}; | ||||||
| pub use self::ioctl::{ | pub use self::ioctl::{ | ||||||
|  | |||||||
| @ -1,8 +1,8 @@ | |||||||
| use super::event_file::EventCreationFlags; | use super::event_file::EventCreationFlags; | ||||||
| use super::file_ops; | use super::file_ops; | ||||||
| use super::file_ops::{ | use super::file_ops::{ | ||||||
|     AccessibilityCheckFlags, AccessibilityCheckMode, ChownFlags, FcntlCmd, FsPath, LinkFlags, |     get_abs_path_by_fd, AccessibilityCheckFlags, AccessibilityCheckMode, ChownFlags, FcntlCmd, | ||||||
|     StatFlags, UnlinkFlags, AT_FDCWD, |     FsPath, LinkFlags, StatFlags, UnlinkFlags, AT_FDCWD, | ||||||
| }; | }; | ||||||
| use super::fs_ops; | use super::fs_ops; | ||||||
| use super::time::{clockid_t, itimerspec_t, ClockID}; | use super::time::{clockid_t, itimerspec_t, ClockID}; | ||||||
| @ -362,6 +362,12 @@ pub fn do_chdir(path: *const i8) -> Result<isize> { | |||||||
|     Ok(0) |     Ok(0) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | pub fn do_fchdir(fd: FileDesc) -> Result<isize> { | ||||||
|  |     let path = get_abs_path_by_fd(fd)?; | ||||||
|  |     fs_ops::do_chdir(&path)?; | ||||||
|  |     Ok(0) | ||||||
|  | } | ||||||
|  | 
 | ||||||
| pub fn do_getcwd(buf_ptr: *mut u8, size: usize) -> Result<isize> { | pub fn do_getcwd(buf_ptr: *mut u8, size: usize) -> Result<isize> { | ||||||
|     let buf = { |     let buf = { | ||||||
|         from_user::check_mut_array(buf_ptr, size)?; |         from_user::check_mut_array(buf_ptr, size)?; | ||||||
|  | |||||||
| @ -23,14 +23,14 @@ use util::mem_util::from_user::*; | |||||||
| use crate::exception::do_handle_exception; | use crate::exception::do_handle_exception; | ||||||
| use crate::fs::{ | use crate::fs::{ | ||||||
|     do_access, do_chdir, do_chmod, do_chown, do_close, do_dup, do_dup2, do_dup3, do_eventfd, |     do_access, do_chdir, do_chmod, do_chown, do_close, do_dup, do_dup2, do_dup3, do_eventfd, | ||||||
|     do_eventfd2, do_faccessat, do_fallocate, do_fchmod, do_fchmodat, do_fchown, do_fchownat, |     do_eventfd2, do_faccessat, do_fallocate, do_fchdir, do_fchmod, do_fchmodat, do_fchown, | ||||||
|     do_fcntl, do_fdatasync, do_fstat, do_fstatat, do_fstatfs, do_fsync, do_ftruncate, do_getcwd, |     do_fchownat, do_fcntl, do_fdatasync, do_fstat, do_fstatat, do_fstatfs, do_fsync, do_ftruncate, | ||||||
|     do_getdents, do_getdents64, do_ioctl, do_lchown, do_link, do_linkat, do_lseek, do_lstat, |     do_getcwd, do_getdents, do_getdents64, do_ioctl, do_lchown, do_link, do_linkat, do_lseek, | ||||||
|     do_mkdir, do_mkdirat, do_mount_rootfs, do_open, do_openat, do_pipe, do_pipe2, do_pread, |     do_lstat, do_mkdir, do_mkdirat, do_mount_rootfs, do_open, do_openat, do_pipe, do_pipe2, | ||||||
|     do_pwrite, do_read, do_readlink, do_readlinkat, do_readv, do_rename, do_renameat, do_rmdir, |     do_pread, do_pwrite, do_read, do_readlink, do_readlinkat, do_readv, do_rename, do_renameat, | ||||||
|     do_sendfile, do_stat, do_statfs, do_symlink, do_symlinkat, do_sync, do_timerfd_create, |     do_rmdir, do_sendfile, do_stat, do_statfs, do_symlink, do_symlinkat, do_sync, | ||||||
|     do_timerfd_gettime, do_timerfd_settime, do_truncate, do_unlink, do_unlinkat, do_write, |     do_timerfd_create, do_timerfd_gettime, do_timerfd_settime, do_truncate, do_unlink, do_unlinkat, | ||||||
|     do_writev, iovec_t, AsTimer, File, FileDesc, FileRef, HostStdioFds, Stat, Statfs, |     do_write, do_writev, iovec_t, AsTimer, File, FileDesc, FileRef, HostStdioFds, Stat, Statfs, | ||||||
| }; | }; | ||||||
| use crate::interrupt::{do_handle_interrupt, sgx_interrupt_info_t}; | use crate::interrupt::{do_handle_interrupt, sgx_interrupt_info_t}; | ||||||
| use crate::misc::{resource_t, rlimit_t, sysinfo_t, utsname_t}; | use crate::misc::{resource_t, rlimit_t, sysinfo_t, utsname_t}; | ||||||
| @ -167,7 +167,7 @@ macro_rules! process_syscall_table_with_callback { | |||||||
|             (Getdents = 78) => do_getdents(fd: FileDesc, buf: *mut u8, buf_size: usize), |             (Getdents = 78) => do_getdents(fd: FileDesc, buf: *mut u8, buf_size: usize), | ||||||
|             (Getcwd = 79) => do_getcwd(buf: *mut u8, size: usize), |             (Getcwd = 79) => do_getcwd(buf: *mut u8, size: usize), | ||||||
|             (Chdir = 80) => do_chdir(path: *const i8), |             (Chdir = 80) => do_chdir(path: *const i8), | ||||||
|             (Fchdir = 81) => handle_unsupported(), |             (Fchdir = 81) => do_fchdir(fd: FileDesc), | ||||||
|             (Rename = 82) => do_rename(oldpath: *const i8, newpath: *const i8), |             (Rename = 82) => do_rename(oldpath: *const i8, newpath: *const i8), | ||||||
|             (Mkdir = 83) => do_mkdir(path: *const i8, mode: usize), |             (Mkdir = 83) => do_mkdir(path: *const i8, mode: usize), | ||||||
|             (Rmdir = 84) => do_rmdir(path: *const i8), |             (Rmdir = 84) => do_rmdir(path: *const i8), | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user