Ich versuche, die sed-Opal-Bibliotheken in der das tunOPAL-SED-Bibliothek ioctl Verwendung?
4.11 Linux-Kernel hinzugefügt zu verwenden, ich habe ein Basisprogramm wie folgt geschrieben:
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <linux/nvme_ioctl.h>
#include <uapi/linux/sed-opal.h>
#include <fcntl.h>
#include <linux/types.h>
int main()
{
int f_desc;
printf("Trying to open device /dev/nvme0...\n");
f_desc = open("/dev/nvme0", O_RDWR);
if(f_desc == 0)
{
printf("Could not open the file..\n");
}
else
{
printf("Open call returns : %d\n", f_desc);
}
struct nvme_admin_cmd cmd = {
.opcode = 0x81, //0x81 Security Send. 0x82 Security Receive
.nsid = 0xffffffff,
.cdw10 = 0x02000000,
};
int ret_ioctl_value;
ret_ioctl_value = ioctl(f_desc, IOC_OPAL_REVERT_TPR, &cmd);
printf("ioctl returned value : %d \n", ret_ioctl_value);
perror("Flush");
close(f_desc);
}
Problem kommt, wenn ich verwenden will Die sed-opal-Bibliothek ioctl-Befehle wie im obigen Code erwähnt.
Error is like:-
Trying to open device /dev/nvme0...
Open call returns : 3
ioctl returned value : -1
Flush: Inappropriate ioctl for device
Error is like:-
Trying to open device /dev/nvme0...
Open call returns : 3
ioctl returned value : -1
Flush: Inappropriate ioctl for device
Ist dies der richtige Weg, um die Security SEND/RECV Befehle zu senden?
Wenn ja, was könnte die mögliche Ursache für den Fehler sein?
Jede Hilfe wird geschätzt. :)
Danke.
Note:
- With the above code the basic NVMe protocol specific ADMIN commands works and i am able to receive response of a SMART health log page from the device.
- I have built /usr/src/linux/block/ directory by Enabling the "Logic for interfacing with OPAL enabled SEDs" from the menuconfig.
- Using 4.13.9 kernel level right now.
=========================================== ===========
Edit:
So it is supposed to be done as follows:
open(/dev/nvme0n1");
set up opal_structures here from /uapi/linux/sed-opal.h
ioctl(fd, IOC_OPAL_*, &struct_from_above);
können wir sed_ioctl direkt im Userspace-Programm verwenden ?? – user3453931
Ja, wir können es im Userspace verwenden. Definition ist in sed-opal.h, die Sie enthalten haben. Versuche es und antworte. – Devidas
Ich habe den sed-opal von uapi/linux/sed-opal.h hinzugefügt. Die sed_ioctl, die Sie erwähnen, stammt aus /linux/sed-opal.h und ist verfügbar, um von anderen Kernel-Modulen verwendet werden zu können. Bitte können Sie mit einem Beispiel vorschlagen? – user3453931