Re: [PATCH] squashfs: Add posix acl support

2018-04-09 Thread kbuild test robot
Hi Geliang,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on v4.16]
[also build test ERROR on next-20180409]
[cannot apply to squashfs/master]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]

url:
https://github.com/0day-ci/linux/commits/Geliang-Tang/squashfs-Add-posix-acl-support/20180410-013038
config: i386-randconfig-s0-201814 (attached as .config)
compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026
reproduce:
# save the attached .config to linux build tree
make ARCH=i386 

All errors (new ones prefixed by >>):

>> ERROR: "squashfs_get_acl" [fs/squashfs/squashfs.ko] undefined!

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


.config.gz
Description: application/gzip


[PATCH] squashfs: Add posix acl support

2018-04-09 Thread Geliang Tang
Add posix acl (Access Control Lists) support for squashfs, which is
marked as a todo item in squashfs' documentation.  This patch implements
the squashfs_get_acl function to read file's acl information from its
xattr lists.

Signed-off-by: Geliang Tang 
---
 Documentation/filesystems/squashfs.txt |  2 -
 fs/squashfs/Kconfig| 11 ++
 fs/squashfs/Makefile   |  1 +
 fs/squashfs/acl.c  | 69 ++
 fs/squashfs/acl.h  | 27 +
 fs/squashfs/inode.c|  4 +-
 fs/squashfs/namei.c|  6 ++-
 fs/squashfs/squashfs_fs.h  | 12 +++---
 fs/squashfs/super.c|  3 ++
 fs/squashfs/symlink.c  |  6 ++-
 fs/squashfs/xattr.c| 13 ++-
 fs/squashfs/xattr.h|  8 
 12 files changed, 149 insertions(+), 13 deletions(-)
 create mode 100644 fs/squashfs/acl.c
 create mode 100644 fs/squashfs/acl.h

diff --git a/Documentation/filesystems/squashfs.txt 
b/Documentation/filesystems/squashfs.txt
index e5274f84dc56..539fad6b4db0 100644
--- a/Documentation/filesystems/squashfs.txt
+++ b/Documentation/filesystems/squashfs.txt
@@ -235,8 +235,6 @@ list using a second xattr id lookup table.
 4.1 Todo list
 -
 
-Implement ACL support.
-
 4.2 Squashfs internal cache
 ---
 
diff --git a/fs/squashfs/Kconfig b/fs/squashfs/Kconfig
index 1adb3346b9d6..f9587bcf9dd9 100644
--- a/fs/squashfs/Kconfig
+++ b/fs/squashfs/Kconfig
@@ -107,6 +107,17 @@ config SQUASHFS_XATTR
 
  If unsure, say N.
 
+config SQUASHFS_POSIX_ACL
+   bool "Squashfs POSIX ACL support"
+   depends on SQUASHFS_XATTR
+   select FS_POSIX_ACL
+   help
+ Saying Y here includes support for Access Control Lists (acls).
+ Acls are used to define more fine-grained discretionary access
+ rights for files and directories (see the acl(5) manual page).
+
+ If unsure, say N.
+
 config SQUASHFS_ZLIB
bool "Include support for ZLIB compressed file systems"
depends on SQUASHFS
diff --git a/fs/squashfs/Makefile b/fs/squashfs/Makefile
index 7bd9b8b856d0..73bc1c8a8df6 100644
--- a/fs/squashfs/Makefile
+++ b/fs/squashfs/Makefile
@@ -12,6 +12,7 @@ squashfs-$(CONFIG_SQUASHFS_DECOMP_SINGLE) += 
decompressor_single.o
 squashfs-$(CONFIG_SQUASHFS_DECOMP_MULTI) += decompressor_multi.o
 squashfs-$(CONFIG_SQUASHFS_DECOMP_MULTI_PERCPU) += decompressor_multi_percpu.o
 squashfs-$(CONFIG_SQUASHFS_XATTR) += xattr.o xattr_id.o
+squashfs-$(CONFIG_SQUASHFS_POSIX_ACL) += acl.o
 squashfs-$(CONFIG_SQUASHFS_LZ4) += lz4_wrapper.o
 squashfs-$(CONFIG_SQUASHFS_LZO) += lzo_wrapper.o
 squashfs-$(CONFIG_SQUASHFS_XZ) += xz_wrapper.o
diff --git a/fs/squashfs/acl.c b/fs/squashfs/acl.c
new file mode 100644
index ..1c9eb2d13c2b
--- /dev/null
+++ b/fs/squashfs/acl.c
@@ -0,0 +1,69 @@
+/*
+ * Squashfs - a compressed read only filesystem for Linux
+ *
+ * Copyright (c) 2018
+ * Phillip Lougher 
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * acl.c
+ */
+
+#include 
+#include 
+#include 
+#include "squashfs_fs.h"
+#include "xattr.h"
+#include "acl.h"
+
+struct posix_acl *squashfs_get_acl(struct inode *inode, int type)
+{
+   int name_index;
+   char *name;
+   struct posix_acl *acl = NULL;
+   char *value = NULL;
+   int retval;
+
+   switch (type) {
+   case ACL_TYPE_ACCESS:
+   name_index = SQUASHFS_XATTR_POSIX_ACL_ACCESS;
+   name = XATTR_POSIX_ACL_ACCESS;
+   break;
+   case ACL_TYPE_DEFAULT:
+   name_index = SQUASHFS_XATTR_POSIX_ACL_DEFAULT;
+   name = XATTR_POSIX_ACL_DEFAULT;
+   break;
+   default:
+   BUG();
+   }
+
+   retval = squashfs_xattr_get(inode, name_index, name, NULL, 0);
+   if (retval > 0) {
+   value = kmalloc(retval, GFP_KERNEL);
+   if (!value)
+   return ERR_PTR(-ENOMEM);
+   retval = squashfs_xattr_get(inode, name_index, name, value, 
retval);
+   }
+   if (retval > 0)
+   acl = posix_acl_from_xattr(_user_ns, value, retval);
+   else if (retval ==