Commit 3eca76cc authored by Tetsuhiro Kohada's avatar Tetsuhiro Kohada Committed by Greg Kroah-Hartman

staging: exfat: clean up d_entry rebuilding.

Clean up d_entry rebuilding in exfat_rename_file() and move_file().

-Replace memcpy of d_entry with structure copy.
-Change to use the value already stored in fid.
Signed-off-by: default avatarTetsuhiro Kohada <Kohada.Tetsuhiro@dc.MitsubishiElectric.co.jp>
Acked-by: default avatarValdis Kletnieks <valdis.kletnieks@vt.edu>
Link: https://lore.kernel.org/r/20200302095716.64155-1-Kohada.Tetsuhiro@dc.MitsubishiElectric.co.jpSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent dbcf85e2
...@@ -2285,12 +2285,10 @@ s32 exfat_rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry, ...@@ -2285,12 +2285,10 @@ s32 exfat_rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry,
return -ENOENT; return -ENOENT;
} }
memcpy((void *)epnew, (void *)epold, DENTRY_SIZE); *epnew = *epold;
if (exfat_get_entry_type(epnew) == TYPE_FILE) { if (fid->type == TYPE_FILE) {
exfat_set_entry_attr(epnew,
exfat_get_entry_attr(epnew) |
ATTR_ARCHIVE);
fid->attr |= ATTR_ARCHIVE; fid->attr |= ATTR_ARCHIVE;
exfat_set_entry_attr(epnew, fid->attr);
} }
exfat_buf_modify(sb, sector_new); exfat_buf_modify(sb, sector_new);
exfat_buf_unlock(sb, sector_old); exfat_buf_unlock(sb, sector_old);
...@@ -2306,7 +2304,7 @@ s32 exfat_rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry, ...@@ -2306,7 +2304,7 @@ s32 exfat_rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry,
return -ENOENT; return -ENOENT;
} }
memcpy((void *)epnew, (void *)epold, DENTRY_SIZE); *epnew = *epold;
exfat_buf_modify(sb, sector_new); exfat_buf_modify(sb, sector_new);
exfat_buf_unlock(sb, sector_old); exfat_buf_unlock(sb, sector_old);
...@@ -2319,11 +2317,9 @@ s32 exfat_rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry, ...@@ -2319,11 +2317,9 @@ s32 exfat_rename_file(struct inode *inode, struct chain_t *p_dir, s32 oldentry,
num_old_entries); num_old_entries);
fid->entry = newentry; fid->entry = newentry;
} else { } else {
if (exfat_get_entry_type(epold) == TYPE_FILE) { if (fid->type == TYPE_FILE) {
exfat_set_entry_attr(epold,
exfat_get_entry_attr(epold) |
ATTR_ARCHIVE);
fid->attr |= ATTR_ARCHIVE; fid->attr |= ATTR_ARCHIVE;
exfat_set_entry_attr(epold, fid->attr);
} }
exfat_buf_modify(sb, sector_old); exfat_buf_modify(sb, sector_old);
exfat_buf_unlock(sb, sector_old); exfat_buf_unlock(sb, sector_old);
...@@ -2387,11 +2383,10 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry, ...@@ -2387,11 +2383,10 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry,
return -ENOENT; return -ENOENT;
} }
memcpy((void *)epnew, (void *)epmov, DENTRY_SIZE); *epnew = *epmov;
if (exfat_get_entry_type(epnew) == TYPE_FILE) { if (fid->type == TYPE_FILE) {
exfat_set_entry_attr(epnew, exfat_get_entry_attr(epnew) |
ATTR_ARCHIVE);
fid->attr |= ATTR_ARCHIVE; fid->attr |= ATTR_ARCHIVE;
exfat_set_entry_attr(epnew, fid->attr);
} }
exfat_buf_modify(sb, sector_new); exfat_buf_modify(sb, sector_new);
exfat_buf_unlock(sb, sector_mov); exfat_buf_unlock(sb, sector_mov);
...@@ -2406,7 +2401,7 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry, ...@@ -2406,7 +2401,7 @@ s32 move_file(struct inode *inode, struct chain_t *p_olddir, s32 oldentry,
return -ENOENT; return -ENOENT;
} }
memcpy((void *)epnew, (void *)epmov, DENTRY_SIZE); *epnew = *epmov;
exfat_buf_modify(sb, sector_new); exfat_buf_modify(sb, sector_new);
exfat_buf_unlock(sb, sector_mov); exfat_buf_unlock(sb, sector_mov);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment