diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/ext4_common.c | 5 | ||||
-rw-r--r-- | fs/ext4/ext4_journal.c | 2 | ||||
-rw-r--r-- | fs/ext4/ext4_write.c | 20 |
3 files changed, 19 insertions, 8 deletions
diff --git a/fs/ext4/ext4_common.c b/fs/ext4/ext4_common.c index 365c5147c4b..2ff0dca2495 100644 --- a/fs/ext4/ext4_common.c +++ b/fs/ext4/ext4_common.c @@ -765,11 +765,6 @@ int ext4fs_get_parent_inode_num(const char *dirname, char *dname, int flags) struct ext2_inode *first_inode = NULL; struct ext2_inode temp_inode; - if (*dirname != '/') { - printf("Please supply Absolute path\n"); - return -1; - } - /* TODO: input validation make equivalent to linux */ depth_dirname = zalloc(strlen(dirname) + 1); if (!depth_dirname) diff --git a/fs/ext4/ext4_journal.c b/fs/ext4/ext4_journal.c index 1a340b4764c..e80f797c8dc 100644 --- a/fs/ext4/ext4_journal.c +++ b/fs/ext4/ext4_journal.c @@ -430,7 +430,7 @@ int ext4fs_check_journal_state(int recovery_flag) printf("Recovery required\n"); } else { if (recovery_flag == RECOVER) - printf("File System is consistent\n"); + log_debug("File System is consistent\n"); goto end; } diff --git a/fs/ext4/ext4_write.c b/fs/ext4/ext4_write.c index ea4c5d4157c..d057f6b5a79 100644 --- a/fs/ext4/ext4_write.c +++ b/fs/ext4/ext4_write.c @@ -847,6 +847,7 @@ int ext4fs_write(const char *fname, const char *buffer, { int ret = 0; struct ext2_inode *file_inode = NULL; + struct ext2_inode *existing_file_inode = NULL; unsigned char *inode_buffer = NULL; int parent_inodeno; int inodeno; @@ -900,6 +901,15 @@ int ext4fs_write(const char *fname, const char *buffer, /* check if the filename is already present in root */ existing_file_inodeno = ext4fs_filename_unlink(filename); if (existing_file_inodeno != -1) { + existing_file_inode = (struct ext2_inode *)zalloc(fs->inodesz); + if (!existing_file_inode) + goto fail; + ret = ext4fs_iget(existing_file_inodeno, existing_file_inode); + if (ret) { + free(existing_file_inode); + goto fail; + } + ret = ext4fs_delete_file(existing_file_inodeno); fs->first_pass_bbmap = 0; fs->curr_blkno = 0; @@ -948,9 +958,15 @@ int ext4fs_write(const char *fname, const char *buffer, sizebytes = 0; } } else { - file_inode->mode = cpu_to_le16(S_IFREG | S_IRWXU | S_IRGRP | - S_IROTH | S_IXGRP | S_IXOTH); + if (existing_file_inode) { + file_inode->mode = existing_file_inode->mode; + } else { + file_inode->mode = cpu_to_le16(S_IFREG | S_IRWXU | S_IRGRP | + S_IROTH | S_IXGRP | S_IXOTH); + } } + if (existing_file_inode) + free(existing_file_inode); /* ToDo: Update correct time */ file_inode->mtime = cpu_to_le32(timestamp); file_inode->atime = cpu_to_le32(timestamp); |