This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

B20.1: rmdir errno bug


When rmdir() attempts to remove a regular file (non-directory) and therefore
fails, it sets errno to EISDIR instead of ENOTDIR. Tested on NT with B20.1;
both egcs-2.91.57 and egcs-2.91.66; with binmode and without. Couldn't find
a reference to the problem in the mailing list archives and didn't see an
obvious way of fixing it in the source. Encountered the problem when porting
dpkg. Test code below...

-Tad

----- begin chkrmdir.c -----
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>

#define TEST_FNAME "rmdir_test_file"

int main() {
  FILE *f;

  printf ("Creating '%s'.\n", TEST_FNAME);
  if (!(f = fopen(TEST_FNAME,"w"))) {
    fprintf(stderr, "fopen '%s' failed: %s (%d)\n",
      TEST_FNAME, strerror(errno), errno);
    exit(1);
  }

  fputc('X',f);
  fclose(f);

  printf ("Trying rmdir on '%s'.\n", TEST_FNAME);
  if (rmdir (TEST_FNAME))
    fprintf(stderr, "rmdir '%s' failed: %s (%d)\n",
      TEST_FNAME, strerror(errno), errno);

  printf ("Trying unlink on '%s'.\n", TEST_FNAME);
  if (unlink (TEST_FNAME))
    fprintf(stderr, "unlink %s failed: '%s' (%d)\n",
      TEST_FNAME, strerror(errno), errno);

  exit(0);
}
----- end chkrmdir.c -----

--
------------------------------------------------------------------------------
Thaddeus J. Kollar
Integral Systems, Inc.
NASA John H. Glenn Research Center, M/S 142-2
------------------------------------------------------------------------------

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]