-
Notifications
You must be signed in to change notification settings - Fork 30
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
Add mount-boot
command.
#251
Open
silkeh
wants to merge
3
commits into
clearlinux:master
Choose a base branch
from
silkeh:add-mount-boot
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[Unit] | ||
Description=mount @BOOTDIR@ using clr-boot-manager | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
ExecStart=@BINDIR@/clr-boot-manager mount-boot | ||
ExecStop=@BINDIR@/umount @BOOTDIR@ | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
# Write systemd unit | ||
data_conf = configuration_data() | ||
data_conf.set('BINDIR', path_bindir) | ||
data_conf.set('BOOTDIR', with_boot_dir) | ||
|
||
configure_file( | ||
input: 'clr-boot-manager-booted.service.in', | ||
output: 'clr-boot-manager-booted.service', | ||
configuration: data_conf, | ||
install_dir: with_systemd_system_unit_dir, | ||
) | ||
|
||
configure_file( | ||
input: 'clr-boot-manager-mount-boot.service.in', | ||
output: 'clr-boot-manager-mount-boot.service', | ||
configuration: data_conf, | ||
install_dir: with_systemd_system_unit_dir, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* This file is part of clr-boot-manager. | ||
* | ||
* Copyright © 2016-2018 Intel Corporation | ||
* Copyright © 2020 Silke Hofstra | ||
* | ||
* clr-boot-manager is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 | ||
* of the License, or (at your option) any later version. | ||
*/ | ||
|
||
#define _GNU_SOURCE | ||
|
||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
#include "bootman.h" | ||
#include "cli.h" | ||
#include "log.h" | ||
|
||
bool cbm_command_mount_boot(int argc, char **argv) | ||
{ | ||
autofree(char) *root = NULL; | ||
autofree(BootManager) *manager = NULL; | ||
bool forced_image = false; | ||
bool update_efi_vars = false; | ||
autofree(char) *boot_dir = NULL; | ||
int did_mount = -1; | ||
|
||
if (!cli_default_args_init(&argc, &argv, &root, &forced_image, &update_efi_vars)) { | ||
return false; | ||
} | ||
|
||
manager = boot_manager_new(); | ||
if (!manager) { | ||
DECLARE_OOM(); | ||
return false; | ||
} | ||
|
||
boot_manager_set_update_efi_vars(manager, update_efi_vars); | ||
|
||
if (root) { | ||
autofree(char) *realp = NULL; | ||
|
||
realp = realpath(root, NULL); | ||
if (!realp) { | ||
LOG_FATAL("Path specified does not exist: %s", root); | ||
return false; | ||
} | ||
/* Anything not / is image mode */ | ||
if (!streq(realp, "/")) { | ||
boot_manager_set_image_mode(manager, true); | ||
} else { | ||
boot_manager_set_image_mode(manager, forced_image); | ||
} | ||
|
||
/* CBM will check this again, we just needed to check for | ||
* image mode.. */ | ||
if (!boot_manager_set_prefix(manager, root)) { | ||
return false; | ||
} | ||
} else { | ||
boot_manager_set_image_mode(manager, forced_image); | ||
/* Default to "/", bail if it doesn't work. */ | ||
if (!boot_manager_set_prefix(manager, "/")) { | ||
return false; | ||
} | ||
} | ||
|
||
/* Let CBM detect and mount the boot directory */ | ||
did_mount = boot_manager_detect_and_mount_boot(manager, &boot_dir); | ||
return did_mount >= 0; | ||
} | ||
|
||
/* | ||
* Editor modelines - https://www.wireshark.org/tools/modelines.html | ||
* | ||
* Local variables: | ||
* c-basic-offset: 8 | ||
* tab-width: 8 | ||
* indent-tabs-mode: nil | ||
* End: | ||
* | ||
* vi: set shiftwidth=8 tabstop=8 expandtab: | ||
* :indentSize=8:tabSize=8:noTabs=true: | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* This file is part of clr-boot-manager. | ||
* | ||
* Copyright © 2020 Silke Hofstra | ||
* | ||
* clr-boot-manager is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 | ||
* of the License, or (at your option) any later version. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "cli.h" | ||
|
||
bool cbm_command_mount_boot(int argc, char **argv); | ||
|
||
/* | ||
* Editor modelines - https://www.wireshark.org/tools/modelines.html | ||
* | ||
* Local variables: | ||
* c-basic-offset: 8 | ||
* tab-width: 8 | ||
* indent-tabs-mode: nil | ||
* End: | ||
* | ||
* vi: set shiftwidth=8 tabstop=8 expandtab: | ||
* :indentSize=8:tabSize=8:noTabs=true: | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 you can claim copyright on this file.
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.
Actually, this is entirely reasonable.
When you add a new file, or add code that contains substantial amounts of new code authored by your, adding an author/copyright line is very much okay.
Maybe the date should be changed to
2022
, though. Unless it's actually old code that's been circulated before.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.
Looking at my original commit date, this is correct. It has been ready for a while, pending a go-ahead to start integrating
fwupd
for solus.