From a928fd829207e6ad9675ca6a80050517a2f3917f Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 2 Mar 2015 14:00:16 -0800 Subject: [PATCH] Implement all nacl_irt_dev_filename calls. --- sysdeps/nacl/{fchmod.c => chdir.c} | 10 ++++---- sysdeps/nacl/{fchmod.c => chmod.c} | 10 ++++---- sysdeps/nacl/fchmod.c | 2 +- sysdeps/nacl/{fchmod.c => link.c} | 10 ++++---- sysdeps/nacl/lxstat.c | 46 +++++++++++++++++++++++++++++++++++ sysdeps/nacl/lxstat64.c | 1 + sysdeps/nacl/{fchmod.c => readlink.c} | 16 +++++++----- sysdeps/nacl/{fchmod.c => rename.c} | 9 +++---- sysdeps/nacl/{fchmod.c => rmdir.c} | 10 ++++---- sysdeps/nacl/{fchmod.c => symlink.c} | 10 ++++---- sysdeps/nacl/{fchmod.c => truncate.c} | 14 +++++++---- sysdeps/nacl/truncate64.c | 1 + sysdeps/nacl/{fchmod.c => utimes.c} | 13 +++++----- 13 files changed, 104 insertions(+), 48 deletions(-) copy sysdeps/nacl/{fchmod.c => chdir.c} (77%) copy sysdeps/nacl/{fchmod.c => chmod.c} (77%) copy sysdeps/nacl/{fchmod.c => link.c} (77%) create mode 100644 sysdeps/nacl/lxstat.c create mode 100644 sysdeps/nacl/lxstat64.c copy sysdeps/nacl/{fchmod.c => readlink.c} (64%) copy sysdeps/nacl/{fchmod.c => rename.c} (77%) copy sysdeps/nacl/{fchmod.c => rmdir.c} (77%) copy sysdeps/nacl/{fchmod.c => symlink.c} (77%) copy sysdeps/nacl/{fchmod.c => truncate.c} (70%) create mode 100644 sysdeps/nacl/truncate64.c copy sysdeps/nacl/{fchmod.c => utimes.c} (70%) diff --git a/sysdeps/nacl/fchmod.c b/sysdeps/nacl/chdir.c similarity index 77% copy from sysdeps/nacl/fchmod.c copy to sysdeps/nacl/chdir.c index a51094d4ad..e194ae95d1 100644 --- a/sysdeps/nacl/fchmod.c +++ b/sysdeps/nacl/chdir.c @@ -1,4 +1,4 @@ -/* Change a file's permissions given a file descriptor. NaCl version. +/* Change current working directory. NaCl version. Copyright (C) 2015 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -19,10 +19,10 @@ #include #include -/* Change the current directory to FD. */ +/* Change the current directory to PATH. */ int -__fchmod (int fd, mode_t mode) +__chdir (const char *path) { - return NACL_CALL (__nacl_irt_dev_fdio.fchmod (fd, mode), 0); + return NACL_CALL (__nacl_irt_dev_filename.chdir (path), 0); } -weak_alias (__fchmod, fchmod) +weak_alias (__chdir, chdir) diff --git a/sysdeps/nacl/fchmod.c b/sysdeps/nacl/chmod.c similarity index 77% copy from sysdeps/nacl/fchmod.c copy to sysdeps/nacl/chmod.c index a51094d4ad..9a8ba097b5 100644 --- a/sysdeps/nacl/fchmod.c +++ b/sysdeps/nacl/chmod.c @@ -1,4 +1,4 @@ -/* Change a file's permissions given a file descriptor. NaCl version. +/* Change a file's permissions. NaCl version. Copyright (C) 2015 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -19,10 +19,10 @@ #include #include -/* Change the current directory to FD. */ +/* Change the protections of FILE to MODE. */ int -__fchmod (int fd, mode_t mode) +__chmod (const char *file, mode_t mode) { - return NACL_CALL (__nacl_irt_dev_fdio.fchmod (fd, mode), 0); + return NACL_CALL (__nacl_irt_dev_filename.chmod (file, mode), 0); } -weak_alias (__fchmod, fchmod) +weak_alias (__chmod, chmod) diff --git a/sysdeps/nacl/fchmod.c b/sysdeps/nacl/fchmod.c index a51094d4ad..35d6939cb2 100644 --- a/sysdeps/nacl/fchmod.c +++ b/sysdeps/nacl/fchmod.c @@ -19,7 +19,7 @@ #include #include -/* Change the current directory to FD. */ +/* Change the permissions of the file referenced by FD to MODE. */ int __fchmod (int fd, mode_t mode) { diff --git a/sysdeps/nacl/fchmod.c b/sysdeps/nacl/link.c similarity index 77% copy from sysdeps/nacl/fchmod.c copy to sysdeps/nacl/link.c index a51094d4ad..49f071f3d9 100644 --- a/sysdeps/nacl/fchmod.c +++ b/sysdeps/nacl/link.c @@ -1,4 +1,4 @@ -/* Change a file's permissions given a file descriptor. NaCl version. +/* Make a hard link. NaCl version. Copyright (C) 2015 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -19,10 +19,10 @@ #include #include -/* Change the current directory to FD. */ +/* Make a link to FROM called TO. */ int -__fchmod (int fd, mode_t mode) +__link (const char *from, const char *to) { - return NACL_CALL (__nacl_irt_dev_fdio.fchmod (fd, mode), 0); + return NACL_CALL (__nacl_irt_dev_filename.link (from, to), 0); } -weak_alias (__fchmod, fchmod) +weak_alias (__link, link) diff --git a/sysdeps/nacl/lxstat.c b/sysdeps/nacl/lxstat.c new file mode 100644 index 0000000000..b14708529d --- /dev/null +++ b/sysdeps/nacl/lxstat.c @@ -0,0 +1,46 @@ +/* Get stat information from a file name NaCl version. + Copyright (C) 2015 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 + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* Avoid the declaration so the compiler doesn't complain about the alias + with a different type signature. It doesn't know that 'struct stat' + and 'struct stat64' are ABI-compatible. */ +#define __lxstat64 __lxstat64_avoid +#include +#undef __lxstat64 + +#include +#include + +#include + +#undef lstat + +/* Get file attributes about FILE and put them in BUF. + If FILE is a symbolic link, do not follow it. */ +int +__lxstat (int vers, const char *file, struct stat *buf) +{ + nacl_abi_stat_t abi_buf; + return NACL_CALL (__nacl_irt_dev_filename.lstat (file, &abi_buf), + __xstat_conv (vers, &abi_buf, buf)); +} +hidden_def (__lxstat) +weak_alias (__lxstat, _lxstat) + +strong_alias (__lxstat, __lxstat64) +hidden_ver (__lxstat, __lxstat64) diff --git a/sysdeps/nacl/lxstat64.c b/sysdeps/nacl/lxstat64.c new file mode 100644 index 0000000000..ca4ecd2be5 --- /dev/null +++ b/sysdeps/nacl/lxstat64.c @@ -0,0 +1 @@ +/* lxstat.c defines __lxstat64 as an alias. */ diff --git a/sysdeps/nacl/fchmod.c b/sysdeps/nacl/readlink.c similarity index 64% copy from sysdeps/nacl/fchmod.c copy to sysdeps/nacl/readlink.c index a51094d4ad..d1c4cadf55 100644 --- a/sysdeps/nacl/fchmod.c +++ b/sysdeps/nacl/readlink.c @@ -1,4 +1,4 @@ -/* Change a file's permissions given a file descriptor. NaCl version. +/* Read the contents of a symbolic link. NaCl version. Copyright (C) 2015 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -19,10 +19,14 @@ #include #include -/* Change the current directory to FD. */ -int -__fchmod (int fd, mode_t mode) +/* Read the contents of the symbolic link PATH into no more than + LEN bytes of BUF. The contents are not null-terminated. + Returns the number of characters read, or -1 for errors. */ +ssize_t +__readlink (const char *path, char *buf, size_t len) { - return NACL_CALL (__nacl_irt_dev_fdio.fchmod (fd, mode), 0); + size_t nread; + return NACL_CALL (__nacl_irt_dev_filename.readlink (path, buf, len, &nread), + nread); } -weak_alias (__fchmod, fchmod) +weak_alias (__readlink, readlink) diff --git a/sysdeps/nacl/fchmod.c b/sysdeps/nacl/rename.c similarity index 77% copy from sysdeps/nacl/fchmod.c copy to sysdeps/nacl/rename.c index a51094d4ad..a968eaf969 100644 --- a/sysdeps/nacl/fchmod.c +++ b/sysdeps/nacl/rename.c @@ -1,4 +1,4 @@ -/* Change a file's permissions given a file descriptor. NaCl version. +/* Make a hard link. NaCl version. Copyright (C) 2015 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -19,10 +19,9 @@ #include #include -/* Change the current directory to FD. */ +/* Rename the file OLD to NEW. */ int -__fchmod (int fd, mode_t mode) +rename (const char *old, const char *new) { - return NACL_CALL (__nacl_irt_dev_fdio.fchmod (fd, mode), 0); + return NACL_CALL (__nacl_irt_dev_filename.rename (old, new), 0); } -weak_alias (__fchmod, fchmod) diff --git a/sysdeps/nacl/fchmod.c b/sysdeps/nacl/rmdir.c similarity index 77% copy from sysdeps/nacl/fchmod.c copy to sysdeps/nacl/rmdir.c index a51094d4ad..917bffd4e7 100644 --- a/sysdeps/nacl/fchmod.c +++ b/sysdeps/nacl/rmdir.c @@ -1,4 +1,4 @@ -/* Change a file's permissions given a file descriptor. NaCl version. +/* Remove a directory. NaCl version. Copyright (C) 2015 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -19,10 +19,10 @@ #include #include -/* Change the current directory to FD. */ +/* Remove the directory PATH. */ int -__fchmod (int fd, mode_t mode) +__rmdir (const char *path) { - return NACL_CALL (__nacl_irt_dev_fdio.fchmod (fd, mode), 0); + return NACL_CALL (__nacl_irt_dev_filename.rmdir (path), 0); } -weak_alias (__fchmod, fchmod) +weak_alias (__rmdir, rmdir) diff --git a/sysdeps/nacl/fchmod.c b/sysdeps/nacl/symlink.c similarity index 77% copy from sysdeps/nacl/fchmod.c copy to sysdeps/nacl/symlink.c index a51094d4ad..1454589fda 100644 --- a/sysdeps/nacl/fchmod.c +++ b/sysdeps/nacl/symlink.c @@ -1,4 +1,4 @@ -/* Change a file's permissions given a file descriptor. NaCl version. +/* Make a symbolic link. NaCl version. Copyright (C) 2015 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -19,10 +19,10 @@ #include #include -/* Change the current directory to FD. */ +/* Make a symbolic link to FROM called TO. */ int -__fchmod (int fd, mode_t mode) +__symlink (const char *from, const char *to) { - return NACL_CALL (__nacl_irt_dev_fdio.fchmod (fd, mode), 0); + return NACL_CALL (__nacl_irt_dev_filename.symlink (from, to), 0); } -weak_alias (__fchmod, fchmod) +weak_alias (__symlink, symlink) diff --git a/sysdeps/nacl/fchmod.c b/sysdeps/nacl/truncate.c similarity index 70% copy from sysdeps/nacl/fchmod.c copy to sysdeps/nacl/truncate.c index a51094d4ad..cdb8ac7222 100644 --- a/sysdeps/nacl/fchmod.c +++ b/sysdeps/nacl/truncate.c @@ -1,4 +1,4 @@ -/* Change a file's permissions given a file descriptor. NaCl version. +/* Truncate a file (by name). NaCl version. Copyright (C) 2015 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -19,10 +19,14 @@ #include #include -/* Change the current directory to FD. */ +/* Truncate PATH to LENGTH bytes. */ int -__fchmod (int fd, mode_t mode) +__truncate (const char *path, off_t length) { - return NACL_CALL (__nacl_irt_dev_fdio.fchmod (fd, mode), 0); + return NACL_CALL (__nacl_irt_dev_filename.truncate (path, length), 0); } -weak_alias (__fchmod, fchmod) +weak_alias (__truncate, truncate) + +/* truncate64 is the same as truncate. */ +strong_alias (__truncate, __truncate64) +weak_alias (__truncate64, truncate64) diff --git a/sysdeps/nacl/truncate64.c b/sysdeps/nacl/truncate64.c new file mode 100644 index 0000000000..729d0d01db --- /dev/null +++ b/sysdeps/nacl/truncate64.c @@ -0,0 +1 @@ +/* truncate64 is the same as truncate. */ diff --git a/sysdeps/nacl/fchmod.c b/sysdeps/nacl/utimes.c similarity index 70% copy from sysdeps/nacl/fchmod.c copy to sysdeps/nacl/utimes.c index a51094d4ad..1f0f08a9e0 100644 --- a/sysdeps/nacl/fchmod.c +++ b/sysdeps/nacl/utimes.c @@ -1,4 +1,4 @@ -/* Change a file's permissions given a file descriptor. NaCl version. +/* Change the access and modification times of a file. NaCl version. Copyright (C) 2015 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -16,13 +16,14 @@ License along with the GNU C Library; if not, see . */ -#include +#include #include -/* Change the current directory to FD. */ +/* Change the access time of FILE to TVP[0] and + the modification time of FILE to TVP[1]. */ int -__fchmod (int fd, mode_t mode) +__utimes (const char *file, const struct timeval tvp[2]) { - return NACL_CALL (__nacl_irt_dev_fdio.fchmod (fd, mode), 0); + return NACL_CALL (__nacl_irt_dev_filename.utimes (file, tvp), 0); } -weak_alias (__fchmod, fchmod) +weak_alias (__utimes, utimes) -- 2.11.4.GIT