mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-22 08:53:29 +00:00
Add syscall creat
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
fa7d0a787f
commit
4101d8328a
@ -15,7 +15,7 @@ support the loading of Linux kernel modules.
|
||||
## System Calls
|
||||
|
||||
At the time of writing,
|
||||
Asterinas implements 130 out of the 310+ system calls
|
||||
Asterinas implements 138 out of the 310+ system calls
|
||||
provided by Linux on x86-64 architecture.
|
||||
|
||||
| Numbers | Names | Is Implemented |
|
||||
@ -49,15 +49,15 @@ provided by Linux on x86-64 architecture.
|
||||
| 26 | msync | ❌ |
|
||||
| 27 | mincore | ❌ |
|
||||
| 28 | madvise | ✅ |
|
||||
| 29 | shmget | ✅ |
|
||||
| 30 | shmat | ✅ |
|
||||
| 31 | shmctl | ✅ |
|
||||
| 29 | shmget | ❌ |
|
||||
| 30 | shmat | ❌ |
|
||||
| 31 | shmctl | ❌ |
|
||||
| 32 | dup | ✅ |
|
||||
| 33 | dup2 | ✅ |
|
||||
| 34 | pause | ✅ |
|
||||
| 35 | nanosleep | ✅ |
|
||||
| 36 | getitimer | ❌ |
|
||||
| 37 | alarm | ❌ |
|
||||
| 37 | alarm | ✅ |
|
||||
| 38 | setitimer | ❌ |
|
||||
| 39 | getpid | ✅ |
|
||||
| 40 | sendfile | ❌ |
|
||||
@ -96,8 +96,8 @@ provided by Linux on x86-64 architecture.
|
||||
| 73 | flock | ❌ |
|
||||
| 74 | fsync | ✅ |
|
||||
| 75 | fdatasync | ❌ |
|
||||
| 76 | truncate | ❌ |
|
||||
| 77 | ftruncate | ❌ |
|
||||
| 76 | truncate | ✅ |
|
||||
| 77 | ftruncate | ✅ |
|
||||
| 78 | getdents | ❌ |
|
||||
| 79 | getcwd | ✅ |
|
||||
| 80 | chdir | ✅ |
|
||||
@ -105,7 +105,7 @@ provided by Linux on x86-64 architecture.
|
||||
| 82 | rename | ✅ |
|
||||
| 83 | mkdir | ✅ |
|
||||
| 84 | rmdir | ✅ |
|
||||
| 85 | creat | ❌ |
|
||||
| 85 | creat | ✅ |
|
||||
| 86 | link | ✅ |
|
||||
| 87 | unlink | ✅ |
|
||||
| 88 | symlink | ✅ |
|
||||
@ -160,8 +160,8 @@ provided by Linux on x86-64 architecture.
|
||||
| 137 | statfs | ✅ |
|
||||
| 138 | fstatfs | ✅ |
|
||||
| 139 | sysfs | ❌ |
|
||||
| 140 | getpriority | ❌ |
|
||||
| 141 | setpriority | ❌ |
|
||||
| 140 | getpriority | ✅ |
|
||||
| 141 | setpriority | ✅ |
|
||||
| 142 | sched_setparam | ❌ |
|
||||
| 143 | sched_getparam | ❌ |
|
||||
| 144 | sched_setscheduler | ❌ |
|
||||
|
@ -114,7 +114,12 @@ impl FsResolver {
|
||||
Err(e) => return Err(e),
|
||||
};
|
||||
|
||||
if creation_flags.contains(CreationFlags::O_TRUNC) {
|
||||
dentry.resize(0)?;
|
||||
}
|
||||
|
||||
let inode_handle = InodeHandle::new(dentry, access_mode, status_flags)?;
|
||||
|
||||
Ok(inode_handle)
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ use crate::syscall::{
|
||||
mprotect::sys_mprotect,
|
||||
munmap::sys_munmap,
|
||||
nanosleep::{sys_clock_nanosleep, sys_nanosleep},
|
||||
open::{sys_open, sys_openat},
|
||||
open::{sys_creat, sys_open, sys_openat},
|
||||
pause::sys_pause,
|
||||
pipe::{sys_pipe, sys_pipe2},
|
||||
poll::sys_poll,
|
||||
@ -172,6 +172,7 @@ impl_syscall_nums_and_dispatch_fn! {
|
||||
SYS_RENAME = 82 => sys_rename(args[..2]);
|
||||
SYS_MKDIR = 83 => sys_mkdir(args[..2]);
|
||||
SYS_RMDIR = 84 => sys_rmdir(args[..1]);
|
||||
SYS_CREAT = 85 => sys_creat(args[..2]);
|
||||
SYS_LINK = 86 => sys_link(args[..2]);
|
||||
SYS_UNLINK = 87 => sys_unlink(args[..1]);
|
||||
SYS_SYMLINK = 88 => sys_symlink(args[..2]);
|
||||
|
@ -6,7 +6,7 @@ use crate::{
|
||||
file_handle::FileLike,
|
||||
file_table::{FdFlags, FileDesc},
|
||||
fs_resolver::{FsPath, AT_FDCWD},
|
||||
utils::CreationFlags,
|
||||
utils::{AccessMode, CreationFlags},
|
||||
},
|
||||
prelude::*,
|
||||
syscall::constants::MAX_FILENAME_LEN,
|
||||
@ -50,6 +50,12 @@ pub fn sys_open(path_addr: Vaddr, flags: u32, mode: u16) -> Result<SyscallReturn
|
||||
self::sys_openat(AT_FDCWD, path_addr, flags, mode)
|
||||
}
|
||||
|
||||
pub fn sys_creat(path_addr: Vaddr, mode: u16) -> Result<SyscallReturn> {
|
||||
let flags =
|
||||
AccessMode::O_WRONLY as u32 | CreationFlags::O_CREAT.bits() | CreationFlags::O_TRUNC.bits();
|
||||
self::sys_openat(AT_FDCWD, path_addr, flags, mode)
|
||||
}
|
||||
|
||||
/// File for output busybox ash log.
|
||||
struct BusyBoxTraceFile;
|
||||
|
||||
|
@ -10,6 +10,7 @@ TESTS ?= \
|
||||
chmod_test \
|
||||
chown_test \
|
||||
chroot_test \
|
||||
creat_test \
|
||||
epoll_test \
|
||||
eventfd_test \
|
||||
fsync_test \
|
||||
|
Reference in New Issue
Block a user