diff options
Diffstat (limited to 'fuse_sideload.cpp')
-rw-r--r-- | fuse_sideload.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/fuse_sideload.cpp b/fuse_sideload.cpp index 1725e8823..f57d479b0 100644 --- a/fuse_sideload.cpp +++ b/fuse_sideload.cpp @@ -46,7 +46,7 @@ #include <errno.h> #include <fcntl.h> #include <limits.h> -#include <linux/fuse.h> +#include "fuse.h" #include <pthread.h> #include <stdio.h> #include <stdlib.h> @@ -61,7 +61,12 @@ #include <sys/uio.h> #include <unistd.h> +#ifdef USE_MINCRYPT +#include "mincrypt/sha256.h" +#define SHA256_DIGEST_LENGTH SHA256_DIGEST_SIZE +#else #include <openssl/sha.h> +#endif #include "fuse_sideload.h" @@ -71,6 +76,10 @@ #define NO_STATUS 1 #define NO_STATUS_EXIT 2 +#ifndef MIN +#define MIN(a, b) ((a) < (b) ? (a) : (b)) +#endif + struct fuse_data { int ffd; // file descriptor for the fuse socket @@ -271,7 +280,11 @@ static int fetch_block(struct fuse_data* fd, uint32_t block) { // - Otherwise, return -EINVAL for the read. uint8_t hash[SHA256_DIGEST_LENGTH]; +#ifdef USE_MINCRYPT + SHA256_hash(fd->block_data, fd->block_size, hash); +#else SHA256(fd->block_data, fd->block_size, hash); +#endif uint8_t* blockhash = fd->hashes + block * SHA256_DIGEST_LENGTH; if (memcmp(hash, blockhash, SHA256_DIGEST_LENGTH) == 0) { return 0; @@ -523,3 +536,9 @@ int run_fuse_sideload(struct provider_vtab* vtab, void* cookie, return result; } + +extern "C" int run_old_fuse_sideload(struct provider_vtab* vtab, void* cookie, + uint64_t file_size, uint32_t block_size) +{ + return run_fuse_sideload(vtab, cookie, file_size, block_size); +} |