Thanks for your reply.
Yes i agree, this is what i am trying to achieve, i get the data from MODE SENSE(10), with page code 0x05, which completes successfully. I then use this data to send back using MODE SELECT(10) in the same format as i received the data, the command descriptor block i am using for the MODE SELECT(10) is:
0x55, 0, 0, 0, 0, 0, 0, 0, 50, 0;
But i have also tried 0x10 and 0x11 for the second byte as i read somewhere that the PF bit should be set and so i also tried setting the SP bit. I've also tried setting the 50 to 58 to include the size of the header, but i feel this is wrong and it also didn't help.
Anyway they all have the same effect. The command makes the changes to the logical unit, but EIO is returned in the sense buffer of the sg_io_hdr struct. I will need to know that the command has completed, although i suppose i can do so by re-checking the values with a subsequent read.
Looking at the Linux docs EIO on a write is given as:
Size given as 3rd argument less than size of old
header structure (sg_header). Additionally a write()
with the old header will yield this error for most
detected malformed requests.
I don't really understand the size issue (i've tried adjusting the command block size field in the header which seems to make no difference and as far as i can tell should be 0x0a) and i would have thought a malformed request would not be executed by the logical unit.