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