X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=gnu%2Fsymlinkat.c;h=84d55847696fe59dcb59a13b9dd7c7ac4e407775;hb=d30babc23b4f25be970ada2e63a50220a3672281;hp=a4301de171452a12c0615210e6eb04c9e1e1b76e;hpb=1a44d77d50f4fb37c0410eed04b82303624ea2ec;p=debian%2Ftar diff --git a/gnu/symlinkat.c b/gnu/symlinkat.c index a4301de1..84d55847 100644 --- a/gnu/symlinkat.c +++ b/gnu/symlinkat.c @@ -1,7 +1,5 @@ -/* -*- buffer-read-only: t -*- vi: set ro: */ -/* DO NOT EDIT! GENERATED AUTOMATICALLY! */ /* Create a symlink relative to an open directory. - Copyright (C) 2009-2011 Free Software Foundation, Inc. + Copyright (C) 2009-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -21,13 +19,33 @@ #include #include +#include -#if !HAVE_SYMLINK +#if HAVE_SYMLINKAT +# undef symlinkat + +#include +#include + +/* Create a symlink, but reject trailing slash. */ +int +rpl_symlinkat (char const *contents, int fd, char const *name) +{ + size_t len = strlen (name); + if (len && name[len - 1] == '/') + { + struct stat st; + if (fstatat (fd, name, &st, 0) == 0) + errno = EEXIST; + return -1; + } + return symlinkat (contents, fd, name); +} + +#elif !HAVE_SYMLINK /* Mingw lacks symlink, and it is more efficient to provide a trivial wrapper than to go through at-func.c to call rpl_symlink. */ -# include - int symlinkat (char const *path1 _GL_UNUSED, int fd _GL_UNUSED, char const *path2 _GL_UNUSED)