diff options
author | Charles Manning <cdhmanning@gmail.com> | 2010-11-24 13:50:04 +1300 |
---|---|---|
committer | Charles Manning <cdhmanning@gmail.com> | 2010-11-24 13:50:04 +1300 |
commit | 0d62a49dfe174bd70d289f0cf8e97c78585dd359 (patch) | |
tree | 1d7ee1211f1cba232b79bdeb05a59ebeaef026d4 /yaffs_guts.c | |
parent | de9d60531e0b398feb6304e02e940fbf6cbc4f57 (diff) |
yaffs direct: Fix error for attempting to rename over a non-empty directory
Now produces -ENOTEMPTY.
Signed-off-by: Charles Manning <cdhmanning@gmail.com>
Diffstat (limited to 'yaffs_guts.c')
-rw-r--r-- | yaffs_guts.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/yaffs_guts.c b/yaffs_guts.c index 1bc6d51..c56e060 100644 --- a/yaffs_guts.c +++ b/yaffs_guts.c @@ -1669,12 +1669,8 @@ int yaffs_rename_obj(struct yaffs_obj *old_dir, const YCHAR * old_name, /* Now do the handling for an existing target, if there is one */ existing_target = yaffs_find_by_name(new_dir, new_name); - if (existing_target && - existing_target->variant_type == YAFFS_OBJECT_TYPE_DIRECTORY - && !list_empty(&existing_target->variant.dir_variant. - children)) { - /* There is a target that is a non-empty directory, so we fail */ - return YAFFS_FAIL; /* EEXIST or ENOTEMPTY */ + if (yaffs_is_non_empty_dir(existing_target)){ + return YAFFS_FAIL; /* ENOTEMPTY */ } else if (existing_target && existing_target != obj) { /* Nuke the target first, using shadowing, * but only if it isn't the same object. @@ -3811,10 +3807,11 @@ int yaffs_del_file(struct yaffs_obj *in) } } -static int yaffs_is_non_empty_dir(struct yaffs_obj *obj) +int yaffs_is_non_empty_dir(struct yaffs_obj *obj) { - return (obj->variant_type == YAFFS_OBJECT_TYPE_DIRECTORY) && - !(list_empty(&obj->variant.dir_variant.children)); + return (obj && + obj->variant_type == YAFFS_OBJECT_TYPE_DIRECTORY) && + !(list_empty(&obj->variant.dir_variant.children)); } static int yaffs_del_dir(struct yaffs_obj *obj) |