Skip to content

feat: allow mounting a virtiofsd share to / #774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: revise getdents64 to be compatible to the Linux system call
  • Loading branch information
stlankes authored and mkroening committed Apr 24, 2024
commit 3773709359d58ab0dfd7359cc1a510fb27e9e514
16 changes: 7 additions & 9 deletions src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ pub unsafe extern "C" fn sys_getdents64(
return -crate::errno::EINVAL as i64;
}

let limit = dirp as usize + count;
const ALIGN_DIRENT: usize = core::mem::align_of::<Dirent64>();
let mut dirp: *mut Dirent64 = dirp;
let mut offset: i64 = 0;
let obj = get_object(fd);
Expand All @@ -442,18 +442,18 @@ pub unsafe extern "C" fn sys_getdents64(
|v| {
for i in v.iter() {
let len = i.name.len();
if dirp as usize + core::mem::size_of::<Dirent64>() + len + 1 >= limit {
let aligned_len = ((core::mem::size_of::<Dirent64>() + len + 1)
+ (ALIGN_DIRENT - 1)) & (!(ALIGN_DIRENT - 1));
if offset as usize + aligned_len >= count {
return -crate::errno::EINVAL as i64;
}

let dir = unsafe { &mut *dirp };

dir.d_ino = 0;
dir.d_type = 0;
dir.d_reclen = (core::mem::size_of::<Dirent64>() + len + 1)
.try_into()
.unwrap();
offset += i64::from(dir.d_reclen);
dir.d_reclen = aligned_len.try_into().unwrap();
offset += i64::try_from(aligned_len).unwrap();
dir.d_off = offset;

// copy null-terminated filename
Expand All @@ -463,9 +463,7 @@ pub unsafe extern "C" fn sys_getdents64(
s.add(len).write_bytes(0, 1);
}

dirp = unsafe {
(dirp as *mut u8).add(dir.d_reclen as usize) as *mut Dirent64
};
dirp = unsafe { (dirp as *mut u8).add(aligned_len) as *mut Dirent64 };
}

offset
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy