]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
Improved Makefile to use kernel uapi header.
authorStephen Bates <sbates@raithlin.com>
Sun, 15 Mar 2015 22:41:41 +0000 (16:41 -0600)
committerStephen Bates <sbates@raithlin.com>
Sun, 15 Mar 2015 22:41:41 +0000 (16:41 -0600)
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.

Makefile
regress

index db88e038722244924e2d3bec6c69c3932b76e313..b005929bbab4fc1d5f6df6576e7148cd1a0aff58 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -9,9 +9,19 @@ ifeq ($(LIBUDEV),0)
        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
diff --git a/regress b/regress
index 9c5dd4f5842455f0b274c6c8739727b65ba7aeb5..b7c36f12fabfa9c91d64f2e0cf2226f238371d0f 100755 (executable)
--- a/regress
+++ b/regress
@@ -81,12 +81,12 @@ function run_test {
 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}