1.1 --- a/libe2access/lib/src/image.c Mon Feb 14 00:46:57 2022 +0100
1.2 +++ b/libe2access/lib/src/image.c Mon Feb 14 22:21:03 2022 +0100
1.3 @@ -558,13 +558,22 @@
1.4 ext2_ino_t ino_parent;
1.5 errcode_t retval;
1.6
1.7 + /* Copy the path and split it. */
1.8 +
1.9 strcpy(_path, path);
1.10 basename = path_split(_path);
1.11
1.12 - retval = image_find_path(fs, &remaining, &ino_parent);
1.13 + /* Determine the parent directory. */
1.14 +
1.15 + if (basename != _path)
1.16 + {
1.17 + retval = image_find_path(fs, &remaining, &ino_parent);
1.18
1.19 - if (retval)
1.20 - return retval;
1.21 + if (retval)
1.22 + return retval;
1.23 + }
1.24 + else
1.25 + ino_parent = EXT2_ROOT_INO;
1.26
1.27 return ext2fs_unlink(fs, ino_parent, basename, 0, 0);
1.28 }