-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
742022e
commit ec7b6f4
Showing
5 changed files
with
76 additions
and
1 deletion.
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
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,16 @@ | ||
#ifndef HWCLOCK_HPP | ||
#define HWCLOCK_HPP | ||
|
||
#include <string_view> // for string_view | ||
|
||
namespace gucc::hwclock { | ||
|
||
// set utc hwclock | ||
auto set_hwclock_utc(std::string_view root_mountpoint) noexcept -> bool; | ||
|
||
// set localtime hwclock | ||
auto set_hwclock_localtime(std::string_view root_mountpoint) noexcept -> bool; | ||
|
||
} // namespace gucc::hwclock | ||
|
||
#endif // HWCLOCK_HPP |
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,42 @@ | ||
#include "gucc/hwclock.hpp" | ||
#include "gucc/io_utils.hpp" | ||
|
||
#include <fmt/compile.h> | ||
#include <fmt/format.h> | ||
|
||
#include <spdlog/spdlog.h> | ||
|
||
using namespace std::string_view_literals; | ||
|
||
namespace gucc::hwclock { | ||
|
||
auto set_hwclock_utc(std::string_view root_mountpoint) noexcept -> bool { | ||
// try default | ||
static constexpr auto hwclock_cmd = "hwclock --systohc --utc"sv; | ||
if (utils::arch_chroot_checked(hwclock_cmd, root_mountpoint)) { | ||
spdlog::info("hwclock UTC set on '{}'", root_mountpoint); | ||
return true; | ||
} | ||
|
||
// try fallback with direct ISA | ||
static constexpr auto hwclock_isa_cmd = "hwclock --systohc --utc --directisa"sv; | ||
if (utils::arch_chroot_checked(hwclock_isa_cmd, root_mountpoint)) { | ||
spdlog::info("hwclock UTC set using direct ISA on '{}'", root_mountpoint); | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
auto set_hwclock_localtime(std::string_view root_mountpoint) noexcept -> bool { | ||
// try default | ||
static constexpr auto hwclock_cmd = "hwclock --systohc --localtime"sv; | ||
if (utils::arch_chroot_checked(hwclock_cmd, root_mountpoint)) { | ||
spdlog::info("hwclock localtime set on '{}'", root_mountpoint); | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
} // namespace gucc::hwclock |
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