Skip to content

Commit

Permalink
swtpm: Remove all interface functions from swtpm_nvstore_dir.h
Browse files Browse the repository at this point in the history
Remove all interface functions from swtpm_nvstore_dir.h and make them
static in swtpm_nvstore_dir.c. This way we avoid direct calls to these
functions from elsewhere.

Move the declaration of the interface structure into swtpm_nvstore.h
to get rid of swtpm_nvstore_dir.h entirely.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
  • Loading branch information
stefanberger committed Sep 25, 2021
1 parent 78137e8 commit ea8e92a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 99 deletions.
1 change: 0 additions & 1 deletion src/swtpm/swtpm_nvstore.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@
#include "swtpm_aes.h"
#include "swtpm_debug.h"
#include "swtpm_nvstore.h"
#include "swtpm_nvstore_dir.h"
#include "key.h"
#include "logging.h"
#include "tpmstate.h"
Expand Down
5 changes: 5 additions & 0 deletions src/swtpm/swtpm_nvstore.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ struct nvram_backend_ops {
const char *uri);
void (*cleanup)(void);
};

/* backend interfaces */
extern struct nvram_backend_ops nvram_dir_ops;


int SWTPM_NVRAM_PrintJson(void);

#endif /* _SWTPM_NVSTORE_H */
36 changes: 19 additions & 17 deletions src/swtpm/swtpm_nvstore_dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,14 @@
#include "swtpm.h"
#include "swtpm_debug.h"
#include "swtpm_nvstore.h"
#include "swtpm_nvstore_dir.h"
#include "key.h"
#include "logging.h"
#include "tpmstate.h"
#include "utils.h"

static int lock_fd = -1;
#define TPM_FILENAME_MAX 20

struct nvram_backend_ops nvram_dir_ops = {
.prepare = SWTPM_NVRAM_Prepare_Dir,
.load = SWTPM_NVRAM_LoadData_Dir,
.store = SWTPM_NVRAM_StoreData_Dir,
.delete = SWTPM_NVRAM_DeleteName_Dir,
.cleanup = SWTPM_NVRAM_Cleanup_Dir,
};
static int lock_fd = -1;

static const char *
SWTPM_NVRAM_Uri_to_Dir(const char *uri)
Expand Down Expand Up @@ -180,7 +173,7 @@ SWTPM_NVRAM_GetFilepathForName(char *filepath, /* output: rooted file path
return rc;
}

TPM_RESULT
static TPM_RESULT
SWTPM_NVRAM_Prepare_Dir(const char *uri)
{
TPM_RESULT rc = 0;
Expand All @@ -195,13 +188,13 @@ SWTPM_NVRAM_Prepare_Dir(const char *uri)
return rc;
}

void
static void
SWTPM_NVRAM_Cleanup_Dir(void)
{
SWTPM_NVRAM_Unlock_Dir();
}

TPM_RESULT
static TPM_RESULT
SWTPM_NVRAM_LoadData_Dir(unsigned char **data,
uint32_t *length,
uint32_t tpm_number,
Expand Down Expand Up @@ -305,7 +298,7 @@ SWTPM_NVRAM_LoadData_Dir(unsigned char **data,
return rc;
}

TPM_RESULT
static TPM_RESULT
SWTPM_NVRAM_StoreData_Dir(unsigned char *filedata,
uint32_t filedata_length,
uint32_t tpm_number,
Expand Down Expand Up @@ -446,10 +439,11 @@ SWTPM_NVRAM_StoreData_Dir(unsigned char *filedata,
return rc;
}

TPM_RESULT SWTPM_NVRAM_DeleteName_Dir(uint32_t tpm_number,
const char *name,
TPM_BOOL mustExist,
const char *uri)
static TPM_RESULT
SWTPM_NVRAM_DeleteName_Dir(uint32_t tpm_number,
const char *name,
TPM_BOOL mustExist,
const char *uri)
{
TPM_RESULT rc = 0;
int irc;
Expand All @@ -476,3 +470,11 @@ TPM_RESULT SWTPM_NVRAM_DeleteName_Dir(uint32_t tpm_number,
}
return rc;
}

struct nvram_backend_ops nvram_dir_ops = {
.prepare = SWTPM_NVRAM_Prepare_Dir,
.load = SWTPM_NVRAM_LoadData_Dir,
.store = SWTPM_NVRAM_StoreData_Dir,
.delete = SWTPM_NVRAM_DeleteName_Dir,
.cleanup = SWTPM_NVRAM_Cleanup_Dir,
};
81 changes: 0 additions & 81 deletions src/swtpm/swtpm_nvstore_dir.h

This file was deleted.

0 comments on commit ea8e92a

Please sign in to comment.