Implement mkdirat
Linux's variant uses the syscall as intended. Redox's variant uses fpath to build a path to pass to mkdir from the file descriptor plus the file name, which isn't atomic due to the fpath lookup being subject to TOCTOU when paired with mkdir.
This commit is contained in:
@@ -502,8 +502,12 @@ impl Pal for Sys {
|
||||
e_raw(unsafe { syscall!(LSEEK, fildes, offset, whence) }).map(|o| o as off_t)
|
||||
}
|
||||
|
||||
fn mkdirat(dir_fildes: c_int, path: CStr, mode: mode_t) -> Result<()> {
|
||||
e_raw(unsafe { syscall!(MKDIRAT, dir_fildes, path.as_ptr(), mode) }).map(|_| ())
|
||||
}
|
||||
|
||||
fn mkdir(path: CStr, mode: mode_t) -> Result<()> {
|
||||
e_raw(unsafe { syscall!(MKDIRAT, AT_FDCWD, path.as_ptr(), mode) }).map(|_| ())
|
||||
Sys::mkdirat(AT_FDCWD, path, mode)
|
||||
}
|
||||
|
||||
fn mknodat(dir_fildes: c_int, path: CStr, mode: mode_t, dev: dev_t) -> Result<()> {
|
||||
|
||||
Reference in New Issue
Block a user