All of lore.kernel.org
 help / color / mirror / Atom feed
From: Holger Jakob <jakob@dsi.uni-stuttgart.de>
To: linux-btrfs@vger.kernel.org
Cc: Holger Jakob <jakob@dsi.uni-stuttgart.de>
Subject: [PATCH v2 1/2] Fixed issue with restore of xattrs not working on directories
Date: Wed,  1 Feb 2023 20:33:44 -0800	[thread overview]
Message-ID: <20230202043345.14010-1-jakob@dsi.uni-stuttgart.de> (raw)
In-Reply-To: <7b2b7360-9008-7d88-02db-1ca4f07a6df6@oracle.com>

Restore was only setting xattrs on files but ignored directories.
The patch adds a missing set_file_xattrs

Signed-off-by: Holger Jakob <jakob@dsi.uni-stuttgart.de>
---
 cmds/restore.c | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/cmds/restore.c b/cmds/restore.c
index 19df6be2..18edc8ca 100644
--- a/cmds/restore.c
+++ b/cmds/restore.c
@@ -1117,11 +1117,11 @@ next:
 		path.slots[0]++;
 	}
 
-	if (restore_metadata) {
+	if (restore_metadata || get_xattrs) {
 		snprintf(path_name, PATH_MAX, "%s%s", output_rootdir, in_dir);
 		fd = open(path_name, O_RDONLY);
 		if (fd < 0) {
-			error("failed to access '%s' to restore metadata: %m",
+			error("failed to access '%s' to restore metadata/xattrs: %m",
 					path_name);
 			if (!ignore_errors) {
 				ret = -1;
@@ -1132,7 +1132,23 @@ next:
 			 * Set owner/mode/time on the directory as well
 			 */
 			key->type = BTRFS_INODE_ITEM_KEY;
-			ret = copy_metadata(root, fd, key);
+			if (restore_metadata) {
+				ret = copy_metadata(root, fd, key);
+				if (ret && !ignore_errors) {
+					close(fd);
+					goto out;
+				}
+			}
+
+			/*
+			 * Also set xattrs on the directory
+			 */
+			if (get_xattrs) {
+				ret = set_file_xattrs(root, key->objectid, fd, path_name);
+				if (ret) {
+					error("failed to set xattrs: %m");
+				}
+			}
 			close(fd);
 			if (ret && !ignore_errors)
 				goto out;
-- 
2.35.3


  reply	other threads:[~2023-02-02  4:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-01 17:06 [PATCH] btrfs-progs: restore of xattrs fixed Holger Jakob
2023-02-01 22:44 ` Anand Jain
2023-02-02  4:33   ` Holger Jakob [this message]
2023-02-02  4:33     ` [PATCH v2 2/2] Fixed issue with metadata getting modified in dry run mode Holger Jakob
2023-03-16 15:32     ` [PATCH v2 1/2] Fixed issue with restore of xattrs not working on directories David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230202043345.14010-1-jakob@dsi.uni-stuttgart.de \
    --to=jakob@dsi.uni-stuttgart.de \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.