Projects / sg3_utils / Comments

Comments for sg3_utils

05 Apr 2014 17:59 dpgilbert

The proposed read-only flag added to sg_sat_set_features and will appear in version 1.39. Best to email patches like that directly to me as I don't check this site that often.

More information about sg_xcopy: its xcopy(lid1) functionality has been ported to ddpt (https://freecode.com/projects/ddpt). Further, ODX support (aka: xcopy v2, lite) is being added to ddpt and will appear shortly.

10 Dec 2013 00:05 lucasrangit

Using sg_sat_set_features to send EPC (TAPM) power commands requires ability to open device as read-only otherwise, drivers will wake up device and issue IDENTIFY and READ commands potentially negating power condition specified in command.

Below is a patch based off similar work in sg_start to illustrate. It works for me as I have confirmed the power condition using `hdparm -C /dev/sda` after issuing `sg_sat_set_features --feature=74 --count=0 --lba=1 /dev/sda` to transition to Standby_z (spin-down).

If this is acceptable, I would like to complete the patch to the necessary documentation and perform additional testing.

--- a/src/sg_sat_set_features.c
+++ b/src/sg_sat_set_features.c
@@ -55,6 +55,7 @@
{"help", no_argument, 0, 'h'},
{"len", required_argument, 0, 'l'},
{"lba", required_argument, 0, 'L'},
+ {"readonly", no_argument, 0, 'r'},
{"verbose", no_argument, 0, 'v'},
{"version", no_argument, 0, 'V'},
{0, 0, 0, 0},
@@ -79,6 +80,9 @@
" --lba=LBA | -L LBA LBA field contents (def: 0)\n"
" --len=16|12 | -l 16|12 cdb length: 16 or 12 bytes "
"(def: 16)\n"
+ " --readonly | -r open DEVICE read-only "
+ "(def: read-write)\n"
+ " recommended if DEVICE is ATA disk\n"
" --verbose | -v increase verbosity\n"
" --version | -V print version string and exit\n\n"
"Sends an ATA SET FEATURES command via a SAT pass through.\n"
@@ -256,12 +260,13 @@
int lba = 0;
int verbose = 0;
int ck_cond = 0;
+ int rdonly = 0;
int cdb_len = SAT_ATA_PASS_THROUGH16_LEN;

while (1) {
int option_index = 0;

- c = getopt_long(argc, argv, "c:Cf:hl:L:vV", long_options,
+ c = getopt_long(argc, argv, "c:Cf:hl:L:rvV", long_options,
&option_index);
if (c == -1)
break;
@@ -302,6 +307,8 @@
return SG_LIB_SYNTAX_ERROR;
}
break;
+ case 'r':
+ rdonly = 1;
case 'v':
++verbose;
break;
@@ -334,7 +341,7 @@
return 1;
}

- if ((sg_fd = sg_cmds_open_device(device_name, 0 /* rw */,
+ if ((sg_fd = sg_cmds_open_device(device_name, rdonly,
verbose)) < 0) {
fprintf(stderr, "error opening file: %s: %s\n",
device_name, safe_strerror(-sg_fd));

03 Jun 2013 21:52 dpgilbert

'Does sdparm support SCSI FW download?' No but sg_write_buffer in this package does.

03 Jun 2013 21:49 dpgilbert

With regard to the sg_xcopy offer by yuvalkashtan, a sg_xcopy (and sg_copy_results) was added in version 1.34 . There have been several extensions and fixes added in versions 1.35 and 1.36 . Are there more features that you could suggest for sg_xcopy?

25 Apr 2013 16:01 Tom4015

Does Sdparm support SCSI FW download?

25 Jan 2012 16:42 yuvalkashtan

We have developed sg_xcopy and would like to submit it.
Supposed to work for every VAAI (VMWare accelerated...) compliant storage system.

Are you interested in adding it to the sg3_utils? or otherwise we'll open a new package.

TIA,
Yuval.

04 Aug 2011 03:08 dpgilbert

The x64 windows problem reported by xu_john with the DataBufferOffset field has been fixed. That fix will appear in version 1.33 .
As for OS X, Apple have an aversion to generic SCSI pass-throughs. They suggest writing a special driver for each type of controller if I understand their explanation. I have no intention of doing that.

25 Feb 2011 08:22 KeithLocke

I have used the sg3_utils for years on Linux, and it is one of the greatest set of tools ever created, but now I am in need of these features on OS X 10.6.6. I have been unable to get the source to build, any direction would be greatly appreciated.

20 Feb 2011 02:17 xu_john

sg_utils(sg_inq) not work in x64 windows(2003 and 2008) using VS2005

The DeviceIoControl return error code 1306, the root cause is a field of
SCSI_PASS_THROUGH structure using wrong data type,

in file sg_pt_win32.h file
ULONG DataBufferOffset;

but in MSDN, it's
ULONG_PTR DataBufferOffset;

In 32bit Windows, the ULONG and ULONG_PRT is the same size(4bytes), but for
64bit Windows, the ULONG_PTR is 8bytes, and ULONG only 4bytes, After change
the data type the sg_inq work fine.

Not sure here existing any other different type between the sg_utils and MSDN.

17 Feb 2011 20:51 dpgilbert

The utilities in sg3_utils send SCSI commands through the Windows SPT pass-through interface. If the recipient understands SCSI commands (or something in between translates them (e.g. as per the SAT standard)) then these utilities will work. So they won't work with a directly attached SATA drive (e.g. to a SATA controller with a AHCI driver) but they will work if the same disk is connected via a SAS controller. In Linux, all SATA disks are controlled via SCSI commands, either by hardware/firmware (e.g. in a SAS controller) or via a software layer called libata. Maybe one day MS will follow ...

Screenshot

Project Spotlight

ReciJournal

An open, cross-platform journaling program.

Screenshot

Project Spotlight

Veusz

A scientific plotting package.