[PATCH 1/2] ssc: 32bit arch can't handle large image files

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

 



Signed-off-by: FUJITA Tomonori <fujita.tomonori@xxxxxxxxxxxxx>
---
 usr/bs_ssc.c |   12 ++++++------
 usr/libssc.c |    8 ++++----
 usr/libssc.h |    4 ++--
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/usr/bs_ssc.c b/usr/bs_ssc.c
index b80ece8..469057d 100644
--- a/usr/bs_ssc.c
+++ b/usr/bs_ssc.c
@@ -113,7 +113,7 @@ static int resp_rewind(struct scsi_lu *lu)
 	return skip_next_header(lu);
 }
 
-static unsigned long current_size(struct scsi_cmd *cmd)
+static uint64_t current_size(struct scsi_cmd *cmd)
 {
 	struct ssc_info *ssc = dtype_priv(cmd->dev);
 	return ssc->c_blk.curr;
@@ -179,8 +179,8 @@ static int append_blk(struct scsi_cmd *cmd, uint8_t *data,
 
 	/* Write any data */
 	if (size) {
-		ret = pwrite(fd, data, size,
-			     (off_t)curr->curr + SSC_BLK_HDR_SIZE);
+		ret = pwrite64(fd, data, size,
+			       curr->curr + SSC_BLK_HDR_SIZE);
 		if (ret != size) {
 			eprintf("Write of data failed: %m\n");
 			sense_data_build(cmd, MEDIUM_ERROR, ASC_WRITE_ERROR);
@@ -345,7 +345,7 @@ static int resp_var_read(struct scsi_cmd *cmd, uint8_t *buf, uint32_t length,
 			goto out;
 	}
 
-	ret = pread(cmd->dev->fd, buf, length, h->curr + SSC_BLK_HDR_SIZE);
+	ret = pread64(cmd->dev->fd, buf, length, h->curr + SSC_BLK_HDR_SIZE);
 	if (ret != length) {
 		sense_data_build(cmd, MEDIUM_ERROR, ASC_READ_ERROR);
 		result = SAM_STAT_CHECK_CONDITION;
@@ -399,8 +399,8 @@ static int resp_fixed_read(struct scsi_cmd *cmd, uint8_t *buf, uint32_t length,
 			goto out;
 		}
 
-		residue = pread(fd, buf, block_length,
-				h->curr + SSC_BLK_HDR_SIZE);
+		residue = pread64(fd, buf, block_length,
+				  h->curr + SSC_BLK_HDR_SIZE);
 		if (block_length != residue) {
 			eprintf("Could only read %d bytes, not %d\n",
 					(int)residue, block_length);
diff --git a/usr/libssc.c b/usr/libssc.c
index e13a9f6..a4a0687 100644
--- a/usr/libssc.c
+++ b/usr/libssc.c
@@ -181,13 +181,13 @@ int ssc_write_mam_info(int fd, struct MAM_info *i)
 	return  0;
 }
 
-int ssc_read_blkhdr(int fd, struct blk_header_info *i, off_t offset)
+int ssc_read_blkhdr(int fd, struct blk_header_info *i, loff_t offset)
 {
 	size_t count;
 	struct blk_header h, *m = &h;
 	uint32_t crc = ~0;
 
-	count = pread(fd, m, SSC_BLK_HDR_SIZE, offset);
+	count = pread64(fd, m, SSC_BLK_HDR_SIZE, offset);
 	if (count != SSC_BLK_HDR_SIZE)
 		return 1;
 
@@ -207,7 +207,7 @@ int ssc_read_blkhdr(int fd, struct blk_header_info *i, off_t offset)
 	return 0;
 }
 
-int ssc_write_blkhdr(int fd, struct blk_header_info *i, off_t offset)
+int ssc_write_blkhdr(int fd, struct blk_header_info *i, loff_t offset)
 {
 	size_t count;
 	struct blk_header h, *m = &h;
@@ -224,7 +224,7 @@ int ssc_write_blkhdr(int fd, struct blk_header_info *i, off_t offset)
 	crc = crc32c(crc, &m->ondisk_sz, SSC_BLK_HDR_SIZE - sizeof(m->h_csum));
 	*(uint32_t *)m->h_csum = ~crc;
 
-	count = pwrite(fd, m, SSC_BLK_HDR_SIZE, offset);
+	count = pwrite64(fd, m, SSC_BLK_HDR_SIZE, offset);
 	if (count != SSC_BLK_HDR_SIZE)
 		return 1;
 
diff --git a/usr/libssc.h b/usr/libssc.h
index ace2037..e844346 100644
--- a/usr/libssc.h
+++ b/usr/libssc.h
@@ -3,7 +3,7 @@
 
 extern int ssc_read_mam_info(int fd, struct MAM_info *i);
 extern int ssc_write_mam_info(int fd, struct MAM_info *i);
-extern int ssc_read_blkhdr(int fd, struct blk_header_info *h, off_t offset);
-extern int ssc_write_blkhdr(int fd, struct blk_header_info *h, off_t offset);
+extern int ssc_read_blkhdr(int fd, struct blk_header_info *h, loff_t offset);
+extern int ssc_write_blkhdr(int fd, struct blk_header_info *h, loff_t offset);
 
 #endif
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux SCSI]     [Linux RAID]     [Linux Clusters]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]

  Powered by Linux