Commit a0adabc1 authored by rcrane's avatar rcrane
Browse files

Update get_key_range.c

The original code didn't work with a kinetic hdd (ember unit).
The disk returned the status message "Synchronization Field Invalid / Not Provided".
Adding .tag and .synchronization to the entry solved the issue.
parent 8b9208b9
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <openssl/sha.h>

static bool create_entries(KineticSession * const session, const int count);

@@ -125,11 +126,19 @@ static bool create_entries(KineticSession * const session, const int count)
        ByteBuffer KeyBuffer = ByteBuffer_CreateAndAppendFormattedCString(key_buf, sz, "key_prefix_%02d", i);
        ByteBuffer ValueBuffer = ByteBuffer_CreateAndAppendFormattedCString(value_buf, sz, "val_%02d", i);
        
        /* Populate tag with SHA1 of value */
        ByteBuffer put_tag_buf = ByteBuffer_Malloc(20);
        uint8_t sha1[20];
        SHA1(ValueBuffer.array.data, ValueBuffer.bytesUsed, &sha1[0]);
        ByteBuffer_Append(&put_tag_buf, sha1, sizeof(sha1));
        
        KineticEntry entry = {
            .key = KeyBuffer,
            .value = ValueBuffer,
            .tag = put_tag_buf,
            .algorithm = KINETIC_ALGORITHM_SHA1,
            .force = true,
            .synchronization = KINETIC_SYNCHRONIZATION_WRITETHROUGH,
        };

        KineticStatus status = KineticClient_Put(session, &entry, NULL);