Bug 8479

Summary: unlink() on a dir sets errno to EISDIR; SUS expects EPERM
Product: [Retired] Red Hat Linux Reporter: Jay Turner <jturner>
Component: kernelAssignee: Michael K. Johnson <johnsonm>
Status: CLOSED DEFERRED QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1CC: srevivo
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2000-01-14 21:08:24 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Glen Foster 2000-01-14 21:08:24 UTC
VSX-PCTS tests the errno returned from an unlink() call on a directory.
Although Linux's setting of errno = EISDIR is *informative*, the Single
Unix Specification requires errno to be set to EPERM for implementations
that do not support unlink() operating on a directory.  See SUS for more
details.  A simple test-case is set up below...

#include <stdio.h>
#include <errno.h>

#define DIRNAME "./testdir"

main()
{
        if (mkdir(DIRNAME, 0755) < 0) {
                perror(DIRNAME);
                exit(1);
        }
        if (unlink(DIRNAME) < 0 && errno == EPERM) {
                exit(0);
        }
        perror("unlink");
        fprintf(stderr, "Expected errno %d, received %d\n", EPERM, errno);
        exit(1);
}

Comment 1 Alan Cox 2000-08-08 19:00:02 UTC
This probably wont be changing for 2.2 since it may break compatibility.