Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Handle POSIX-compliant errno value of unlink in remove.
  • Loading branch information
Ulrich Drepper committed Apr 4, 2010
1 parent 952df0a commit cb652f3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
@@ -1,5 +1,11 @@
2010-04-04 Ulrich Drepper <drepper@redhat.com>

[BZ #11276]
* sysdeps/posix/remove.c (IS_NO_DIRECTORY_ERROR): Define.
(remove): Use IS_NO_DIRECTORY_ERROR to check for file being no
directory.
* sysdeps/unix/sysv/linux/remove.c: New file.

* conform/data/sys/stat.h-data: Fix testing of S_IS* macros.

[BZ #11279]
Expand Down
10 changes: 8 additions & 2 deletions sysdeps/posix/remove.c
@@ -1,5 +1,5 @@
/* ANSI C `remove' function to delete a file or directory. POSIX.1 version.
Copyright (C) 1995,96,97,2002,2003 Free Software Foundation, Inc.
Copyright (C) 1995,96,97,2002,2003,2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
Expand All @@ -21,14 +21,20 @@
#include <stdio.h>
#include <unistd.h>


#ifndef IS_NO_DIRECTORY_ERROR
# define IS_NO_DIRECTORY_ERROR errno != EPERM
#endif


int
remove (file)
const char *file;
{
/* First try to unlink since this is more frequently the necessary action. */
if (__unlink (file) != 0
/* If it is indeed a directory... */
&& (errno != EISDIR
&& (IS_NO_DIRECTORY_ERROR
/* ...try to remove it. */
|| __rmdir (file) != 0))
/* Cannot remove the object for whatever reason. */
Expand Down
2 changes: 2 additions & 0 deletions sysdeps/unix/sysv/linux/remove.c
@@ -0,0 +1,2 @@
#define IS_NO_DIRECTORY_ERROR errno != EISDIR
#include <sysdeps/posix/remove.c>

0 comments on commit cb652f3

Please sign in to comment.