Hurd: Fix mkdir / error value

This commit is contained in:
Samuel Thibault 2012-05-10 15:16:07 -07:00 committed by Roland McGrath
parent e468f8a3a7
commit 6b645f0d70
3 changed files with 18 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2012-05-10 Samuel Thibault <samuel.thibault@ens-lyon.org>
* sysdeps/mach/hurd/mkdir.c: Include <string.h>.
(__mkdir): When path is `/', just fail with EEXIST.
* sysdeps/mach/hurd/mkdirat.c: Likewise.
2012-05-10 Thomas Schwinge <thomas@schwinge.name>
* nss/makedb.c: Include <sys/param.h> (for MAX and roundup), and

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1991,93,94,95,96,97,2002 Free Software Foundation, Inc.
/* Copyright (C) 1991-2012 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
@ -19,6 +19,7 @@
#include <stddef.h>
#include <sys/stat.h>
#include <hurd.h>
#include <string.h>
/* Create a directory named FILE_NAME with protections MODE. */
int
@ -28,7 +29,10 @@ __mkdir (file_name, mode)
{
error_t err;
const char *name;
file_t parent = __directory_name_split (file_name, (char **) &name);
file_t parent;
if (!strcmp (file_name, "/"))
return __hurd_fail (EEXIST);
parent = __directory_name_split (file_name, (char **) &name);
if (parent == MACH_PORT_NULL)
return -1;
err = __dir_mkdir (parent, name, mode & ~_hurd_umask);

View File

@ -1,6 +1,5 @@
/* Create a directory named relative to another open directory. Hurd version.
Copyright (C) 1991,1993,1994,1995,1996,1997,2002,2006
Free Software Foundation, Inc.
Copyright (C) 1991-2012 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
@ -22,6 +21,7 @@
#include <sys/stat.h>
#include <hurd.h>
#include <hurd/fd.h>
#include <string.h>
int
mkdirat (fd, path, mode)
@ -31,7 +31,10 @@ mkdirat (fd, path, mode)
{
error_t err;
const char *name;
file_t parent = __directory_name_split_at (fd, path, (char **) &name);
file_t parent;
if (!strcmp (path, "/"))
return __hurd_fail (EEXIST);
parent = __directory_name_split_at (fd, path, (char **) &name);
if (parent == MACH_PORT_NULL)
return -1;
err = __dir_mkdir (parent, name, mode & ~_hurd_umask);