From patchwork Wed Oct 17 13:52:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Lyakas X-Patchwork-Id: 1606081 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 3B0D2DFABE for ; Wed, 17 Oct 2012 13:52:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756988Ab2JQNwt (ORCPT ); Wed, 17 Oct 2012 09:52:49 -0400 Received: from mail-lb0-f174.google.com ([209.85.217.174]:41516 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756200Ab2JQNwt (ORCPT ); Wed, 17 Oct 2012 09:52:49 -0400 Received: by mail-lb0-f174.google.com with SMTP id n3so5096232lbo.19 for ; Wed, 17 Oct 2012 06:52:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type :x-gm-message-state; bh=vSZret2NuVShrQGVdmIVO1YdsqDbgV9x46oldnIeuLI=; b=WOBM5ISc4Pg0E9q+tQXKzFDih20vNiIsElWHIwns61NPuuGFdoUgMAJPE3qc2oReTf 6kN5+NSIyP4vvOO0oRH6qtryYQT5GRAfAfZjLCMCogx/UeceP0JjBFmS0wwFPf3t1cdX Tn7tAH1FSRk0bahZCOA7UnQBsU/IF30mggFnbIK9R1NHRm9N1s0dG1OgRlTlXvx2rDAy LCjl6EnZJdzRO1lLBHat5bevo7Aqq1BZ7cTrLhCbSCYwjbzs8kSAsD13c2F+/NVDk1mF W8uYB30dJcybMn9MQR87bRVPoNcoz6hnzLM6ogpFgHcn/J7vGoi9VFQFlS4eTvm0JrB1 v/4Q== MIME-Version: 1.0 Received: by 10.152.124.180 with SMTP id mj20mr15949315lab.43.1350481967254; Wed, 17 Oct 2012 06:52:47 -0700 (PDT) Received: by 10.112.127.232 with HTTP; Wed, 17 Oct 2012 06:52:47 -0700 (PDT) Date: Wed, 17 Oct 2012 15:52:47 +0200 Message-ID: Subject: [PATCH] Btrfs: Send: preserve ownership (uid and gid) also for symlinks. From: Alex Lyakas To: linux-btrfs , chris.mason@fusionio.com, Jan Schmidt Cc: Arne Jansen X-Gm-Message-State: ALoCoQkBqaww7xpOgqCDHhZE4WgjIUgXR2pOskCv1Bz1cBepFrTj4lOm15RETuDCBnqopPSwaVY1 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This patch also requires a change in the user-space part of "receive". We need to use "lchown" instead of "chown". We will do this in the following patch. Signed-off-by: Alex Lyakas if (S_ISREG(sctx->cur_inode_mode)) { --- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index c7beb54..7d1eed2 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -4033,22 +4033,21 @@ static int finish_inode_if_needed(struct send_ctx *sctx, int at_end) if (ret < 0) goto out; - if (!S_ISLNK(sctx->cur_inode_mode)) { - if (!sctx->parent_root || sctx->cur_inode_new) { + if (!sctx->parent_root || sctx->cur_inode_new) { + need_chown = 1; + if (!S_ISLNK(sctx->cur_inode_mode)) need_chmod = 1; - need_chown = 1; - } else { - ret = get_inode_info(sctx->parent_root, sctx->cur_ino, - NULL, NULL, &right_mode, &right_uid, - &right_gid, NULL); - if (ret < 0) - goto out; + } else { + ret = get_inode_info(sctx->parent_root, sctx->cur_ino, + NULL, NULL, &right_mode, &right_uid, + &right_gid, NULL); + if (ret < 0) + goto out; - if (left_uid != right_uid || left_gid != right_gid) - need_chown = 1; - if (left_mode != right_mode) - need_chmod = 1; - } + if (left_uid != right_uid || left_gid != right_gid) + need_chown = 1; + if (!S_ISLNK(sctx->cur_inode_mode) && left_mode != right_mode) + need_chmod = 1; }