summary refs log tree commit diff
diff options
context:
space:
mode:
authorRoland McGrath <roland@hack.frob.com>2015-03-02 14:00:16 -0800
committerRoland McGrath <roland@hack.frob.com>2015-03-02 14:00:16 -0800
commita928fd829207e6ad9675ca6a80050517a2f3917f (patch)
tree8befd115708a4d7fac07cd31815848f2af8d6e3b
parent48a5cf1639ad1aa81f314543b84f150f3bd8f521 (diff)
downloadglibc-a928fd829207e6ad9675ca6a80050517a2f3917f.tar.gz
glibc-a928fd829207e6ad9675ca6a80050517a2f3917f.tar.xz
glibc-a928fd829207e6ad9675ca6a80050517a2f3917f.zip
Implement all nacl_irt_dev_filename calls.
-rw-r--r--sysdeps/nacl/chdir.c28
-rw-r--r--sysdeps/nacl/chmod.c28
-rw-r--r--sysdeps/nacl/fchmod.c2
-rw-r--r--sysdeps/nacl/link.c28
-rw-r--r--sysdeps/nacl/lxstat.c46
-rw-r--r--sysdeps/nacl/lxstat64.c1
-rw-r--r--sysdeps/nacl/readlink.c32
-rw-r--r--sysdeps/nacl/rename.c27
-rw-r--r--sysdeps/nacl/rmdir.c28
-rw-r--r--sysdeps/nacl/symlink.c28
-rw-r--r--sysdeps/nacl/truncate.c32
-rw-r--r--sysdeps/nacl/truncate64.c1
-rw-r--r--sysdeps/nacl/utimes.c29
13 files changed, 309 insertions, 1 deletions
diff --git a/sysdeps/nacl/chdir.c b/sysdeps/nacl/chdir.c
new file mode 100644
index 0000000000..e194ae95d1
--- /dev/null
+++ b/sysdeps/nacl/chdir.c
@@ -0,0 +1,28 @@
+/* Change current working directory.  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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <unistd.h>
+#include <nacl-interfaces.h>
+
+/* Change the current directory to PATH.  */
+int
+__chdir (const char *path)
+{
+  return NACL_CALL (__nacl_irt_dev_filename.chdir (path), 0);
+}
+weak_alias (__chdir, chdir)
diff --git a/sysdeps/nacl/chmod.c b/sysdeps/nacl/chmod.c
new file mode 100644
index 0000000000..9a8ba097b5
--- /dev/null
+++ b/sysdeps/nacl/chmod.c
@@ -0,0 +1,28 @@
+/* Change a file's permissions.  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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <unistd.h>
+#include <nacl-interfaces.h>
+
+/* Change the protections of FILE to MODE.  */
+int
+__chmod (const char *file, mode_t mode)
+{
+  return NACL_CALL (__nacl_irt_dev_filename.chmod (file, mode), 0);
+}
+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 <unistd.h>
 #include <nacl-interfaces.h>
 
-/* 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/link.c b/sysdeps/nacl/link.c
new file mode 100644
index 0000000000..49f071f3d9
--- /dev/null
+++ b/sysdeps/nacl/link.c
@@ -0,0 +1,28 @@
+/* Make a hard link.  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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <unistd.h>
+#include <nacl-interfaces.h>
+
+/* Make a link to FROM called TO.  */
+int
+__link (const char *from, const char *to)
+{
+  return NACL_CALL (__nacl_irt_dev_filename.link (from, to), 0);
+}
+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
+   <http://www.gnu.org/licenses/>.  */
+
+/* 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 <sys/stat.h>
+#undef  __lxstat64
+
+#include <errno.h>
+#include <stddef.h>
+
+#include <xstatconv.h>
+
+#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/readlink.c b/sysdeps/nacl/readlink.c
new file mode 100644
index 0000000000..d1c4cadf55
--- /dev/null
+++ b/sysdeps/nacl/readlink.c
@@ -0,0 +1,32 @@
+/* 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.
+
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <unistd.h>
+#include <nacl-interfaces.h>
+
+/* 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)
+{
+  size_t nread;
+  return NACL_CALL (__nacl_irt_dev_filename.readlink (path, buf, len, &nread),
+                    nread);
+}
+weak_alias (__readlink, readlink)
diff --git a/sysdeps/nacl/rename.c b/sysdeps/nacl/rename.c
new file mode 100644
index 0000000000..a968eaf969
--- /dev/null
+++ b/sysdeps/nacl/rename.c
@@ -0,0 +1,27 @@
+/* Make a hard link.  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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <unistd.h>
+#include <nacl-interfaces.h>
+
+/* Rename the file OLD to NEW.  */
+int
+rename (const char *old, const char *new)
+{
+  return NACL_CALL (__nacl_irt_dev_filename.rename (old, new), 0);
+}
diff --git a/sysdeps/nacl/rmdir.c b/sysdeps/nacl/rmdir.c
new file mode 100644
index 0000000000..917bffd4e7
--- /dev/null
+++ b/sysdeps/nacl/rmdir.c
@@ -0,0 +1,28 @@
+/* Remove a directory.  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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <unistd.h>
+#include <nacl-interfaces.h>
+
+/* Remove the directory PATH.  */
+int
+__rmdir (const char *path)
+{
+  return NACL_CALL (__nacl_irt_dev_filename.rmdir (path), 0);
+}
+weak_alias (__rmdir, rmdir)
diff --git a/sysdeps/nacl/symlink.c b/sysdeps/nacl/symlink.c
new file mode 100644
index 0000000000..1454589fda
--- /dev/null
+++ b/sysdeps/nacl/symlink.c
@@ -0,0 +1,28 @@
+/* Make a symbolic link.  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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <unistd.h>
+#include <nacl-interfaces.h>
+
+/* Make a symbolic link to FROM called TO.  */
+int
+__symlink (const char *from, const char *to)
+{
+  return NACL_CALL (__nacl_irt_dev_filename.symlink (from, to), 0);
+}
+weak_alias (__symlink, symlink)
diff --git a/sysdeps/nacl/truncate.c b/sysdeps/nacl/truncate.c
new file mode 100644
index 0000000000..cdb8ac7222
--- /dev/null
+++ b/sysdeps/nacl/truncate.c
@@ -0,0 +1,32 @@
+/* Truncate a file (by 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <unistd.h>
+#include <nacl-interfaces.h>
+
+/* Truncate PATH to LENGTH bytes.  */
+int
+__truncate (const char *path, off_t length)
+{
+  return NACL_CALL (__nacl_irt_dev_filename.truncate (path, length), 0);
+}
+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/utimes.c b/sysdeps/nacl/utimes.c
new file mode 100644
index 0000000000..1f0f08a9e0
--- /dev/null
+++ b/sysdeps/nacl/utimes.c
@@ -0,0 +1,29 @@
+/* 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.
+
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <sys/time.h>
+#include <nacl-interfaces.h>
+
+/* Change the access time of FILE to TVP[0] and
+   the modification time of FILE to TVP[1].  */
+int
+__utimes (const char *file, const struct timeval tvp[2])
+{
+  return NACL_CALL (__nacl_irt_dev_filename.utimes (file, tvp), 0);
+}
+weak_alias (__utimes, utimes)