Skip to content

Commit 59c4dea

Browse files
committed
address review
1 parent 7be67ef commit 59c4dea

1 file changed

Lines changed: 14 additions & 8 deletions

File tree

src/fs/syscalls/mount.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,15 @@ pub async fn sys_mount(
5858
return Ok(0);
5959
}
6060
let mut buf = [0u8; 1024];
61-
let dev_name = UserCStr::from_ptr(dev_name)
62-
.copy_from_user(&mut buf)
63-
.await
64-
.ok();
61+
let dev_name = if dev_name.is_null() {
62+
None
63+
} else {
64+
Some(
65+
UserCStr::from_ptr(dev_name)
66+
.copy_from_user(&mut buf)
67+
.await?,
68+
)
69+
};
6570
let mut buf = [0u8; 1024];
6671
let dir_name = UserCStr::from_ptr(dir_name)
6772
.copy_from_user(&mut buf)
@@ -74,10 +79,11 @@ pub async fn sys_mount(
7479
)
7580
.await?;
7681
let mut buf = [0u8; 1024];
77-
let _type = UserCStr::from_ptr(type_)
78-
.copy_from_user(&mut buf)
79-
.await
80-
.ok();
82+
let _type = if type_.is_null() {
83+
None
84+
} else {
85+
Some(UserCStr::from_ptr(type_).copy_from_user(&mut buf).await?)
86+
};
8187
if let Some(dev_name) = dev_name {
8288
let dev_name = match dev_name {
8389
"proc" => "procfs",

0 commit comments

Comments
 (0)