kernel/{hammer2,tmpfs}: Fix ENOTDIR/EISDIR logic.
authorSascha Wildner <saw@online.de>
Wed, 31 Oct 2018 09:27:27 +0000 (10:27 +0100)
committerSascha Wildner <saw@online.de>
Wed, 31 Oct 2018 09:27:40 +0000 (10:27 +0100)
It caused confusion like this:

vm64# touch /usr/obj/t
vm64# rmdir /usr/obj/t
rmdir: /usr/obj/t: Is a directory
vm64#

Likewise unlink(2) on a directory also gives the wrong error
("Not a directory").

This also causes Ruby's unlink() file method to fail.

Reported-by: tuxillo
sys/vfs/hammer2/hammer2_xops.c

index 16b8fcc..1406906 100644 (file)
@@ -434,10 +434,10 @@ again:
                        }
                } else if (type == HAMMER2_OBJTYPE_DIRECTORY &&
                    xop->isdir == 0) {
-                       error = HAMMER2_ERROR_ENOTDIR;
+                       error = HAMMER2_ERROR_EISDIR;
                } else if (type != HAMMER2_OBJTYPE_DIRECTORY &&
                           xop->isdir >= 1) {
-                       error = HAMMER2_ERROR_EISDIR;
+                       error = HAMMER2_ERROR_ENOTDIR;
                } else {
                        /*
                         * Delete the directory entry.  chain might also