www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/06/23/16:28:31

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
From: Thaddeus Kollar <tad AT apk DOT net>
Message-Id: <199906232017.QAA00724@junior.apk.net>
X-Real-To: cygwin AT sourceware DOT cygnus DOT com
Subject: B20.1: rmdir errno bug
To: cygwin AT sourceware DOT cygnus DOT com
Date: Wed, 23 Jun 1999 16:17:59 -0400 (EDT)
X-Mailer: ELM [version 2.4 PL25]
MIME-Version: 1.0

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 AT sourceware DOT cygnus DOT com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019