From: Dan Merillat <dan.merillat@gmail.com>
To: BTRFS <linux-btrfs@vger.kernel.org>
Subject: [PATCH] btrfs-progs: have restore set atime/mtime
Date: Thu, 16 Apr 2015 19:33:46 -0400 [thread overview]
Message-ID: <553046DA.7090809@gmail.com> (raw)
The inode is already found, use the data and make restore friendlier.
Signed-off-by: Dan Merillat <dan.merillat@gmail.com>
---
cmds-restore.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
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;
}
btrfs_release_path(path);
@@ -680,6 +690,8 @@ set_size:
if (ret)
return ret;
}
+ if (times_ok)
+ futimens(fd, times);
return 0;
}
--
2.1.4
next reply other threads:[~2015-04-16 23:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-16 23:33 Dan Merillat [this message]
2015-04-16 23:43 ` [PATCH] btrfs-progs: have restore set atime/mtime Dan Merillat
2015-04-17 1:09 ` Duncan
2015-04-17 2:19 ` Dan Merillat
[not found] ` <GqKV1q00y3iShQZ01qKkzm>
2015-04-17 3:24 ` Duncan
[not found] ` <CADfjVrg=hZNE1x4F3H05Ds_H9WDBjuY2ZPPixuxiUanAd2mOHw@mail.gmail.com>
2015-04-17 12:32 ` Dan Merillat
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=553046DA.7090809@gmail.com \
--to=dan.merillat@gmail.com \
--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.