From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id yIi7FtWuul7oWQAA0tVLHw (envelope-from ) for ; Tue, 12 May 2020 14:12:37 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id iCKxK+Ouul5eHAAAB5/wlQ (envelope-from ) for ; Tue, 12 May 2020 14:12:51 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 5EA2D940DB8 for ; Tue, 12 May 2020 14:12:49 +0000 (UTC) Received: from localhost ([::1]:58686 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYVeM-0007yX-9d for larch@yhetil.org; Tue, 12 May 2020 10:12:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jYVeB-0007vT-3k; Tue, 12 May 2020 10:12:39 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:41516) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jYVeA-0001Bb-R4; Tue, 12 May 2020 10:12:38 -0400 Received: from [2001:980:1b4f:1:42d2:832d:bb59:862] (port=40622 helo=dundal.peder.onsbrabantnet.nl) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jYVeA-00048q-1S; Tue, 12 May 2020 10:12:38 -0400 From: Jan Nieuwenhuizen To: bug-hurd@gnu.org Subject: [PATCH] ext2fs: Update to upstream Hurd-reserved xattr index for "gnu.*". Organization: AvatarAcademy.nl X-Url: http://AvatarAcademy.nl Date: Tue, 12 May 2020 16:12:34 +0200 Message-ID: <87sgg5z1gt.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: guix-devel@gnu.org Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Scanner: scn0 X-Spam-Score: -1.01 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Scan-Result: default: False [-1.01 / 13.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; GENERIC_REPUTATION(0.00)[-0.53999008549927]; DWL_DNSWL_FAIL(0.00)[209.51.188.17:server fail]; R_SPF_ALLOW(-0.20)[+ip4:209.51.188.0/24:c]; IP_REPUTATION_HAM(0.00)[asn: 22989(0.06), country: US(-0.00), ip: 209.51.188.17(-0.54)]; TO_DN_NONE(0.00)[]; HAS_ORG_HEADER(0.00)[]; MX_GOOD(-0.50)[cached: eggs.gnu.org]; RCPT_COUNT_TWO(0.00)[2]; MAILLIST(-0.20)[mailman]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; RCVD_IN_DNSWL_FAIL(0.00)[209.51.188.17:server fail]; RCVD_TLS_LAST(0.00)[]; R_DKIM_NA(0.00)[]; ASN(0.00)[asn:22989, ipnet:209.51.188.0/24, country:US]; MID_RHS_MATCH_FROM(0.00)[]; TAGGED_FROM(0.00)[larch=yhetil.org]; ARC_NA(0.00)[]; RCVD_COUNT_FIVE(0.00)[5]; FROM_NEQ_ENVFROM(0.00)[janneke@gnu.org,guix-devel-bounces@gnu.org]; FROM_HAS_DN(0.00)[]; URIBL_BLOCKED(0.00)[summerofcode.withgoogle.com:url,outlook.com:email,gnu.org:email,computer.org:email,avataracademy.com:url,lilypond.org:url,ufmg.br:email,joyofsource.com:url]; MIME_GOOD(-0.10)[multipart/mixed,text/plain,text/x-patch]; DMARC_NA(0.00)[gnu.org]; HAS_LIST_UNSUB(-0.01)[]; MIME_TRACE(0.00)[0:+,1:+,2:+,3:+,4:+]; RWL_MAILSPIKE_POSSIBLE(0.00)[209.51.188.17:from]; FORGED_SENDER_MAILLIST(0.00)[] X-TUID: A1xtbwl5EMu9 --=-=-= Content-Type: text/plain Hello, I have looked a bit further into upstream xattr support and and have been testing that using the two attached patches. As you can see, upstream reserved INDEX 10 for the Hurd, but the Hurd has been using INDEX 7. The (trivial) patch for the Hurd to change this should be OK, but until this all fully works I'm just a bit less certain about the Linux patch. Anyway, using the patched Linux we can add gnu.translator attributes to files that are recognized by Linux (on a Hurd file system) as well as by the Hurd. So now we can actually do this --8<---------------cut here---------------start------------->8--- dd if=/dev/zero of=file bs=1k count=1000 losetup /dev/loop0 file mke2fs -t ext2 -o hurd -O ext_attr /dev/loop0 mount -t ext2 -o x-xattr-translator-records /dev/loop0 /mnt mkdir -p /mnt/servers/socket touch /mnt/servers/socket/1 setfattr --name=gnu.translator --value='/hurd/pflocal\0' /mnt/servers/socket/1 getfattr --name=gnu.translator /mnt/servers/socket/1 # file: 1 gnu.translator="/hurd/pflocal" --8<---------------cut here---------------end--------------->8--- (on GNU/Linux), and I am using that now in Guix to cross build a vm-image for the Hurd. So far, so good. However, combining these does not work yet. When I reduce libexec/runsystem to something like this --8<---------------cut here---------------start------------->8--- #! /gnu/store/s8pcby4hjxf7d4pfzrwd3ngd813i8skw-bash-minimal-5.0.16/bin/bash # XXX Guile needs pipe support for its finalizer thread to start PATH=/gnu/store/6is7b5xjdfdwzym5cfhjf7jpa3824h42-hurd-0.9-1.91a5167/bin:/gnu/store/6is7b5xjdfdwzym5cfhjf7jpa3824h42-hurd-0.9-1.91a5167/sbin:/gnu/store/a4vdhbfflmbpc346lsvl3v0plplmg5ma-attr-2.4.48/bin:/gnu/store/y9vicb9spdy9lfsipv75yy5aavwf5xyn-coreutils-8.32/bin:/gnu/store/s5kx9yqqqqbvdkxcyg1243rl4fdq139b-sed-4.8/bin:/gnu/store/wy7k8v4iik6kzh9vw1fjzcnj7jhsh5fv-util-linux-2.35.1/sbin echo foo | sed s/o/O/ echo Starting /gnu/store/6is7b5xjdfdwzym5cfhjf7jpa3824h42-hurd-0.9-1.91a5167/libexec/rc ... exec /gnu/store/6is7b5xjdfdwzym5cfhjf7jpa3824h42-hurd-0.9-1.91a5167/libexec/rc --8<---------------cut here---------------end--------------->8--- the Hurd says /gnu/store/6is7b5xjdfdwzym5cfhjf7jpa3824h42-hurd-0.9-1.91a5167/runsystem: pipe error: Translator died When I leave out the echo | sed pipe, starting Guile just hangs. When I insert this --8<---------------cut here---------------start------------->8--- fsck --yes --force / fsysopts / --writable mv /servers/socket/1 /servers/socket/1-linux touch /servers/socket/1 setfattr --name=gnu.translator --value='/hurd/pflocal\0' /servers/socket/1 --8<---------------cut here---------------end--------------->8--- it works: So, we're getting real close! \o/ And I guess there must be an incompatibility between Linux and the Hurd in how setfattr embeds the xattr attributes into the file system. How to best "diff" this aspect in the file system; how to proceed? Inspired by Shengyu's GSoC code that simply seemed to use fprintf for debbugging, I tried adding some debug printing in inode.c fprintf (stderr, "gnu.translator[%d,%d]=%s\n", datalen, strlen (*namep), *namep); but that does not seem to work, or I am looking in the wrong place. Ideas? Greetings, janneke --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ext2fs-Update-to-upstream-Hurd-reserved-xattr-index-.patch >From 75cb948c575fca3962c4cce115d31dd178bc389f Mon Sep 17 00:00:00 2001 From: "Jan (janneke) Nieuwenhuizen" Date: Tue, 12 May 2020 07:39:59 +0200 Subject: [PATCH] ext2fs: Update to upstream Hurd-reserved xattr index for "gnu.*". See https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3980bd3b406addb327d858aebd19e229ea340b9a This supports setting (and reading) of passive trasnlators from GNU/Linux, e.g. dd if=/dev/zero of=file bs=1k count=1000 losetup /dev/loop0 file mke2fs -t ext2 -o hurd -O ext_attr /dev/loop0 mount -t ext2 -o x-xattr-translator-records /dev/loop0 /mnt mkdir -p /mnt/servers/socket touch /mnt/servers/socket/1 setfattr --name=gnu.translator --value='/hurd/pflocal\0' /mnt/servers/socket/1 getfattr --name=gnu.translator /mnt/servers/socket/1 # file: 1 gnu.translator="/hurd/pflocal" * ext2fs/xattr.c (struct _xattr_prefix): For "gnu.*", use index for the Hurd (10). --- ext2fs/xattr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ext2fs/xattr.c b/ext2fs/xattr.c index f6ea0f39..78458214 100644 --- a/ext2fs/xattr.c +++ b/ext2fs/xattr.c @@ -1,6 +1,6 @@ /* Ext2 support for extended attributes - Copyright (C) 2006, 2016 Free Software Foundation, Inc. + Copyright (C) 2006, 2016, 2020 Free Software Foundation, Inc. Written by Thadeu Lima de Souza Cascardo and Shengyu Zhang @@ -39,7 +39,7 @@ xattr_prefixes[] = { 1, "user.", sizeof "user." - 1}, { - 7, "gnu.", sizeof "gnu." - 1}, + 10, "gnu.", sizeof "gnu." - 1}, { 0, NULL, 0} }; -- 2.26.0 --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-ext4-Support-gnu.-namespace-for-Hurd-file-systems.patch >From 475eb7cfae390d9118a5420df90b979b4ec78aa3 Mon Sep 17 00:00:00 2001 From: "Jan (janneke) Nieuwenhuizen" Date: Mon, 11 May 2020 18:43:44 +0200 Subject: [PATCH] ext4: Support gnu.* namespace for Hurd file systems. The Hurd has experimental code to move the translator and author fields out of the inode, into the "gnu.*" xattr namespace. This patch adds support for reading and writing such attributes. For more information please see: https://summerofcode.withgoogle.com/projects/#5869799859027968 --- fs/ext4/Kconfig | 11 ++++++++ fs/ext4/Makefile | 1 + fs/ext4/xattr.c | 6 ++++ fs/ext4/xattr.h | 1 + fs/ext4/xattr_hurd.c | 57 ++++++++++++++++++++++++++++++++++++++ include/uapi/linux/xattr.h | 4 +++ 6 files changed, 80 insertions(+) create mode 100644 fs/ext4/xattr_hurd.c diff --git a/fs/ext4/Kconfig b/fs/ext4/Kconfig index 2de970cfc33c..324082dec6ee 100644 --- a/fs/ext4/Kconfig +++ b/fs/ext4/Kconfig @@ -98,6 +98,17 @@ config EXT4_FS_SECURITY If you are not using a security module that requires using extended attributes for file security labels, say N. +config EXT4_FS_HURD + bool "Ext4 xattr gnu.* namespace support for the Hurd" + depends on EXT4_FS + help + Extended attributes are name:value pairs associated with inodes by + the kernel or by users (see the attr(5) manual page for details). + This option adds support for the gnu.* namespace ext4 file + systems for the Hurd. + + If you don't know what the GNU Hurd is, say N + config EXT4_DEBUG bool "Ext4 debugging support" depends on EXT4_FS diff --git a/fs/ext4/Makefile b/fs/ext4/Makefile index 4ccb3c9189d8..3c2c43167dbf 100644 --- a/fs/ext4/Makefile +++ b/fs/ext4/Makefile @@ -16,3 +16,4 @@ ext4-$(CONFIG_EXT4_FS_SECURITY) += xattr_security.o ext4-inode-test-objs += inode-test.o obj-$(CONFIG_EXT4_KUNIT_TESTS) += ext4-inode-test.o ext4-$(CONFIG_FS_VERITY) += verity.o +ext4-$(CONFIG_EXT4_FS_HURD) += xattr_hurd.o diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 8966a5439a22..6353034c5f56 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -93,6 +93,9 @@ static const struct xattr_handler * const ext4_xattr_handler_map[] = { #ifdef CONFIG_EXT4_FS_SECURITY [EXT4_XATTR_INDEX_SECURITY] = &ext4_xattr_security_handler, #endif +#ifdef CONFIG_EXT4_FS_HURD + [EXT4_XATTR_INDEX_HURD] = &ext4_xattr_hurd_handler, +#endif }; const struct xattr_handler *ext4_xattr_handlers[] = { @@ -104,6 +107,9 @@ const struct xattr_handler *ext4_xattr_handlers[] = { #endif #ifdef CONFIG_EXT4_FS_SECURITY &ext4_xattr_security_handler, +#endif +#ifdef CONFIG_EXT4_FS_HURD + &ext4_xattr_hurd_handler, #endif NULL }; diff --git a/fs/ext4/xattr.h b/fs/ext4/xattr.h index f39cad2abe2a..c5e865f14133 100644 --- a/fs/ext4/xattr.h +++ b/fs/ext4/xattr.h @@ -124,6 +124,7 @@ struct ext4_xattr_inode_array { extern const struct xattr_handler ext4_xattr_user_handler; extern const struct xattr_handler ext4_xattr_trusted_handler; extern const struct xattr_handler ext4_xattr_security_handler; +extern const struct xattr_handler ext4_xattr_hurd_handler; #define EXT4_XATTR_NAME_ENCRYPTION_CONTEXT "c" diff --git a/fs/ext4/xattr_hurd.c b/fs/ext4/xattr_hurd.c new file mode 100644 index 000000000000..ee31557308a9 --- /dev/null +++ b/fs/ext4/xattr_hurd.c @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * linux/fs/ext4/xattr_hurd.c + * Handler for extended gnu attributes for the Hurd. + * + * Copyright (C) 2001 by Andreas Gruenbacher, + * Copyright (C) 2020 by Jan (janneke) Nieuwenhuizen, + */ + +#include +#include +#include "ext4.h" +#include "xattr.h" + +static bool +ext4_xattr_hurd_list(struct dentry *dentry) +{ + return test_opt(dentry->d_sb, XATTR_USER) && + EXT4_SB(dentry->d_sb)->s_es->s_creator_os == + cpu_to_le32(EXT4_OS_HURD); +} + +static int +ext4_xattr_hurd_get(const struct xattr_handler *handler, + struct dentry *unused, struct inode *inode, + const char *name, void *buffer, size_t size) +{ + if (!test_opt(inode->i_sb, XATTR_USER) || + EXT4_SB(inode->i_sb)->s_es->s_creator_os != + cpu_to_le32(EXT4_OS_HURD)) + return -EOPNOTSUPP; + + return ext4_xattr_get(inode, EXT4_XATTR_INDEX_HURD, + name, buffer, size); +} + +static int +ext4_xattr_hurd_set(const struct xattr_handler *handler, + struct dentry *unused, struct inode *inode, + const char *name, const void *value, + size_t size, int flags) +{ + if (!test_opt(inode->i_sb, XATTR_USER) || + EXT4_SB(inode->i_sb)->s_es->s_creator_os != + cpu_to_le32(EXT4_OS_HURD)) + return -EOPNOTSUPP; + + return ext4_xattr_set(inode, EXT4_XATTR_INDEX_HURD, + name, value, size, flags); +} + +const struct xattr_handler ext4_xattr_hurd_handler = { + .prefix = XATTR_HURD_PREFIX, + .list = ext4_xattr_hurd_list, + .get = ext4_xattr_hurd_get, + .set = ext4_xattr_hurd_set, +}; diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h index c1395b5bd432..9463db2dfa9d 100644 --- a/include/uapi/linux/xattr.h +++ b/include/uapi/linux/xattr.h @@ -7,6 +7,7 @@ Copyright (C) 2001 by Andreas Gruenbacher Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved. Copyright (c) 2004 Red Hat, Inc., James Morris + Copyright (c) 2020 Jan (janneke) Nieuwenhuizen */ #include @@ -31,6 +32,9 @@ #define XATTR_BTRFS_PREFIX "btrfs." #define XATTR_BTRFS_PREFIX_LEN (sizeof(XATTR_BTRFS_PREFIX) - 1) +#define XATTR_HURD_PREFIX "gnu." +#define XATTR_HURD_PREFIX_LEN (sizeof(XATTR_HURD_PREFIX) - 1) + #define XATTR_SECURITY_PREFIX "security." #define XATTR_SECURITY_PREFIX_LEN (sizeof(XATTR_SECURITY_PREFIX) - 1) -- 2.26.0 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable --=20 Jan Nieuwenhuizen | GNU LilyPond http://lilypond.org Freelance IT http://JoyofSource.com | Avatar=C2=AE http://AvatarAcademy.com --=-=-=--