From 9ea50714469c0c5773178222ae6b745701ac9076 Mon Sep 17 00:00:00 2001
From: Amir Goldstein <amir73il@aquasec.com>
Date: Mon, 17 Oct 2016 21:10:46 +0300
Subject: [PATCH] projectquota: fix build failure with new kernels

In kernel version >= v4.5 the project quota ioctl definitions
have been made public via the include/uapi/linux/fs.h API, so
that ext4 could use the same API.

Avoid re-defining the ioctl API if it is already defined in fs.h.

Signed-off-by: Amir Goldstein <amir73il@aquasec.com>
---
 daemon/graphdriver/projectquota.go | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/daemon/graphdriver/projectquota.go b/daemon/graphdriver/projectquota.go
index 82ee5011c4..e2004b950f 100644
--- a/daemon/graphdriver/projectquota.go
+++ b/daemon/graphdriver/projectquota.go
@@ -17,6 +17,8 @@ package graphdriver
 #include <linux/fs.h>
 #include <linux/quota.h>
 #include <linux/dqblk_xfs.h>
+
+#ifndef FS_XFLAG_PROJINHERIT
 struct fsxattr {
 	__u32		fsx_xflags;
 	__u32		fsx_extsize;
@@ -25,13 +27,26 @@ struct fsxattr {
 	unsigned char	fsx_pad[12];
 };
 #define FS_XFLAG_PROJINHERIT	0x00000200
+#endif
+#ifndef FS_IOC_FSGETXATTR
 #define FS_IOC_FSGETXATTR		_IOR ('X', 31, struct fsxattr)
+#endif
+#ifndef FS_IOC_FSSETXATTR
 #define FS_IOC_FSSETXATTR		_IOW ('X', 32, struct fsxattr)
+#endif
 
+#ifndef PRJQUOTA
 #define PRJQUOTA	2
+#endif
+#ifndef XFS_PROJ_QUOTA
 #define XFS_PROJ_QUOTA	2
+#endif
+#ifndef Q_XSETPQLIM
 #define Q_XSETPQLIM QCMD(Q_XSETQLIM, PRJQUOTA)
+#endif
+#ifndef Q_XGETPQUOTA
 #define Q_XGETPQUOTA QCMD(Q_XGETQUOTA, PRJQUOTA)
+#endif
 */
 import "C"
 import (