Until now the CLI has relied on the header in the local Linux folder.
This is not safe as the kernel header may have differences that can
cause severe issues (e.g. new/different structure members). This
commit tries to use the uapi for the current kernel. Note this only
fixes at compile time.
CFLAGS += -DLIBUDEV_EXISTS
endif
+# For the uapi header file we priorize this way:
+# 1. Use /usr/src/$(uname -r)/include/uapi/linux/nvme.h
+# 2. Use ./linux/nvme.h
+
+ifneq (,$(wildcard /usr/src/linux-headers-$(shell uname -r)/include/uapi/linux/nvme.h))
+ NVME_HEADER = /usr/src/linux-headers-$(shell uname -r)/include/uapi/linux/nvme.h
+else
+ NVME_HEADER = ./linux/nvme.h
+endif
+
default: $(NVME)
-nvme: nvme.c ./linux/nvme.h argconfig.o suffix.o
+nvme: nvme.c $(NVME_HEADER) argconfig.o suffix.o
$(CC) $(CFLAGS) nvme.c $(LDFLAGS) -o $(NVME) argconfig.o suffix.o
argconfig.o: $(SRC)/argconfig.c $(SRC)/argconfig.h $(SRC)/suffix.h
make clean > /dev/null || exit -1
make install > /dev/null || exit -1
-if $LIST ; then
+if $LIST ; then
run_test nvme list
fi
run_test nvme id-ctrl ${DEVICE}
run_test nvme id-ns -raw-binary ${DEVICE}
-run_test nvme list-ns ${DEVICE}
+run_test nvme list-ns -n 1 ${DEVICE}
run_test nvme get-ns-id ${DEVICE}
run_test nvme get-log ${DEVICE} --log-id=2 --log-len=512
run_test nvme fw-log ${DEVICE}