All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] btrfs-progs: have restore set atime/mtime
@ 2015-04-16 23:33 Dan Merillat
  2015-04-16 23:43 ` Dan Merillat
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Dan Merillat @ 2015-04-16 23:33 UTC (permalink / raw)
  To: BTRFS

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-04-17 12:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-16 23:33 [PATCH] btrfs-progs: have restore set atime/mtime Dan Merillat
2015-04-16 23:43 ` 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

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.