summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Scherle2022-06-08 17:44:33 +0200
committerMichael Scherle2022-06-08 17:44:33 +0200
commit7df5db8e8f56e5c2ca28ecf0e841b5cc1a7180e4 (patch)
tree03c6c61a0c54ceb2de3cb001f8c48befecc6b000
parentstruct padding and type changes (diff)
downloaddnbd3-7df5db8e8f56e5c2ca28ecf0e841b5cc1a7180e4.tar.gz
dnbd3-7df5db8e8f56e5c2ca28ecf0e841b5cc1a7180e4.tar.xz
dnbd3-7df5db8e8f56e5c2ca28ecf0e841b5cc1a7180e4.zip
asserts to verify type size
-rw-r--r--inc/dnbd3/config.h1
-rw-r--r--src/fuse/cowfile.h32
2 files changed, 18 insertions, 15 deletions
diff --git a/inc/dnbd3/config.h b/inc/dnbd3/config.h
index 0b0ee24..c435d22 100644
--- a/inc/dnbd3/config.h
+++ b/inc/dnbd3/config.h
@@ -48,6 +48,7 @@
#define COW_STATS_UPDATE_TIME 5 // time in seconds the cow status files gets updated (while uploading blocks)
#define COW_MAX_PARALLEL_UPLOADS 10 // maximum number of parallel uploads
#define COW_URL_STRING_SIZE 500 // Max string size for an url
+
// +++++ COW API Endpoints +++++
#define COW_API_CREATE "%s/api/File/Create"
#define COW_API_UPDATE "%s/api/File/Update?guid=%s&BlockNumber=%lu"
diff --git a/src/fuse/cowfile.h b/src/fuse/cowfile.h
index ef429fb..4ca3d73 100644
--- a/src/fuse/cowfile.h
+++ b/src/fuse/cowfile.h
@@ -22,24 +22,26 @@
_Static_assert( ATOMIC_INT_LOCK_FREE == 2, "ATOMIC INT not lock free");
_Static_assert( ATOMIC_LONG_LOCK_FREE == 2, "ATOMIC LONG not lock free");
_Static_assert( ATOMIC_LLONG_LOCK_FREE == 2, "ATOMIC LLONG not lock free");
+_Static_assert( sizeof(atomic_uint_least64_t) == 8, "atomic_uint_least64_t not 8 byte");
+_Static_assert( sizeof(atomic_int_least64_t) == 8, "atomic_int_least64_t not 8 byte");
#define COW_METADATA_HEADER_SIZE 320
typedef struct cowfile_metadata_header
{
- uint64_t magicValue; // 8byte
- atomic_uint_fast64_t imageSize; // 8byte
- int32_t version; // 4byte
- int32_t blocksize; // 4byte
- uint64_t originalImageSize; // 8byte
- uint64_t metaDataStart; // 8byte
- int32_t bitfieldSize; // 4byte
- int32_t nextL2; // 4byte
- atomic_size_t metadataFileSize; // 8byte
- atomic_size_t dataFileSize; // 8byte
- uint64_t maxImageSize; // 8byte
- uint64_t creationTime; // 8byte
- char uuid[40]; // 40byte
- char imageName[200]; // 200byte
+ uint64_t magicValue; // 8byte
+ atomic_uint_least64_t imageSize; // 8byte
+ int32_t version; // 4byte
+ int32_t blocksize; // 4byte
+ uint64_t originalImageSize; // 8byte
+ uint64_t metaDataStart; // 8byte
+ int32_t bitfieldSize; // 4byte
+ int32_t nextL2; // 4byte
+ atomic_uint_least64_t metadataFileSize; // 8byte
+ atomic_uint_least64_t dataFileSize; // 8byte
+ uint64_t maxImageSize; // 8byte
+ uint64_t creationTime; // 8byte
+ char uuid[40]; // 40byte
+ char imageName[200]; // 200byte
} cowfile_metadata_header_t;
_Static_assert(
sizeof( cowfile_metadata_header_t ) == COW_METADATA_HEADER_SIZE, "cowfile_metadata_header is messed up" );
@@ -47,7 +49,7 @@ _Static_assert(
#define COW_METADATA_METADATA_SIZE 64
typedef struct cow_block_metadata
{
- atomic_long offset;
+ atomic_int_least64_t offset;
atomic_uint_least64_t timeChanged;
atomic_uint_least64_t timeUploaded;
atomic_char bitfield[40];