Skip to content

Commit

Permalink
fixup! [LibOS] Single-process-lifetime rollback protection for protec…
Browse files Browse the repository at this point in the history
…ted files (WIP)

Signed-off-by: g2flyer <michael.steiner@intel.com>
  • Loading branch information
g2flyer committed May 10, 2024
1 parent 10d4597 commit 95c577f
Showing 1 changed file with 22 additions and 5 deletions.
27 changes: 22 additions & 5 deletions libos/src/fs/libos_fs_encrypted.c
Original file line number Diff line number Diff line change
Expand Up @@ -897,14 +897,20 @@ BEGIN_CP_FUNC(encrypted_volume) {
struct libos_encrypted_volume* new_volume = NULL;

size_t off = ADD_CP_OFFSET(sizeof(struct libos_encrypted_volume));

new_volume = (struct libos_encrypted_volume*)(base + off);

// TODO (MST): do something with remaining fields of struct
log_debug("CP(encrypted_volume): protection_mode=%d file_state_mape=%p",
volume->protection_mode, volume->files_state_map); // TODO (MST): DEBUG
// - protection_mode -> automatically copied
// - files_state_map
// - files_state_map_lock

lock(&g_keys_lock);
DO_CP_MEMBER(encrypted_files_key, volume, new_volume, key);
unlock(&g_keys_lock);

// TODO (MST): do something with remaining fields of struct

ADD_CP_FUNC_ENTRY(off);

if (objp)
Expand All @@ -917,11 +923,19 @@ BEGIN_RS_FUNC(encrypted_volume) {
struct libos_encrypted_volume* volume = (void*)(base + GET_CP_FUNC_ENTRY());
__UNUSED(offset);

CP_REBASE(volume->key);

// TODO (MST): do something with remaining fields of struct
log_debug("RS(encrypted_volume): protection_mode=%d file_state_mape=%p",
volume->protection_mode, volume->files_state_map); // TODO (MST): DEBUG
// - protection_mode -> automatically copied
// - files_state_map
// - files_state_map_lock
if (!create_lock(&volume->files_state_map_lock)) {
return -ENOMEM;
}

CP_REBASE(volume->key);
}
END_CP_FUNC(encrypted_volume)
END_RS_FUNC(encrypted_volume)

BEGIN_CP_FUNC(encrypted_file) {
__UNUSED(size);
Expand All @@ -940,6 +954,7 @@ BEGIN_CP_FUNC(encrypted_file) {

new_enc->use_count = enc->use_count;
DO_CP_MEMBER(str, enc, new_enc, uri);
DO_CP_MEMBER(str, enc, new_enc, norm_path);

DO_CP_MEMBER(encrypted_volume, enc, new_enc, volume);

Expand All @@ -963,6 +978,8 @@ BEGIN_RS_FUNC(encrypted_file) {
__UNUSED(offset);

CP_REBASE(enc->uri);
CP_REBASE(enc->norm_path);

CP_REBASE(enc->volume);

/* If the file was used, recreate `enc->pf` based on the PAL handle */
Expand Down

0 comments on commit 95c577f

Please sign in to comment.