[stgt] Failed to write tape greater than 2Gb

FUJITA Tomonori fujita.tomonori at lab.ntt.co.jp
Wed Dec 7 21:35:29 CET 2011


On Wed, 07 Dec 2011 15:47:55 +0100
Gabriele Mailing <gabriele.mailing at rvmgroup.it> wrote:

> Hy,
> > Try adding a "-D_LARGEFILE64_SOURCE" to the CFLAGS in usr/Makefile..
> > CFLAGS += -D_LARGEFILE64_SOURCE
> > along with the reset of the CFLAGS += entries (somewhere about line 57).
> 
> Recompiled stock debian package woth this flags, but same issue applies.
> Recompiled 1.0.22 with same flag, and same issue applies.

_LARGEFILE64_SOURCE should be already defined due to _GNU_SOURCE.

Can you try the following?

diff --git a/usr/bs_ssc.c b/usr/bs_ssc.c
index b80ece8..e4f1a71 100644
--- a/usr/bs_ssc.c
+++ b/usr/bs_ssc.c
@@ -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
--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list