-
Notifications
You must be signed in to change notification settings - Fork 58
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
reorganize code and add an unit test #354
Conversation
Reorganize the code to make the structure clearer. Specifically: - erofs_common.*: contains some common content used internally by EROFS, such as I/O controllers and constants; - liberofs.*: contains the content for creating EROFS filesystem images; - erofs_fs.*: contains the content for building the EROFS filesystem from EROFS filesystem images and performing operations on the filesystem. Additional changes: - rename `min` to `erofs_min` to avoid conflicts with `std::min`; - declare erofs_check_fs() and erofs_create_fs() as extern in comm_func.cpp, as including erofs_fs.h at this point leads to conflicts. Subsequent patches will clean up erofs_fs.h to allow it to be included by third parties (hide content related to liberofs to avoid conflicts). No other changes were made. Signed-off-by: Hongzhen Luo <[email protected]>
src/overlaybd/tar/erofs/erofs_fs.cpp
Outdated
struct erofs_fs_private { | ||
struct erofs_sb_info sbi; | ||
struct liberofs_file target_file; | ||
unsigned long magic = LIBEROFS_MAGIC; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the exact use of this field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the exact use of this fields?
The ErofsFileSystem needs to be associated with the erofs_superblock and the I/O controller, so this information has been packaged here. The same goes for ErofsFile. The reason for this approach is to avoid including items like erofs_superblock in erofs_fs.h.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean what's the uses of magic
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a double check for pointer conversion using reinterpret_cast.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's useful
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. This field is removed.
src/overlaybd/tar/erofs/erofs_fs.h
Outdated
|
||
class ErofsFileSystem: public photon::fs::IFileSystem { | ||
public: | ||
struct erofs_sb_info sbi; | ||
struct liberofs_file target_file; | ||
void *fs_private; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could just
..
private:
struct ErofsFileSystemInt;
ErofsFileSystemInt *private;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/overlaybd/tar/erofs/erofs_fs.h
Outdated
@@ -61,7 +58,7 @@ class ErofsFileSystem: public photon::fs::IFileSystem { | |||
class ErofsFile: public photon::fs::VirtualReadOnlyFile { | |||
public: | |||
ErofsFileSystem *fs; | |||
struct erofs_inode inode; | |||
void *file_private; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you could just
...
private:
struct ErofsFileInt;
ErofsFileInt *private;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I will give it a try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Hide the parts related to liberofs in erofs_fs.h so that erofs_fs.h can be included. Signed-off-by: Hongzhen Luo <[email protected]>
Add an unit test for the internal ErofsCache. Signed-off-by: Hongzhen Luo <[email protected]>
LGTM |
What this PR does / why we need it:
Reorganize the code to make the structure clearer. And also add an unit test for the internal ErofsCache.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #
Please check the following list: