Rename livefs → apply-live in more places

Keep up the renaming momentum by using the new name in more
places.

Prep for further work.
This commit is contained in:
Colin Walters 2021-01-11 23:18:17 +00:00 committed by OpenShift Merge Robot
parent 2247e7af62
commit 6c66bf1072
6 changed files with 24 additions and 24 deletions

View File

@ -43,7 +43,7 @@ librpmostreed_sources = \
src/daemon/rpmostreed-transaction.cxx \ src/daemon/rpmostreed-transaction.cxx \
src/daemon/rpmostreed-transaction-types.h \ src/daemon/rpmostreed-transaction-types.h \
src/daemon/rpmostreed-transaction-types.cxx \ src/daemon/rpmostreed-transaction-types.cxx \
src/daemon/rpmostreed-transaction-livefs.cxx \ src/daemon/rpmostreed-transaction-applylive.cxx \
src/daemon/rpmostree-package-variants.h \ src/daemon/rpmostree-package-variants.h \
src/daemon/rpmostree-package-variants.cxx \ src/daemon/rpmostree-package-variants.cxx \
src/daemon/rpmostreed-os.h \ src/daemon/rpmostreed-os.h \

View File

@ -134,7 +134,7 @@ command that enables local initramfs generation.
### Experimental interface ### Experimental interface
There is a generic `rpm-ostree ex` command that offers experimental features. There is a generic `rpm-ostree ex` command that offers experimental features.
One of those is `rpm-ostree ex livefs`, which offers the ability to apply One of those is `rpm-ostree ex apply-live`, which offers the ability to apply
changes from the pending deployment to the booted deployment. changes from the pending deployment to the booted deployment.
See `man rpm-ostree` for more information. See `man rpm-ostree` for more information.

View File

@ -96,7 +96,7 @@ mod ffi {
commit: String, commit: String,
} }
// livefs.rs // live.rs
extern "Rust" { extern "Rust" {
fn get_live_apply_state( fn get_live_apply_state(
sysroot: Pin<&mut OstreeSysroot>, sysroot: Pin<&mut OstreeSysroot>,
@ -107,7 +107,7 @@ mod ffi {
deployment: Pin<&mut OstreeDeployment>, deployment: Pin<&mut OstreeDeployment>,
) -> Result<bool>; ) -> Result<bool>;
// FIXME/cxx make this Option<&str> // FIXME/cxx make this Option<&str>
fn transaction_livefs(sysroot: Pin<&mut OstreeSysroot>, target: &str) -> Result<()>; fn transaction_apply_live(sysroot: Pin<&mut OstreeSysroot>, target: &str) -> Result<()>;
} }
} }
@ -129,8 +129,8 @@ mod initramfs;
pub(crate) use self::initramfs::*; pub(crate) use self::initramfs::*;
mod lockfile; mod lockfile;
pub use self::lockfile::*; pub use self::lockfile::*;
mod livefs; mod live;
pub(crate) use self::livefs::*; pub(crate) use self::live::*;
// An origin parser in Rust but only built when testing until // An origin parser in Rust but only built when testing until
// we're ready to try porting the C++ code. // we're ready to try porting the C++ code.
#[cfg(test)] #[cfg(test)]

View File

@ -1,4 +1,4 @@
//! Core implementation logic for "livefs" which applies //! Core implementation logic for "apply-live" which applies
//! changes to an overlayfs on top of `/usr` in the booted //! changes to an overlayfs on top of `/usr` in the booted
//! deployment. //! deployment.
/* /*
@ -26,9 +26,9 @@ use std::process::Command;
/// access it. /// access it.
const OSTREE_RUNSTATE_DIR: &str = "/run/ostree/deployment-state"; const OSTREE_RUNSTATE_DIR: &str = "/run/ostree/deployment-state";
/// Filename we use for serialized state, stored in the above directory. /// Filename we use for serialized state, stored in the above directory.
const LIVEFS_STATE_NAME: &str = "rpmostree-livefs-state.json"; const LIVE_STATE_NAME: &str = "rpmostree-live-state.json";
/// The model for livefs state. This representation is /// The model for live state. This representation is
/// just used "on disk" right now because /// just used "on disk" right now because
/// TODO(cxx-rs) doesn't support Option<T> /// TODO(cxx-rs) doesn't support Option<T>
#[derive(Debug, Default, Clone, Eq, PartialEq, Serialize, Deserialize)] #[derive(Debug, Default, Clone, Eq, PartialEq, Serialize, Deserialize)]
@ -36,7 +36,7 @@ struct LiveApplyStateSerialized {
/// The OSTree commit that the running root filesystem is using, /// The OSTree commit that the running root filesystem is using,
/// as distinct from the one it was booted with. /// as distinct from the one it was booted with.
commit: Option<String>, commit: Option<String>,
/// Set when a livefs operation is in progress; if the process /// Set when an apply-live operation is in progress; if the process
/// is interrupted, some files from this commit may exist /// is interrupted, some files from this commit may exist
/// on disk but in an incomplete state. /// on disk but in an incomplete state.
inprogress: Option<String>, inprogress: Option<String>,
@ -72,10 +72,10 @@ fn get_runstate_dir(deploy: &ostree::Deployment) -> PathBuf {
.into() .into()
} }
/// Get the livefs state /// Get the live state
fn get_livefs_state(deploy: &ostree::Deployment) -> Result<Option<LiveApplyState>> { fn get_live_state(deploy: &ostree::Deployment) -> Result<Option<LiveApplyState>> {
let root = openat::Dir::open("/")?; let root = openat::Dir::open("/")?;
if let Some(f) = root.open_file_optional(&get_runstate_dir(deploy).join(LIVEFS_STATE_NAME))? { if let Some(f) = root.open_file_optional(&get_runstate_dir(deploy).join(LIVE_STATE_NAME))? {
let s: LiveApplyStateSerialized = serde_json::from_reader(std::io::BufReader::new(f))?; let s: LiveApplyStateSerialized = serde_json::from_reader(std::io::BufReader::new(f))?;
let s = &s; let s = &s;
Ok(Some(s.into())) Ok(Some(s.into()))
@ -85,11 +85,11 @@ fn get_livefs_state(deploy: &ostree::Deployment) -> Result<Option<LiveApplyState
} }
/// Write new livefs state /// Write new livefs state
fn write_livefs_state(deploy: &ostree::Deployment, state: &LiveApplyState) -> Result<()> { fn write_live_state(deploy: &ostree::Deployment, state: &LiveApplyState) -> Result<()> {
let rundir = get_runstate_dir(deploy); let rundir = get_runstate_dir(deploy);
let rundir = openat::Dir::open(&rundir)?; let rundir = openat::Dir::open(&rundir)?;
let state: LiveApplyStateSerialized = state.into(); let state: LiveApplyStateSerialized = state.into();
rundir.write_file_with(LIVEFS_STATE_NAME, 0o644, |w| -> Result<_> { rundir.write_file_with(LIVE_STATE_NAME, 0o644, |w| -> Result<_> {
Ok(serde_json::to_writer(w, &state)?) Ok(serde_json::to_writer(w, &state)?)
})?; })?;
Ok(()) Ok(())
@ -180,7 +180,7 @@ fn apply_diff(
/// We don't try to delete anything yet, because doing so could mess up the actual /// We don't try to delete anything yet, because doing so could mess up the actual
/// `/etc` merge on reboot between the real deployment. Much of the logic here /// `/etc` merge on reboot between the real deployment. Much of the logic here
/// is similar to what libostree core does for `/etc` on upgrades. If we ever /// is similar to what libostree core does for `/etc` on upgrades. If we ever
/// push livefs down into libostree, this logic could be shared. /// push apply-live down into libostree, this logic could be shared.
fn update_etc( fn update_etc(
repo: &ostree::Repo, repo: &ostree::Repo,
diff: &crate::ostree_diff::FileTreeDiff, diff: &crate::ostree_diff::FileTreeDiff,
@ -337,8 +337,8 @@ fn rerun_tmpfiles() -> Result<()> {
Ok(()) Ok(())
} }
/// Implementation of `rpm-ostree ex livefs`. /// Implementation of `rpm-ostree ex apply-live`.
pub(crate) fn transaction_livefs( pub(crate) fn transaction_apply_live(
mut sysroot: Pin<&mut crate::ffi::OstreeSysroot>, mut sysroot: Pin<&mut crate::ffi::OstreeSysroot>,
target: &str, target: &str,
) -> Result<()> { ) -> Result<()> {
@ -370,7 +370,7 @@ pub(crate) fn transaction_livefs(
} }
}; };
let state = get_livefs_state(&booted)?; let state = get_live_state(&booted)?;
if state.is_none() { if state.is_none() {
match booted.get_unlocked() { match booted.get_unlocked() {
DeploymentUnlockedState::None => { DeploymentUnlockedState::None => {
@ -378,7 +378,7 @@ pub(crate) fn transaction_livefs(
} }
DeploymentUnlockedState::Transient | DeploymentUnlockedState::Development => {} DeploymentUnlockedState::Transient | DeploymentUnlockedState::Development => {}
s => { s => {
bail!("livefs is incompatible with unlock state: {}", s); bail!("apply-live is incompatible with unlock state: {}", s);
} }
}; };
} else { } else {
@ -434,7 +434,7 @@ pub(crate) fn transaction_livefs(
// Record that we're targeting this commit // Record that we're targeting this commit
state.inprogress = target_commit.to_string(); state.inprogress = target_commit.to_string();
write_livefs_state(&booted, &state)?; write_live_state(&booted, &state)?;
// The heart of things: updating the overlayfs on /usr // The heart of things: updating the overlayfs on /usr
apply_diff(repo, &diff, &target_commit, &openat::Dir::open("/usr")?)?; apply_diff(repo, &diff, &target_commit, &openat::Dir::open("/usr")?)?;
@ -452,7 +452,7 @@ pub(crate) fn transaction_livefs(
// Success! Update the recorded state. // Success! Update the recorded state.
state.commit = target_commit.to_string(); state.commit = target_commit.to_string();
state.inprogress = "".to_string(); state.inprogress = "".to_string();
write_livefs_state(&booted, &state)?; write_live_state(&booted, &state)?;
Ok(()) Ok(())
} }
@ -496,7 +496,7 @@ pub(crate) fn get_live_apply_state(
mut deployment: Pin<&mut crate::ffi::OstreeDeployment>, mut deployment: Pin<&mut crate::ffi::OstreeDeployment>,
) -> Result<LiveApplyState> { ) -> Result<LiveApplyState> {
let deployment = deployment.gobj_wrap(); let deployment = deployment.gobj_wrap();
if let Some(state) = get_livefs_state(&deployment)? { if let Some(state) = get_live_state(&deployment)? {
Ok(state) Ok(state)
} else { } else {
Ok(Default::default()) Ok(Default::default())

View File

@ -76,7 +76,7 @@ livefs_transaction_execute (RpmostreedTransaction *transaction,
/* Run the transaction */ /* Run the transaction */
try { try {
rpmostreecxx::transaction_livefs(*sysroot, target ?: ""); rpmostreecxx::transaction_apply_live(*sysroot, target ?: "");
} catch (std::exception& e) { } catch (std::exception& e) {
(void) rpmostree_syscore_bump_mtime (sysroot, NULL); (void) rpmostree_syscore_bump_mtime (sysroot, NULL);
throw; throw;