btrfsprogs/0101-btrfs-progs-setting-of-time-to-the-root-directory.patch

64 lines
2.0 KiB
Diff
Raw Normal View History

From 37b1fc8c9302ec7dc1c6c04041805ac21fdfca28 Mon Sep 17 00:00:00 2001
From: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Date: Wed, 17 Nov 2010 10:07:52 +0900
Subject: [PATCH 01/28] btrfs-progs: setting of time to the root directory
This patch adds the setting of time to the root directory to the
mkfs.btrfs command.
As a result, the time of the mount point not correctly displayed
comes to be displayed correctly.
[before]
# mkfs.btrfs /dev/sdd10
# mount /dev/sdd10 /test1
# ls -ld /test1
dr-xr-xr-x 1 root root 0 Jan 1 1970 /test1
[after]
# date
Tue Nov 16 18:06:05 JST 2010
# mkfs.btrfs /dev/sdd10
# mount /dev/sdd10 /test1
# ls -ld /test1
dr-xr-xr-x 1 root root 0 Nov 16 18:06 /test1
Thanks,
Tsutomu
Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Hugo Mills <hugo@carfax.org.uk>
---
utils.c | 9 +++++++++
1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/utils.c b/utils.c
index 17e5afe..74d2c59 100644
--- a/utils.c
+++ b/utils.c
@@ -587,6 +587,7 @@ int btrfs_make_root_dir(struct btrfs_trans_handle *trans,
{
int ret;
struct btrfs_inode_item inode_item;
+ time_t now = time(NULL);
memset(&inode_item, 0, sizeof(inode_item));
btrfs_set_stack_inode_generation(&inode_item, trans->transid);
@@ -594,6 +595,14 @@ int btrfs_make_root_dir(struct btrfs_trans_handle *trans,
btrfs_set_stack_inode_nlink(&inode_item, 1);
btrfs_set_stack_inode_nbytes(&inode_item, root->leafsize);
btrfs_set_stack_inode_mode(&inode_item, S_IFDIR | 0555);
+ btrfs_set_stack_timespec_sec(&inode_item.atime, now);
+ btrfs_set_stack_timespec_nsec(&inode_item.atime, 0);
+ btrfs_set_stack_timespec_sec(&inode_item.ctime, now);
+ btrfs_set_stack_timespec_nsec(&inode_item.ctime, 0);
+ btrfs_set_stack_timespec_sec(&inode_item.mtime, now);
+ btrfs_set_stack_timespec_nsec(&inode_item.mtime, 0);
+ btrfs_set_stack_timespec_sec(&inode_item.otime, 0);
+ btrfs_set_stack_timespec_nsec(&inode_item.otime, 0);
if (root->fs_info->tree_root == root)
btrfs_set_super_root_dir(&root->fs_info->super_copy, objectid);
--
1.7.5.2.353.g5df3e