From c0d4544d4bc6648f8168f62d8846fb345e959e6f Mon Sep 17 00:00:00 2001 From: Stephen Bates Date: Sun, 15 Mar 2015 16:41:41 -0600 Subject: [PATCH] Improved Makefile to use kernel uapi header. 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 | 12 +++++++++++- regress | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index db88e038..b005929b 100644 --- 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 9c5dd4f5..b7c36f12 100755 --- 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} -- 2.50.1