From fb10428f8babfcfc1129767b1e647feeb3f491f8 Mon Sep 17 00:00:00 2001 From: Feiyi Wang Date: Wed, 29 Aug 2018 11:22:58 -0400 Subject: [PATCH] do away with ftruncate(), fix fallocate() signature, #23 --- lib/posix.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/lib/posix.c b/lib/posix.c index de95038..24aafc0 100644 --- a/lib/posix.c +++ b/lib/posix.c @@ -48,22 +48,7 @@ void *posix_write(void *fdes, lcio_job_t *job, off_t flag) { *rv = 0; if(job->ftrunc){ - if(flag == 0) { -#ifdef HAVE_POSIX_FALLOCATE - *rv = posix_fallocate(*(int*) fdes, job->blk_sz); -#else - *rv = ftruncate(*(int*) fdes, job->blk_sz); -#endif - if(*rv > -1) *rv = (ssize_t) job->blk_sz; - } - else { -#ifdef HAVE_POSIX_FALLOCATE - *rv = posix_fallocate(*(int*)fdes, flag); -#else - *rv = ftruncate(*(int*)fdes, flag); -#endif - if(*rv > -1) *rv = (ssize_t) flag; - } + *rv = posix_fallocate(*(int*)fdes, 0, flag); return rv; }