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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

swclock: Use the same file for both saving and loading #560

Closed
wants to merge 1 commit into from

Conversation

snh
Copy link

@snh snh commented Nov 19, 2022

If no path is specified on the command-line when calling swclock, it defaults to saving and loading the last shutdown time from a file named shutdowntime:

#define RC_SHUTDOWNTIME RC_SVCDIR "/shutdowntime"

I noticed swclock wasn't operating as I'd expect on Alpine Linux and went investigating to find that /etc/init.d/swclock was calling swclock with no path defined when saving the time:

swclock --save

But providing the path of @SBINDIR@/openrc-run when loading the time:

swclock --warn @SBINDIR@/openrc-run

Sure enough I found a file named /run/openrc/shutdowntime was being created, though on a tmpfs, and regardless, not being used when loading the time.

This PR updates /etc/init.d/swclock so the same file is used for both - @SBINDIR@/openrc-run. I chose this over using the default, as I've noted that systems such as Alpine Linux are placing shutdowntime in a location backed by tmpfs.

What I am changing hasn't changed in many many years, so either this has been broken for a long time, or I'm misunderstanding how it works, which is entirely possible, apologies if it is the later, I thought a PR rather than Issue would be more worthwhile in-case I am on the right track! 馃槃

Possibly closes #430.

If no path is specified on the command-line when calling swclock, it
defaults to saving and loading the last shutdown time from a file named
shutdowntime.

Looking at the included init script for swclock, /etc/init.d/swclock, it
is calling swclock with no path defined when saving the time:
  swclock --save

But providing the path of @sbindir@/openrc-run when loading the time:
  swclock --warn @sbindir@/openrc-run

This results in the out of the box experience of /etc/init.d/swclock
being ineffective.
@williamh
Copy link
Contributor

williamh commented Dec 7, 2022

You are close. The concern though is that @sbindir@ might be a read-only filesystem.
This works in start() because the call to swclock only reads the date/time, and the call that refers to swclock using @sbindir@/openrc-run is only used if the call on the line above it fails.
A better approach would be to make the location of the file used by swclock user configurable.
I'll open a pr for that.

@williamh williamh mentioned this pull request Dec 7, 2022
@williamh
Copy link
Contributor

williamh commented Dec 8, 2022

This is fixed in #565.

@williamh williamh closed this Dec 8, 2022
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.

swclock saves time in tmpfs
2 participants