ref: f4d662d77b4a0376d6a58475839f5a2a89b2c966
parent: 0697bc2f9ff85fa341dc597495413b2160636d59
author: root <ngkaho1234@gmail.com>
date: Mon Sep 21 19:33:49 EDT 2015
Symlink now can be removed by ext4_fremove.
--- a/lwext4/ext4.c
+++ b/lwext4/ext4.c
@@ -1202,22 +1202,6 @@
goto Finish;
}
- if (ext4_inode_is_type(&f->mp->fs.sb, ref.inode, EXT4_INODE_MODE_SOFTLINK)
- && f->fsize < sizeof(ref.inode->blocks)
- && !ext4_inode_get_blocks_count(&f->mp->fs.sb, ref.inode)) {
- char *content = (char *)ref.inode->blocks;
- memset(content + size, 0, sizeof(ref.inode->blocks) - size);
- ext4_inode_set_size(ref.inode, size);
- ref.dirty = true;
-
- f->fsize = size;
- if (f->fpos > size)
- f->fpos = size;
-
- r = EOK;
- goto Finish;
- }
-
/*Start write back cache mode.*/
r = ext4_block_cache_write_back(f->mp->fs.bdev, 1);
if (r != EOK)
--- a/lwext4/ext4_fs.c
+++ b/lwext4/ext4_fs.c
@@ -895,6 +895,18 @@
if (old_size < new_size)
return EINVAL;
+ if (ext4_inode_is_type(sb, inode_ref->inode, EXT4_INODE_MODE_SOFTLINK)
+ && old_size < sizeof(inode_ref->inode->blocks)
+ && !ext4_inode_get_blocks_count(sb, inode_ref->inode)) {
+ char *content = (char *)inode_ref->inode->blocks;
+ memset(content + new_size, 0,
+ sizeof(inode_ref->inode->blocks) - new_size);
+ ext4_inode_set_size(inode_ref->inode, new_size);
+ inode_ref->dirty = true;
+
+ return EOK;
+ }
+
/* Compute how many blocks will be released */
uint64_t size_diff = old_size - new_size;
uint32_t block_size = ext4_sb_get_block_size(sb);
--- a/lwext4/ext4_inode.c
+++ b/lwext4/ext4_inode.c
@@ -327,7 +327,8 @@
return false;
if ((ext4_inode_is_type(sb, inode, EXT4_INODE_MODE_FILE)) ||
- (ext4_inode_is_type(sb, inode, EXT4_INODE_MODE_DIRECTORY)))
+ (ext4_inode_is_type(sb, inode, EXT4_INODE_MODE_DIRECTORY)) ||
+ (ext4_inode_is_type(sb, inode, EXT4_INODE_MODE_SOFTLINK)))
return true;
return false;