Skip to content
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

[check for #426] Use AsBytes for copy_in, read_kernel #460

Closed
wants to merge 6 commits into from
Closed

[check for #426] Use AsBytes for copy_in, read_kernel #460

wants to merge 6 commits into from

Conversation

coolofficials
Copy link
Collaborator

issue #426 의 의미를 파악하기 위한 draft pr 입니다.

@coolofficials coolofficials mentioned this pull request Mar 28, 2021
@@ -185,7 +186,11 @@ pub struct InodeGuard<'a> {
pub inode: &'a Inode,
}

#[derive(Default)]
// It needs repr(C) for deriving zerocopy::AsBytes trait.
// DIRSIZ should match conditions for AsBytes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DIRSIZ가 많이 커질 일은 없겠지만 그래도 AsBytes의 조건을 만족해야하기 때문에 명시했습니다.

@@ -185,7 +186,11 @@ pub struct InodeGuard<'a> {
pub inode: &'a Inode,
}

#[derive(Default)]
// It needs repr(C) for deriving zerocopy::AsBytes trait.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AsBytesderive 한 다른 타입들은 이미 repr(C)였기 때문에 AsBytes를 위해 repr(C)를 추가한 Dirent에만 이 코멘트를 추가했습니다.

@@ -30,6 +30,7 @@ array-macro = "2.0.0"
static_assertions = "1.1.0"
itertools = { version = "0.10.0", default-features = false }
pin-project = "1"
zerocopy = { version = "0.3.0", default-features = false }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

최신 버전은 0.4.0이지만 documentation은 0.3.0까지만 되어 있어서 0.3.0을 사용했습니다.

@coolofficials coolofficials changed the title [check for #426] Use AsBytes for copy_in [check for #426] Use AsBytes for copy_in, read_kernel Mar 28, 2021
Comment on lines 414 to +417
/// # Safety
///
/// `T` can be safely `transmute`d to `[u8; size_of::<T>()]`.
pub unsafe fn read_kernel<T>(&mut self, dst: &mut T, off: u32) -> Result<(), ()> {
/// https://docs.rs/zerocopy/0.3.0/zerocopy/trait.AsBytes.html
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsafe가 없어졌어도 Safety 코멘트를 남겨야 할 것 같아서 두었습니다. 대신 이걸 사용한 곳에서는 제거했습니다.
copy_in도 마찬가지입니다.

@coolofficials
Copy link
Collaborator Author

현재 확인한 바로는 fs::FileName 쪽에 FromBytesAsBytes를 이용하여 수정할 부분이 있는 것으로 판단됩니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant