summaryrefslogtreecommitdiffstats
path: root/lib/ext2fs/orphan.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-21 04:59:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-21 04:59:34 +0000
commit6187d406bede6461086d6e5263f42ae4826675c4 (patch)
tree32a35120c4385929cfd5a7b9c584b9dd8396b108 /lib/ext2fs/orphan.c
parentReleasing progress-linux version 1.47.0-2.4~progress7.99u1. (diff)
downloade2fsprogs-6187d406bede6461086d6e5263f42ae4826675c4.tar.xz
e2fsprogs-6187d406bede6461086d6e5263f42ae4826675c4.zip
Merging upstream version 1.47.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/ext2fs/orphan.c')
-rw-r--r--lib/ext2fs/orphan.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/ext2fs/orphan.c b/lib/ext2fs/orphan.c
index e25f20c..913eb9a 100644
--- a/lib/ext2fs/orphan.c
+++ b/lib/ext2fs/orphan.c
@@ -126,23 +126,23 @@ errcode_t ext2fs_create_orphan_file(ext2_filsys fs, blk_t num_blocks)
char *buf = NULL, *zerobuf = NULL;
struct mkorphan_info oi;
struct ext4_orphan_block_tail *ob_tail;
+ time_t now;
- if (!ino) {
+ if (ino) {
+ err = ext2fs_read_inode(fs, ino, &inode);
+ if (err)
+ return err;
+ if (EXT2_I_SIZE(&inode)) {
+ err = ext2fs_truncate_orphan_file(fs);
+ if (err)
+ return err;
+ }
+ } else {
err = ext2fs_new_inode(fs, EXT2_ROOT_INO, LINUX_S_IFREG | 0600,
0, &ino);
if (err)
return err;
ext2fs_inode_alloc_stats2(fs, ino, +1, 0);
- ext2fs_mark_ib_dirty(fs);
- }
-
- err = ext2fs_read_inode(fs, ino, &inode);
- if (err)
- return err;
- if (EXT2_I_SIZE(&inode)) {
- err = ext2fs_truncate_orphan_file(fs);
- if (err)
- return err;
}
memset(&inode, 0, sizeof(struct ext2_inode));
@@ -185,8 +185,10 @@ errcode_t ext2fs_create_orphan_file(ext2_filsys fs, blk_t num_blocks)
if (err)
goto out;
ext2fs_iblk_set(fs, &inode, 0);
- inode.i_atime = inode.i_mtime =
- inode.i_ctime = fs->now ? fs->now : time(0);
+ now = ext2fsP_get_time(fs);
+ ext2fs_inode_xtime_set(&inode, i_atime, now);
+ ext2fs_inode_xtime_set(&inode, i_ctime, now);
+ ext2fs_inode_xtime_set(&inode, i_mtime, now);
inode.i_links_count = 1;
inode.i_mode = LINUX_S_IFREG | 0600;
ext2fs_iblk_add_blocks(fs, &inode, oi.alloc_blocks);