From 96bf80c3ed8fca53934b430d55a2e0968a181db3 Mon Sep 17 00:00:00 2001
From: Brian Behlendorf <behlendorf1@llnl.gov>
Date: Fri, 14 Aug 2009 10:09:22 -0700
Subject: [PATCH 1/2] Explicit check for requires_* rpm defines Due to
 different distros and/or versions of rpm mishandling the shorthand syntax
 simply use the longer version which get interpreted correctly.

---
 zfs-modules.spec.in | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/zfs-modules.spec.in b/zfs-modules.spec.in
index fc67b53098..0af1a01bd2 100644
--- a/zfs-modules.spec.in
+++ b/zfs-modules.spec.in
@@ -3,9 +3,17 @@
 # require_kver, require_kdir, require_obj constants for us, but if it does not
 # not we attempt to determine the correct values based on your distro.
 
-%{?require_kver: %define kver %{require_kver}}
-%{?require_kdir: %define kdir %{require_kdir}}
-%{?require_kobj: %define kobj %{require_kobj}}
+%if %{defined require_kver}
+%define kver %{require_kver}
+%endif
+
+%if %{defined require_kdir}
+%define kdir %{require_kdir}
+%endif
+
+%if %{defined require_kobj}
+%define kobj %{require_kobj}
+%endif
 
 # kdir:    Full path to the kernel source headers
 # kobj:    Full path to the kernel build objects
@@ -14,9 +22,17 @@
 # kdevpkg: Kernel devel package name
 # kverpkg: Kernel package version
 
-%{?require_splver: %define splver %{require_splver}}
-%{?require_spldir: %define spldir %{require_spldir}}
-%{?require_splobj: %define splobj %{require_splobj}}
+%if %{defined require_splver}
+%define splver %{require_splver}
+%endif
+
+%if %{defined require_spldir}
+%define spldir %{require_spldir}
+%endif
+
+%if %{defined require_splobj}
+%define splobj %{require_splobj}
+%endif
 
 # spldir:    Full path to the spl source headers
 # splobj:    Full path to the spl build objects

From e6b541db64b6bd103807f9215e2d2356954d28df Mon Sep 17 00:00:00 2001
From: Brian Behlendorf <behlendorf1@llnl.gov>
Date: Fri, 14 Aug 2009 10:11:03 -0700
Subject: [PATCH 2/2] All calls to ftruncate() must have their return code
 checked. Under FC11 rpm builds by default add the --fortify-source option
 which ensures that functions flagged with certain attributes must have their
 return codes checked.  Normally this is just a warning but we always build
 with -Werror so this is fatal.  Simply wrap the function in a verify call to
 ensure we catch a failure if there is one.

---
 cmd/ztest/ztest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c
index 746db0c070..0e9d079a93 100644
--- a/cmd/ztest/ztest.c
+++ b/cmd/ztest/ztest.c
@@ -1161,7 +1161,7 @@ grow_vdev(vdev_t *vd, void *arg)
 		return (vd);
 
 	fsize = lseek(fd, 0, SEEK_END);
-	(void) ftruncate(fd, *newsize);
+	VERIFY(ftruncate(fd, *newsize) == 0);
 
 	if (zopt_verbose >= 6) {
 		(void) printf("%s grew from %lu to %lu bytes\n",