From patchwork Thu Apr 16 23:33:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Merillat X-Patchwork-Id: 6228101 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4802FBF4A6 for ; Thu, 16 Apr 2015 23:33:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5323F2026D for ; Thu, 16 Apr 2015 23:33:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 602A62027D for ; Thu, 16 Apr 2015 23:33:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753203AbbDPXdv (ORCPT ); Thu, 16 Apr 2015 19:33:51 -0400 Received: from mail-qc0-f181.google.com ([209.85.216.181]:33675 "EHLO mail-qc0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751589AbbDPXdt (ORCPT ); Thu, 16 Apr 2015 19:33:49 -0400 Received: by qcrf4 with SMTP id f4so15599401qcr.0 for ; Thu, 16 Apr 2015 16:33:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=kd/kwWd8WTIXbYU7R+T1Au4xWdyivOkSoHkw1bsRc0c=; b=clh1+sw+WcFO6/KQXG+s4avv9K/611whBv6/eODcf3HFjnOKcDwWB+aPE/7UGR6q3v fRbbV2gz8GtivmhkLFL1pGHnzxxgJPnJB3qF+hIlWU6AcQFTba1ACyrRVR3SNKJt99V8 AkFrKjXGjCAwiwLoSKPZPYWdd4i5UMecT6rixHsIbpI6OgQgkWvfbYTbwUkMmmI44DZs c8d9X1VRUDiatmCiY2OGdYVDKI9B2Qif0qpqy3Yvxn6/s2mDcTSn67EeaiRJIjR1Tv/Z FChMBbqB1y6NfNMApLTzM/mNBr5RwoQk44d8+6vof3Qwjhql19fkCQsFtYz24GYDy83S dPJQ== X-Received: by 10.140.108.10 with SMTP id i10mr232065qgf.73.1429227229329; Thu, 16 Apr 2015 16:33:49 -0700 (PDT) Received: from ?IPv6:2001:470:8:414::10? (wolf.welp.gs. [2001:470:8:414::10]) by mx.google.com with ESMTPSA id n13sm6742373qkh.8.2015.04.16.16.33.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Apr 2015 16:33:48 -0700 (PDT) Message-ID: <553046DA.7090809@gmail.com> Date: Thu, 16 Apr 2015 19:33:46 -0400 From: Dan Merillat User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:32.0) Gecko/20100101 Icedove/32.0 MIME-Version: 1.0 To: BTRFS Subject: [PATCH] btrfs-progs: have restore set atime/mtime Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The inode is already found, use the data and make restore friendlier. Signed-off-by: Dan Merillat --- cmds-restore.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) } btrfs_release_path(path); @@ -680,6 +690,8 @@ set_size: if (ret) return ret; } + if (times_ok) + futimens(fd, times); return 0; } diff --git a/cmds-restore.c b/cmds-restore.c index d2fc951..95ac487 100644 --- a/cmds-restore.c +++ b/cmds-restore.c @@ -567,12 +567,22 @@ static int copy_file(struct btrfs_root *root, int fd, struct btrfs_key *key, fprintf(stderr, "Ran out of memory\n"); return -ENOMEM; } + struct timespec times[2]; + int times_ok=0; ret = btrfs_lookup_inode(NULL, root, path, key, 0); if (ret == 0) { inode_item = btrfs_item_ptr(path->nodes[0], path->slots[0], struct btrfs_inode_item); found_size = btrfs_inode_size(path->nodes[0], inode_item); + struct btrfs_timespec bts; + read_eb_member(path->nodes[0], inode_item, struct btrfs_inode_item, atime, &bts); + times[0].tv_sec=bts.sec; + times[0].tv_nsec=bts.nsec; + read_eb_member(path->nodes[0], inode_item, struct btrfs_inode_item, atime, &bts); + times[1].tv_sec=bts.sec; + times[1].tv_nsec=bts.nsec; + times_ok=1;