aboutsummaryrefslogtreecommitdiff
path: root/archive
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2007-06-27 02:45:31 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2007-06-27 02:45:31 +0000
commitf078b30e604ad74f9925f6cababa1198d4bab381 (patch)
treec5b0e4465144a4c16c9d1f6dd52700c239be4523 /archive
parent2f602b6d14ddc82313dd1e435ca9917f3e80e377 (diff)
downloadsg3_utils-f078b30e604ad74f9925f6cababa1198d4bab381.tar.gz
Load sg3_utils-0.98 into trunk/.
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@21 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'archive')
-rw-r--r--archive/Makefile5
-rw-r--r--archive/README4
-rw-r--r--archive/sg_reset.c131
-rw-r--r--archive/sg_simple_andre.c33
-rw-r--r--archive/sgq_dd.c94
-rw-r--r--archive/sgs_dd.c45
6 files changed, 129 insertions, 183 deletions
diff --git a/archive/Makefile b/archive/Makefile
index a0a0cdd6..4c1b23e9 100644
--- a/archive/Makefile
+++ b/archive/Makefile
@@ -6,7 +6,7 @@ MANDIR=/usr/local/man
CC = gcc
LD = gcc
-EXECS = sgq_dd sg_poll sg_reset sg_bus_xfer sg_hold isosize
+EXECS = sgq_dd sg_poll sg_bus_xfer sg_hold isosize
COMMON = isosize
@@ -35,9 +35,6 @@ sg_poll: sg_poll.o ../sg_err.o
sgq_dd: sgq_dd.o ../sg_err.o ../llseek.o
$(LD) -o $@ $(LDFLAGS) $^
-sg_reset: sg_reset.o
- $(LD) -o $@ $(LDFLAGS) $^
-
sg_bus_xfer: sg_bus_xfer.o ../sg_err.o
$(LD) -o $@ $(LDFLAGS) $^
diff --git a/archive/README b/archive/README
index 89fc88cd..d6d6c205 100644
--- a/archive/README
+++ b/archive/README
@@ -14,8 +14,6 @@ Since I actively use some of these programs for testing, a Makefile has
been set up which builds:
- sgq_dd [a dd variant the uses a dispatch loop rather than
POSIX threads (as does sgp_dd)]
- - sg_reset [does SCSI bus/device/host resets if mid level SCSI patch
- in place]
- sg_hold holds a sg device open and periodically sends a TEST
UNIT READY command to the device
- sg_poll [internal testing]
@@ -31,4 +29,4 @@ to side step various buffer copies. See:
http://www.torque.net/sg/mem2disk.html
Doug Gilbert
-23rd December 2001
+24th January 2002
diff --git a/archive/sg_reset.c b/archive/sg_reset.c
deleted file mode 100644
index eafb84be..00000000
--- a/archive/sg_reset.c
+++ /dev/null
@@ -1,131 +0,0 @@
-#include <unistd.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include "sg_include.h"
-
-/* Test code for D. Gilbert's extensions to the Linux OS SCSI generic ("sg")
- device driver.
-* Copyright (C) 1999 D. Gilbert
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, or (at your option)
-* any later version.
-
- This program send either device, bus or host resets to device,
- or bus or host associated with the given sg device.
-
- Version 0.02 (20000105)
-*/
-
-#ifndef SG_SCSI_RESET
-#define SG_SCSI_RESET 0x2284
-#endif
-
-#ifndef SG_SCSI_RESET_NOTHING
-#define SG_SCSI_RESET_NOTHING 0
-#define SG_SCSI_RESET_DEVICE 1
-#define SG_SCSI_RESET_BUS 2
-#define SG_SCSI_RESET_HOST 3
-#endif
-
-
-
-int main(int argc, char * argv[])
-{
- int sg_fd, res, k, j;
- int do_device_reset = 0;
- int do_bus_reset = 0;
- int do_host_reset = 0;
- int do_wait = 0;
- char * file_name = 0;
-
- for (k = 1; k < argc; ++k) {
- if (0 == strcmp("-d", argv[k]))
- do_device_reset = 1;
- else if (0 == strcmp("-b", argv[k]))
- do_bus_reset = 1;
- else if (0 == strcmp("-h", argv[k]))
- do_host_reset = 1;
- else if (0 == strcmp("-w", argv[k]))
- do_wait = 1;
- else if (*argv[k] == '-') {
- printf("Unrecognized switch: %s\n", argv[k]);
- file_name = 0;
- break;
- }
- else
- file_name = argv[k];
- }
- if (0 == file_name) {
- printf(
- "Usage: 'sg_reset [-d] [-b] [-h] [-w] <generic_device>'\n");
- printf(" where: -d attempt a scsi device reset\n");
- printf(" -b attempt a scsi bus reset\n");
- printf(" -h attempt a host adapter reset\n");
- printf(" -w wait for one of the resets to complete\n");
- printf(" {if no switch given then check if reset underway}\n");
- return 1;
- }
-
- sg_fd = open(file_name, O_RDWR);
- if (sg_fd < 0) {
- perror("sg_reset: open error");
- return 1;
- }
- /* Don't worry, being very careful not to write to a none-sg file ... */
- k = SG_SCSI_RESET_NOTHING;
- if (do_device_reset)
- k = SG_SCSI_RESET_DEVICE;
- else if (do_bus_reset)
- k = SG_SCSI_RESET_BUS;
- else if (do_host_reset)
- k = SG_SCSI_RESET_HOST;
-
- res = ioctl(sg_fd, SG_SCSI_RESET, &k);
- if (res < 0) {
- if (EBUSY == errno)
- printf("sg_reset: BUSY, may be resetting now\n");
- else if (EIO == errno)
- printf("sg_reset: requested type of reset may not be available\n");
- else if (EACCES == errno)
- printf("sg_reset: to do a reset needs root permission\n");
- else
- printf("sg_reset: SG_SCSI_RESET not supported\n");
- return 1;
- }
- if (SG_SCSI_RESET_NOTHING == k)
- printf("sg_reset: did nothing, device is normal mode\n");
- else {
- if (SG_SCSI_RESET_DEVICE == k)
- printf("sg_reset: started device reset\n");
- else if (SG_SCSI_RESET_BUS == k)
- printf("sg_reset: started bus reset\n");
- else if (SG_SCSI_RESET_HOST == k)
- printf("sg_reset: started host reset\n");
-
- if (do_wait) {
- printf("waiting for the reset to complete...\n");
- j = 0;
- k = SG_SCSI_RESET_NOTHING;
- do {
- if (0 != j)
- sleep(1);
- res = ioctl(sg_fd, SG_SCSI_RESET, &k);
- ++j;
- } while ((res < 0) && (EBUSY == errno));
- printf(" ... reset seemingly completed\n");
- }
- }
-
- if (close(sg_fd) < 0) {
- perror("sg_reset: close error");
- return 1;
- }
- return 0;
-}
diff --git a/archive/sg_simple_andre.c b/archive/sg_simple_andre.c
new file mode 100644
index 00000000..d1630224
--- /dev/null
+++ b/archive/sg_simple_andre.c
@@ -0,0 +1,33 @@
+#include <scsi/sg.h>
+
+
+#define READ10_REPLY_LEN 512
+#define READ10_CMD_LEN 10
+
+// read 0x102 blocks from block # 0x3040506
+// [just to to you where the fields are]
+..............
+
+ unsigned char r10CmdBlk [READ10_CMD_LEN] =
+ {0x28, 0, 3, 4, 5, 6, 0, 1, 2, 0};
+ sg_io_hdr_t io_hdr;
+ unsigned char inBuff[READ10_REPLY_LEN];
+ unsigned char sense_buffer[32];
+
+ /* Prepare READ_10 command */
+ memset(&io_hdr, 0, sizeof(sg_io_hdr_t));
+ io_hdr.interface_id = 'S';
+ io_hdr.cmd_len = sizeof(r10CmdBlk);
+ io_hdr.mx_sb_len = sizeof(sense_buffer);
+ io_hdr.dxfer_direction = SG_DXFER_FROM_DEV;
+ io_hdr.dxfer_len = READ10_REPLY_LEN;
+ io_hdr.dxferp = inBuff;
+ io_hdr.cmdp = r10CmdBlk;
+ io_hdr.sbp = sense_buffer;
+ io_hdr.timeout = 20000; /* 20000 millisecs == 20 seconds */
+
+ if (ioctl(sg_fd, SG_IO, &io_hdr) < 0) {
+ perror("READ_10 SG_IO ioctl error");
+ .....
+ }
+ // block should now be in 'inBuff'
diff --git a/archive/sgq_dd.c b/archive/sgq_dd.c
index 235e561b..7a8a09d7 100644
--- a/archive/sgq_dd.c
+++ b/archive/sgq_dd.c
@@ -15,13 +15,14 @@
#include <sys/sysmacros.h>
#include <sys/poll.h>
#include <linux/major.h>
+#include <sys/time.h>
typedef unsigned char u_char; /* horrible, for scsi.h */
#include "sg_include.h"
#include "sg_err.h"
#include "llseek.h"
/* A utility program for the Linux OS SCSI generic ("sg") device driver.
-* Copyright (C) 1999, 2000 D. Gilbert and P. Allworth
+* Copyright (C) 1999-2002 D. Gilbert and P. Allworth
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
@@ -47,7 +48,7 @@ typedef unsigned char u_char; /* horrible, for scsi.h */
*/
-static char * version_str = "0.52 20010819";
+static char * version_str = "0.53 20020124";
#define DEF_BLOCK_SIZE 512
#define DEF_BLOCKS_PER_TRANSFER 128
@@ -79,6 +80,11 @@ static char * version_str = "0.52 20010819";
#define QS_IN_POLL 11
#define QS_OUT_POLL 12
+#define STR_SZ 1024
+#define INOUTF_SZ 512
+#define EBUFF_SZ 512
+
+
struct request_element;
typedef struct request_collection
@@ -209,11 +215,13 @@ int dd_filetype(const char * filename)
void usage()
{
fprintf(stderr, "Usage: "
- "sgq_dd [if=<infile>] [skip=<n>] [of=<ofile>] [seek=<n>]\n"
- " [bs=<num>] [bpt=<num>] [count=<n>]\n"
- " [dio=<n>] [thr=<n>] [coe=<n>] [gen=<n>]\n"
- " [deb=<n>] [--version]\n"
- " usually either 'if' or 'of' is a sg or raw device\n"
+ "sgq_dd [if=<infile>] [skip=<n>] [of=<ofile>] [seek=<n>] "
+ "[bs=<num>]\n"
+ " [bpt=<num>] [count=<n>] [dio=<n>] [thr=<n>] "
+ "[coe=<n>] [gen=<n>]\n"
+ " [dio=<n>] [thr=<n>] [coe=<n>] [gen=<n>] "
+ "[deb=<n>] [--version]\n"
+ " usually either 'if' or 'of' is a sg or raw device\n"
" 'bpt' is blocks_per_transfer (default is 128)\n"
" 'dio' is direct IO, 1->attempt, 0->indirect IO (def)\n"
" 'thr' is number of queues, must be > 0, default 4, max 32\n");
@@ -524,9 +532,9 @@ int sg_finish_io(int wr, Rq_elem * rep)
return 1;
default:
{
- char ebuff[64];
- sprintf(ebuff, "%s blk=%d", rep->wr ? "writing": "reading",
- rep->blk);
+ char ebuff[EBUFF_SZ];
+ snprintf(ebuff, EBUFF_SZ, "%s blk=%d",
+ rep->wr ? "writing": "reading", rep->blk);
sg_chk_n_print3(ebuff, hp);
return -1;
}
@@ -580,7 +588,7 @@ int prepare_rq_elems(Rq_coll * clp, const char * inf, const char * outf)
int k;
Rq_elem * rep;
size_t psz;
- char ebuff[256];
+ char ebuff[EBUFF_SZ];
int sz = clp->bpt * clp->bs;
int scsi_type;
@@ -605,8 +613,8 @@ int prepare_rq_elems(Rq_coll * clp, const char * inf, const char * outf)
rep->infd = clp->infd;
else {
if ((rep->infd = open(inf, O_RDWR)) < 0) {
- sprintf(ebuff, "sgq_dd: could not open %s for sg reading",
- inf);
+ snprintf(ebuff, EBUFF_SZ,
+ "sgq_dd: could not open %s for sg reading", inf);
perror(ebuff);
return 1;
}
@@ -627,8 +635,8 @@ int prepare_rq_elems(Rq_coll * clp, const char * inf, const char * outf)
rep->outfd = clp->outfd;
else {
if ((rep->outfd = open(outf, O_RDWR)) < 0) {
- sprintf(ebuff, "sgq_dd: could not open %s for sg writing",
- outf);
+ snprintf(ebuff, EBUFF_SZ,
+ "sgq_dd: could not open %s for sg writing", outf);
perror(ebuff);
return 1;
}
@@ -742,10 +750,12 @@ int main(int argc, char * argv[])
int out_num_sect = 0;
int num_threads = DEF_NUM_THREADS;
int gen = 0;
+ int do_time = 0;
int in_sect_sz, out_sect_sz, first_xfer, qstate, req_index, seek_skip;
int blocks, stop_after_write, terminate;
- char ebuff[256];
+ char ebuff[EBUFF_SZ];
Rq_elem * rep;
+ struct timeval start_tm, end_tm;
memset(&rcoll, 0, sizeof(Rq_coll));
rcoll.bpt = DEF_BLOCKS_PER_TRANSFER;
@@ -760,7 +770,7 @@ int main(int argc, char * argv[])
for(k = 1; k < argc; k++) {
if (argv[k])
- strcpy(str, argv[k]);
+ strncpy(str, argv[k], STR_SZ);
else
continue;
for(key = str, buf = key; *buf && *buf != '=';)
@@ -768,9 +778,9 @@ int main(int argc, char * argv[])
if (*buf)
*buf++ = '\0';
if (strcmp(key,"if") == 0)
- strcpy(inf, buf);
+ strncpy(inf, buf, INOUTF_SZ);
else if (strcmp(key,"of") == 0)
- strcpy(outf, buf);
+ strncpy(outf, buf, INOUTF_SZ);
else if (0 == strcmp(key,"ibs"))
ibs = get_num(buf);
else if (0 == strcmp(key,"obs"))
@@ -795,6 +805,8 @@ int main(int argc, char * argv[])
gen = get_num(buf);
else if (0 == strncmp(key,"deb", 3))
rcoll.debug = get_num(buf);
+ else if (0 == strcmp(key,"time"))
+ do_time = get_num(buf);
else if (0 == strncmp(key, "--vers", 6)) {
fprintf(stderr, "sgq_dd for sg version 3 driver: %s\n",
version_str);
@@ -840,15 +852,16 @@ int main(int argc, char * argv[])
if (FT_SG == rcoll.in_type) {
if ((rcoll.infd = open(inf, O_RDWR)) < 0) {
- sprintf(ebuff, "sgq_dd: could not open %s for sg reading",
- inf);
+ snprintf(ebuff, EBUFF_SZ,
+ "sgq_dd: could not open %s for sg reading", inf);
perror(ebuff);
return 1;
}
}
if (FT_SG != rcoll.in_type) {
if ((rcoll.infd = open(inf, O_RDONLY)) < 0) {
- sprintf(ebuff, "sgq_dd: could not open %s for reading", inf);
+ snprintf(ebuff, EBUFF_SZ,
+ "sgq_dd: could not open %s for reading", inf);
perror(ebuff);
return 1;
}
@@ -857,7 +870,7 @@ int main(int argc, char * argv[])
offset *= rcoll.bs; /* could exceed 32 here! */
if (llse_llseek(rcoll.infd, offset, SEEK_SET) < 0) {
- sprintf(ebuff,
+ snprintf(ebuff, EBUFF_SZ,
"sgq_dd: couldn't skip to required position on %s", inf);
perror(ebuff);
return 1;
@@ -870,7 +883,7 @@ int main(int argc, char * argv[])
if (FT_SG == rcoll.out_type) {
if ((rcoll.outfd = open(outf, O_RDWR)) < 0) {
- sprintf(ebuff,
+ snprintf(ebuff, EBUFF_SZ,
"sgq_dd: could not open %s for sg writing", outf);
perror(ebuff);
return 1;
@@ -879,7 +892,7 @@ int main(int argc, char * argv[])
else {
if (FT_OTHER == rcoll.out_type) {
if ((rcoll.outfd = open(outf, O_WRONLY | O_CREAT, 0666)) < 0) {
- sprintf(ebuff,
+ snprintf(ebuff, EBUFF_SZ,
"sgq_dd: could not open %s for writing", outf);
perror(ebuff);
return 1;
@@ -887,7 +900,7 @@ int main(int argc, char * argv[])
}
else {
if ((rcoll.outfd = open(outf, O_WRONLY)) < 0) {
- sprintf(ebuff,
+ snprintf(ebuff, EBUFF_SZ,
"sgq_dd: could not open %s for raw writing", outf);
perror(ebuff);
return 1;
@@ -898,7 +911,7 @@ int main(int argc, char * argv[])
offset *= rcoll.bs; /* could exceed 32 bits here! */
if (llse_llseek(rcoll.outfd, offset, SEEK_SET) < 0) {
- sprintf(ebuff,
+ snprintf(ebuff, EBUFF_SZ,
"sgq_dd: couldn't seek to required position on %s", outf);
perror(ebuff);
return 1;
@@ -987,6 +1000,11 @@ int main(int argc, char * argv[])
stop_after_write = 0;
terminate = 0;
seek_skip = rcoll.seek - rcoll.skip;
+ if (do_time) {
+ start_tm.tv_sec = 0;
+ start_tm.tv_usec = 0;
+ gettimeofday(&start_tm, NULL);
+ }
while (rcoll.out_done_count > 0) { /* >>>>>>>>> main loop */
req_index = -1;
qstate = decider(&rcoll, first_xfer, &req_index);
@@ -1104,6 +1122,28 @@ int main(int argc, char * argv[])
break;
} /* >>>>>>>>>>>>> end of main loop */
+ if ((do_time) && (start_tm.tv_sec || start_tm.tv_usec)) {
+ struct timeval res_tm;
+ double a, b;
+
+ gettimeofday(&end_tm, NULL);
+ res_tm.tv_sec = end_tm.tv_sec - start_tm.tv_sec;
+ res_tm.tv_usec = end_tm.tv_usec - start_tm.tv_usec;
+ if (res_tm.tv_usec < 0) {
+ --res_tm.tv_sec;
+ res_tm.tv_usec += 1000000;
+ }
+ a = res_tm.tv_sec;
+ a += (0.000001 * res_tm.tv_usec);
+ b = (double)rcoll.bs * (dd_count - rcoll.out_done_count);
+ printf("time to transfer data was %d.%06d secs",
+ (int)res_tm.tv_sec, (int)res_tm.tv_usec);
+ if ((a > 0.00001) && (b > 511))
+ printf(", %.2f MB/sec\n", b / (a * 1000000.0));
+ else
+ printf("\n");
+ }
+
if (STDIN_FILENO != rcoll.infd)
close(rcoll.infd);
if (STDOUT_FILENO != rcoll.outfd)
diff --git a/archive/sgs_dd.c b/archive/sgs_dd.c
index b9b4e60e..ff329a33 100644
--- a/archive/sgs_dd.c
+++ b/archive/sgs_dd.c
@@ -44,7 +44,7 @@
This version should compile with Linux sg drivers with version numbers
>= 30000 . Also this version tries to use real time signals.
- Version 3.982 20000827
+ Version 3.99 20020126
6 byte commands [READ: 0x08, WRITE: 0x0a]:
@@ -79,6 +79,12 @@
#define SGQ_CAN_WRITE 2
#define SGQ_TIMEOUT 4
+
+#define STR_SZ 1024
+#define INOUTF_SZ 512
+#define EBUFF_SZ 512
+
+
typedef struct request_element
{
struct request_element * nextp;
@@ -362,7 +368,7 @@ int start_read(Rq_coll * clp)
int blocks = (clp->in_count > clp->bpt) ? clp->bpt : clp->in_count;
Rq_elem * rep = clp->rd_posp;
int buf_sz, res;
- char ebuff[256];
+ char ebuff[EBUFF_SZ];
#ifdef SG_DEBUG
printf("start_read, elem idx=%d\n", rep - clp->elem);
@@ -399,7 +405,7 @@ int start_read(Rq_coll * clp)
(EINTR == errno))
;
if (res < 0) {
- sprintf(ebuff, "sgs_dd: reading, in_blk=%d ", rep->blk);
+ snprintf(ebuff, EBUFF_SZ, "sgs_dd: reading, in_blk=%d ", rep->blk);
perror(ebuff);
rep->state = SGQ_IO_ERR;
return res;
@@ -430,7 +436,7 @@ int start_write(Rq_coll * clp)
{
Rq_elem * rep = clp->wr_posp;
int res, blocks;
- char ebuff[256];
+ char ebuff[EBUFF_SZ];
while ((0 != rep->wr) || (SGQ_IO_FINISHED != rep->state)) {
rep = rep->nextp;
@@ -461,7 +467,7 @@ int start_write(Rq_coll * clp)
rep->num_blks * clp->bs)) < 0) && (EINTR == errno))
;
if (res < 0) {
- sprintf(ebuff, "sgs_dd: output, out_blk=%d ", rep->blk);
+ snprintf(ebuff, EBUFF_SZ, "sgs_dd: output, out_blk=%d ", rep->blk);
perror(ebuff);
rep->state = SGQ_IO_ERR;
return res;
@@ -654,16 +660,16 @@ int main(int argc, char * argv[])
int ibs = 0;
int obs = 0;
int count = -1;
- char str[512];
+ char str[STR_SZ];
char * key;
char * buf;
- char inf[512];
- char outf[512];
+ char inf[INOUTF_SZ];
+ char outf[INOUTF_SZ];
int res, k;
int in_num_sect = 0;
int out_num_sect = 0;
int in_sect_sz, out_sect_sz, crw;
- char ebuff[256];
+ char ebuff[EBUFF_SZ];
Rq_coll rcoll;
memset(&rcoll, 0, sizeof(Rq_coll));
@@ -676,8 +682,10 @@ int main(int argc, char * argv[])
}
for(k = 1; k < argc; k++) {
- if (argv[k])
- strcpy(str, argv[k]);
+ if (argv[k]) {
+ strncpy(str, argv[k], STR_SZ);
+ str[STR_SZ - 1] = '\0';
+ }
else
continue;
for(key = str, buf = key; *buf && *buf != '=';)
@@ -685,9 +693,9 @@ int main(int argc, char * argv[])
if (*buf)
*buf++ = '\0';
if (strcmp(key,"if") == 0)
- strcpy(inf, buf);
+ strncpy(inf, buf, INOUTF_SZ);
else if (strcmp(key,"of") == 0)
- strcpy(outf, buf);
+ strncpy(outf, buf, INOUTF_SZ);
else if (0 == strcmp(key,"ibs"))
ibs = get_num(buf);
else if (0 == strcmp(key,"obs"))
@@ -733,7 +741,8 @@ int main(int argc, char * argv[])
rcoll.outfd = STDOUT_FILENO;
if (inf[0] && ('-' != inf[0])) {
if ((rcoll.infd = open(inf, O_RDONLY)) < 0) {
- sprintf(ebuff, "sgs_dd: could not open %s for reading", inf);
+ snprintf(ebuff, EBUFF_SZ, "sgs_dd: could not open %s for reading",
+ inf);
perror(ebuff);
return 1;
}
@@ -744,7 +753,7 @@ int main(int argc, char * argv[])
offset *= rcoll.bs; /* could overflow here! */
if (lseek(rcoll.infd, offset, SEEK_SET) < 0) {
- sprintf(ebuff,
+ snprintf(ebuff, EBUFF_SZ,
"sgs_dd: couldn't skip to required position on %s", inf);
perror(ebuff);
return 1;
@@ -777,8 +786,8 @@ int main(int argc, char * argv[])
}
if (! rcoll.out_is_sg) {
if ((rcoll.outfd = open(outf, O_WRONLY | O_CREAT, 0666)) < 0) {
- sprintf(ebuff,
- "sgs_dd: could not open %s for writing", outf);
+ snprintf(ebuff, EBUFF_SZ,
+ "sgs_dd: could not open %s for writing", outf);
perror(ebuff);
return 1;
}
@@ -787,7 +796,7 @@ int main(int argc, char * argv[])
offset *= rcoll.bs; /* could overflow here! */
if (lseek(rcoll.outfd, offset, SEEK_SET) < 0) {
- sprintf(ebuff,
+ snprintf(ebuff, EBUFF_SZ,
"sgs_dd: couldn't seek to required position on %s", outf);
perror(ebuff);
return 1;