user2882307
user2882307

Reputation:

raw hard disk acces /dev/sd[x] vs /dev/sg[y]?

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

Answers (1)

HEKTO
HEKTO

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

Related Questions