[PATCH] restripe.c: Use _FILE_OFFSET_BITS to enable largefile support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Instead of using the lseek64 and friends, its better to enable it via
the feature macro _FILE_OFFSET_BITS = 64 and let the C library deal with
the width of types

Upstream-Status: Pending

Signed-off-by: Khem Raj <raj.khem@xxxxxxxxx>
---
 restripe.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/restripe.c b/restripe.c
index a7a7229..1c03577 100644
--- a/restripe.c
+++ b/restripe.c
@@ -22,6 +22,9 @@
  *    Email: <neilb@xxxxxxx>
  */
 
+/* Enable largefile support */
+#define _FILE_OFFSET_BITS 64
+
 #include "mdadm.h"
 #include <stdint.h>
 
@@ -581,7 +584,7 @@ int save_stripes(int *source, unsigned long long *offsets,
 				       raid_disks, level, layout);
 			if (dnum < 0) abort();
 			if (source[dnum] < 0 ||
-			    lseek64(source[dnum],
+			    lseek(source[dnum],
 				    offsets[dnum] + offset, 0) < 0 ||
 			    read(source[dnum], buf+disk * chunk_size,
 				 chunk_size) != chunk_size) {
@@ -754,8 +757,8 @@ int restore_stripes(int *dest, unsigned long long *offsets,
 					   raid_disks, level, layout);
 			if (src_buf == NULL) {
 				/* read from file */
-				if (lseek64(source, read_offset, 0) !=
-					 (off64_t)read_offset) {
+				if (lseek(source, read_offset, 0) !=
+					 (off_t)read_offset) {
 					rv = -1;
 					goto abort;
 				}
@@ -816,7 +819,7 @@ int restore_stripes(int *dest, unsigned long long *offsets,
 		}
 		for (i=0; i < raid_disks ; i++)
 			if (dest[i] >= 0) {
-				if (lseek64(dest[i],
+				if (lseek(dest[i],
 					 offsets[i]+offset, 0) < 0) {
 					rv = -1;
 					goto abort;
@@ -866,7 +869,7 @@ int test_stripes(int *source, unsigned long long *offsets,
 		int disk;
 
 		for (i = 0 ; i < raid_disks ; i++) {
-			if ((lseek64(source[i], offsets[i]+start, 0) < 0) ||
+			if ((lseek(source[i], offsets[i]+start, 0) < 0) ||
 			    (read(source[i], stripes[i], chunk_size) !=
 			     chunk_size)) {
 				free(q);
-- 
2.38.1




[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux