Reputation:
I have been working on a program which reads data from harddisks. And I wonder is it better to use the sda device or the sg0 device? I understand that sg0 is better used if you are gonna do things like use the sg driver for such things as inquirys etc but I want to read data from the drive... Another difference is that sg0 is a character device and sda is a block device
Upvotes: 1
Views: 6210
Reputation: 4191
The /dev/sda is a block device - you can open it from your C program by open, then read/write/seek/pread/pwrite (regular Linux I/O functions!) it, then close it.
The "sg" driver is a more intelligent and more uniform way to access storage devices - you need to form a SCSI command to send something to the device via the "sg" driver and you need to parse the message it will send you back.
For more info please look here.
Upvotes: 1