From 2f44978db430101baeb643db160c9a5190ef7fa8 Mon Sep 17 00:00:00 2001 From: Charles Duffy Date: Wed, 14 Oct 2015 16:26:30 -0500 Subject: [PATCH] Move from loff_t to off64_t for musl libc support (#11) Using musl libc, the loff_t type is unavailable. This is only exported by the kernel when building with GNU_SOURCE, so there's an argument to be made that it's desired behavior; see http://www.openwall.com/lists/musl/2013/01/23/6 for discussion on this point. --- src/context.h | 2 +- src/nwipe.c | 4 ++-- src/pass.c | 24 ++++++++++++------------ 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/context.h b/src/context.h index ca13d0c..fbb5b41 100644 --- a/src/context.h +++ b/src/context.h @@ -82,7 +82,7 @@ typedef struct nwipe_context_t_ int device_minor; /* The minor device number. */ int device_part; /* The device partition or slice number. */ char* device_name; /* The device file name. */ - loff_t device_size; /* The device size in bytes. */ + off64_t device_size; /* The device size in bytes. */ struct stat device_stat; /* The device file state from fstat(). */ nwipe_device_t device_type; /* Indicates an IDE, SCSI, or Compaq SMART device. */ int device_target; /* The device target. */ diff --git a/src/nwipe.c b/src/nwipe.c index 8a84eb1..7423124 100644 --- a/src/nwipe.c +++ b/src/nwipe.c @@ -354,7 +354,7 @@ int main( int argc, char** argv ) } - if( c2[i]->device_size == (loff_t)-1 ) + if( c2[i]->device_size == (off64_t)-1 ) { /* We cannot determine the size of this device. */ nwipe_perror( errno, __FUNCTION__, "lseek" ); @@ -367,7 +367,7 @@ int main( int argc, char** argv ) /* Reset the file pointer. */ r = lseek( c2[i]->device_fd, 0, SEEK_SET ); - if( r == (loff_t)-1 ) + if( r == (off64_t)-1 ) { nwipe_perror( errno, __FUNCTION__, "lseek" ); nwipe_log( NWIPE_LOG_ERROR, "Unable to reset the '%s' file offset.", c2[i]->device_name ); diff --git a/src/pass.c b/src/pass.c index 1cf5c74..3c6dfab 100644 --- a/src/pass.c +++ b/src/pass.c @@ -46,7 +46,7 @@ int nwipe_random_verify( nwipe_context_t* c ) size_t blocksize; /* The result buffer for calls to lseek. */ - loff_t offset; + off64_t offset; /* The input buffer. */ char* b; @@ -98,7 +98,7 @@ int nwipe_random_verify( nwipe_context_t* c ) /* Reset the pass byte counter. */ c->pass_done = 0; - if( offset == (loff_t)-1 ) + if( offset == (off64_t)-1 ) { nwipe_perror( errno, __FUNCTION__, "lseek" ); nwipe_log( NWIPE_LOG_FATAL, "Unable to reset the '%s' file offset.", c->device_name ); @@ -177,7 +177,7 @@ int nwipe_random_verify( nwipe_context_t* c ) /* Bump the file pointer to the next block. */ offset = lseek( c->device_fd, s, SEEK_CUR ); - if( offset == (loff_t)-1 ) + if( offset == (off64_t)-1 ) { nwipe_perror( errno, __FUNCTION__, "lseek" ); nwipe_log( NWIPE_LOG_ERROR, "Unable to bump the '%s' file offset after a partial read.", c->device_name ); @@ -225,7 +225,7 @@ int nwipe_random_pass( NWIPE_METHOD_SIGNATURE ) size_t blocksize; /* The result buffer for calls to lseek. */ - loff_t offset; + off64_t offset; /* The output buffer. */ char* b; @@ -267,7 +267,7 @@ int nwipe_random_pass( NWIPE_METHOD_SIGNATURE ) /* Reset the pass byte counter. */ c->pass_done = 0; - if( offset == (loff_t)-1 ) + if( offset == (off64_t)-1 ) { nwipe_perror( errno, __FUNCTION__, "lseek" ); nwipe_log( NWIPE_LOG_FATAL, "Unable to reset the '%s' file offset.", c->device_name ); @@ -328,7 +328,7 @@ int nwipe_random_pass( NWIPE_METHOD_SIGNATURE ) /* Bump the file pointer to the next block. */ offset = lseek( c->device_fd, s, SEEK_CUR ); - if( offset == (loff_t)-1 ) + if( offset == (off64_t)-1 ) { nwipe_perror( errno, __FUNCTION__, "lseek" ); nwipe_log( NWIPE_LOG_ERROR, "Unable to bump the '%s' file offset after a partial write.", c->device_name ); @@ -388,7 +388,7 @@ int nwipe_static_verify( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* pattern ) size_t blocksize; /* The result buffer for calls to lseek. */ - loff_t offset; + off64_t offset; /* The input buffer. */ char* b; @@ -470,7 +470,7 @@ int nwipe_static_verify( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* pattern ) /* Reset the pass byte counter. */ c->pass_done = 0; - if( offset == (loff_t)-1 ) + if( offset == (off64_t)-1 ) { nwipe_perror( errno, __FUNCTION__, "lseek" ); nwipe_log( NWIPE_LOG_FATAL, "Unable to reset the '%s' file offset.", c->device_name ); @@ -534,7 +534,7 @@ int nwipe_static_verify( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* pattern ) /* Bump the file pointer to the next block. */ offset = lseek( c->device_fd, s, SEEK_CUR ); - if( offset == (loff_t)-1 ) + if( offset == (off64_t)-1 ) { nwipe_perror( errno, __FUNCTION__, "lseek" ); nwipe_log( NWIPE_LOG_ERROR, "Unable to bump the '%s' file offset after a partial read.", c->device_name ); @@ -587,7 +587,7 @@ int nwipe_static_pass( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* pattern ) size_t blocksize; /* The result buffer for calls to lseek. */ - loff_t offset; + off64_t offset; /* The output buffer. */ char* b; @@ -638,7 +638,7 @@ int nwipe_static_pass( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* pattern ) /* Reset the pass byte counter. */ c->pass_done = 0; - if( offset == (loff_t)-1 ) + if( offset == (off64_t)-1 ) { nwipe_perror( errno, __FUNCTION__, "lseek" ); nwipe_log( NWIPE_LOG_FATAL, "Unable to reset the '%s' file offset.", c->device_name ); @@ -697,7 +697,7 @@ int nwipe_static_pass( NWIPE_METHOD_SIGNATURE, nwipe_pattern_t* pattern ) /* Bump the file pointer to the next block. */ offset = lseek( c->device_fd, s, SEEK_CUR ); - if( offset == (loff_t)-1 ) + if( offset == (off64_t)-1 ) { nwipe_perror( errno, __FUNCTION__, "lseek" ); nwipe_log( NWIPE_LOG_ERROR, "Unable to bump the '%s' file offset after a partial write.", c->device_name );