aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2018-02-27 18:00:08 +0100
committerPaul Selkirk <paul@psgd.org>2018-02-27 18:00:08 +0100
commit3f374757fdfde32abceb88adca31d21f2b05cab1 (patch)
treef14ff60badf35807e08a34fd047e9d4be5b555e6
parentb87e7392cdc71b3a69728d7fb40a6697eeeed09e (diff)
Add hal_ks_available
-rw-r--r--ks.c12
-rw-r--r--ks.h2
2 files changed, 14 insertions, 0 deletions
diff --git a/ks.c b/ks.c
index 1598679..f145adc 100644
--- a/ks.c
+++ b/ks.c
@@ -1010,6 +1010,18 @@ hal_error_t hal_ks_rewrite_der(hal_ks_t *ks,
return err;
}
+hal_error_t hal_ks_available(hal_ks_t *ks, size_t *count)
+{
+ if (ks == NULL || count == NULL)
+ return HAL_ERROR_BAD_ARGUMENTS;
+
+ hal_ks_lock();
+ *count = ks->size - ks->used;
+ hal_ks_unlock();
+
+ return HAL_OK;
+}
+
/*
* Local variables:
* indent-tabs-mode: nil
diff --git a/ks.h b/ks.h
index ae1ba1c..4f91706 100644
--- a/ks.h
+++ b/ks.h
@@ -422,6 +422,8 @@ extern hal_error_t hal_ks_block_update(hal_ks_t *ks,
const hal_uuid_t * const uuid,
int *hint);
+extern hal_error_t hal_ks_available(hal_ks_t *ks, size_t *count);
+
#endif /* _KS_H_ */
/*