Skip to content

Commit 95c577f

Browse files
committed
fixup! [LibOS] Single-process-lifetime rollback protection for protected files (WIP)
Signed-off-by: g2flyer <[email protected]>
1 parent 10d4597 commit 95c577f

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

libos/src/fs/libos_fs_encrypted.c

+22-5
Original file line numberDiff line numberDiff line change
@@ -897,14 +897,20 @@ BEGIN_CP_FUNC(encrypted_volume) {
897897
struct libos_encrypted_volume* new_volume = NULL;
898898

899899
size_t off = ADD_CP_OFFSET(sizeof(struct libos_encrypted_volume));
900+
900901
new_volume = (struct libos_encrypted_volume*)(base + off);
901902

903+
// TODO (MST): do something with remaining fields of struct
904+
log_debug("CP(encrypted_volume): protection_mode=%d file_state_mape=%p",
905+
volume->protection_mode, volume->files_state_map); // TODO (MST): DEBUG
906+
// - protection_mode -> automatically copied
907+
// - files_state_map
908+
// - files_state_map_lock
909+
902910
lock(&g_keys_lock);
903911
DO_CP_MEMBER(encrypted_files_key, volume, new_volume, key);
904912
unlock(&g_keys_lock);
905913

906-
// TODO (MST): do something with remaining fields of struct
907-
908914
ADD_CP_FUNC_ENTRY(off);
909915

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

920-
CP_REBASE(volume->key);
921-
922926
// TODO (MST): do something with remaining fields of struct
927+
log_debug("RS(encrypted_volume): protection_mode=%d file_state_mape=%p",
928+
volume->protection_mode, volume->files_state_map); // TODO (MST): DEBUG
929+
// - protection_mode -> automatically copied
930+
// - files_state_map
931+
// - files_state_map_lock
932+
if (!create_lock(&volume->files_state_map_lock)) {
933+
return -ENOMEM;
934+
}
935+
936+
CP_REBASE(volume->key);
923937
}
924-
END_CP_FUNC(encrypted_volume)
938+
END_RS_FUNC(encrypted_volume)
925939

926940
BEGIN_CP_FUNC(encrypted_file) {
927941
__UNUSED(size);
@@ -940,6 +954,7 @@ BEGIN_CP_FUNC(encrypted_file) {
940954

941955
new_enc->use_count = enc->use_count;
942956
DO_CP_MEMBER(str, enc, new_enc, uri);
957+
DO_CP_MEMBER(str, enc, new_enc, norm_path);
943958

944959
DO_CP_MEMBER(encrypted_volume, enc, new_enc, volume);
945960

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

965980
CP_REBASE(enc->uri);
981+
CP_REBASE(enc->norm_path);
982+
966983
CP_REBASE(enc->volume);
967984

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

0 commit comments

Comments
 (0)