-
Notifications
You must be signed in to change notification settings - Fork 17
feat: add rootfsPropagation support and improve error handling #105
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,7 +79,7 @@ parse_mount_options(const std::vector<std::string> &options) | |
| continue; | ||
| } | ||
| if (auto it = propagation_flags_map.find(opt); it != propagation_flags_map.end()) { | ||
| propagation_flags &= it->second; | ||
| propagation_flags |= it->second; | ||
| continue; | ||
| } | ||
|
|
||
|
Comment on lines
79
to
85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The repeated pattern of checking for an option in a map and then setting a flag is a candidate for refactoring to reduce code duplication and improve maintainability. Consider creating a helper function that takes the option, the map, and a reference to the flag variable. This function would encapsulate the logic found in lines 79-85, making the code cleaner and easier to maintain. |
||
|
|
@@ -262,6 +262,21 @@ linyaps_box::config::linux_t parse_linux(const nlohmann::json &obj, | |
| linux.readonly_paths = std::move(readonly_paths); | ||
| } | ||
|
|
||
| if (auto rootfs_propagation = ptr / "rootfsPropagation"; obj.contains(rootfs_propagation)) { | ||
| auto val = obj[rootfs_propagation].get<std::string>(); | ||
| if (val == "shared") { | ||
| linux.rootfs_propagation = MS_SHARED; | ||
| } else if (val == "slave") { | ||
| linux.rootfs_propagation = MS_SLAVE; | ||
| } else if (val == "private") { | ||
| linux.rootfs_propagation = MS_PRIVATE; | ||
| } else if (val == "unbindable") { | ||
| linux.rootfs_propagation = MS_UNBINDABLE; | ||
| } else { | ||
| throw std::runtime_error("unsupported rootfs propagation: " + val); | ||
| } | ||
| } | ||
|
|
||
| return linux; | ||
| } | ||
|
|
||
|
Comment on lines
262
to
282
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The handling of |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,6 +123,7 @@ struct config | |
| std::optional<std::vector<id_mapping_t>> gid_mappings; | ||
| std::optional<std::vector<std::filesystem::path>> masked_paths; | ||
| std::optional<std::vector<std::filesystem::path>> readonly_paths; | ||
|
Comment on lines
123
to
125
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of Recommended Change: |
||
| unsigned int rootfs_propagation{ 0 }; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Recommended Change: |
||
| }; | ||
|
|
||
| std::optional<linux_t> linux; | ||
|
|
||
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.
The error handling for unknown exceptions logs a very generic message, which might not be helpful for diagnosing issues. Consider logging more context-specific information if possible, or at least include a suggestion to check the logs for more details. This could help in troubleshooting and maintaining the application more effectively.
Suggested Improvement: