summary refs log tree commit diff
diff options
context:
space:
mode:
authorRoland McGrath <roland@hack.frob.com>2015-03-02 13:28:55 -0800
committerRoland McGrath <roland@hack.frob.com>2015-03-02 13:28:55 -0800
commit48a5cf1639ad1aa81f314543b84f150f3bd8f521 (patch)
tree8201f07d0f4160bd1e12d8500aa9a4cd07c2cfff
parente139961aad7217dd06444c523a557bfee6013a69 (diff)
downloadglibc-48a5cf1639ad1aa81f314543b84f150f3bd8f521.tar.gz
glibc-48a5cf1639ad1aa81f314543b84f150f3bd8f521.tar.xz
glibc-48a5cf1639ad1aa81f314543b84f150f3bd8f521.zip
Implement all nacl_irt_dev_fdio calls except getdents.
-rw-r--r--sysdeps/nacl/fchdir.c28
-rw-r--r--sysdeps/nacl/fchmod.c28
-rw-r--r--sysdeps/nacl/fdatasync.c28
-rw-r--r--sysdeps/nacl/fsync.c27
-rw-r--r--sysdeps/nacl/ftruncate.c32
-rw-r--r--sysdeps/nacl/ftruncate64.c1
-rw-r--r--sysdeps/nacl/isatty.c29
-rw-r--r--sysdeps/nacl/nacl-interface-list.h2
8 files changed, 175 insertions, 0 deletions
diff --git a/sysdeps/nacl/fchdir.c b/sysdeps/nacl/fchdir.c
new file mode 100644
index 0000000000..4295bc2c6d
--- /dev/null
+++ b/sysdeps/nacl/fchdir.c
@@ -0,0 +1,28 @@
+/* Change working directory given a file descriptor.  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 FD.  */
+int
+__fchdir (int fd)
+{
+  return NACL_CALL (__nacl_irt_dev_fdio.fchdir (fd), 0);
+}
+weak_alias (__fchdir, fchdir)
diff --git a/sysdeps/nacl/fchmod.c b/sysdeps/nacl/fchmod.c
new file mode 100644
index 0000000000..a51094d4ad
--- /dev/null
+++ b/sysdeps/nacl/fchmod.c
@@ -0,0 +1,28 @@
+/* Change a file's permissions given a file descriptor.  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 FD.  */
+int
+__fchmod (int fd, mode_t mode)
+{
+  return NACL_CALL (__nacl_irt_dev_fdio.fchmod (fd, mode), 0);
+}
+weak_alias (__fchmod, fchmod)
diff --git a/sysdeps/nacl/fdatasync.c b/sysdeps/nacl/fdatasync.c
new file mode 100644
index 0000000000..cd7a55ff41
--- /dev/null
+++ b/sysdeps/nacl/fdatasync.c
@@ -0,0 +1,28 @@
+/* Make all changes done to file data actually appear on disk.  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>
+
+/* Synchronize at least the data part of a file with the underlying
+   media.  */
+int
+fdatasync (int fd)
+{
+  return NACL_CALL (__nacl_irt_dev_fdio.fdatasync (fd), 0);
+}
diff --git a/sysdeps/nacl/fsync.c b/sysdeps/nacl/fsync.c
new file mode 100644
index 0000000000..6f6622b7db
--- /dev/null
+++ b/sysdeps/nacl/fsync.c
@@ -0,0 +1,27 @@
+/* Make all changes done to FD actually appear on disk.  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 all changes done to FD actually appear on disk.  */
+int
+fsync (int fd)
+{
+  return NACL_CALL (__nacl_irt_dev_fdio.fsync (fd), 0);
+}
diff --git a/sysdeps/nacl/ftruncate.c b/sysdeps/nacl/ftruncate.c
new file mode 100644
index 0000000000..1235f0d804
--- /dev/null
+++ b/sysdeps/nacl/ftruncate.c
@@ -0,0 +1,32 @@
+/* Truncate 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 <unistd.h>
+#include <nacl-interfaces.h>
+
+/* Truncate the file referenced by FD to LENGTH bytes.  */
+int
+__ftruncate (int fd, off_t length)
+{
+  return NACL_CALL (__nacl_irt_dev_fdio.ftruncate (fd, length), 0);
+}
+weak_alias (__ftruncate, ftruncate)
+
+/* ftruncate64 is the same as ftruncate.  */
+strong_alias (__ftruncate, __ftruncate64)
+weak_alias (__ftruncate64, ftruncate64)
diff --git a/sysdeps/nacl/ftruncate64.c b/sysdeps/nacl/ftruncate64.c
new file mode 100644
index 0000000000..e40129af66
--- /dev/null
+++ b/sysdeps/nacl/ftruncate64.c
@@ -0,0 +1 @@
+/* ftruncate64 is the same as ftruncate.  */
diff --git a/sysdeps/nacl/isatty.c b/sysdeps/nacl/isatty.c
new file mode 100644
index 0000000000..6e2b01ad94
--- /dev/null
+++ b/sysdeps/nacl/isatty.c
@@ -0,0 +1,29 @@
+/* Determine if a file descriptor refers to a terminal.  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>
+
+/* Return 1 if FD is a terminal, 0 if not.  */
+int
+__isatty (int fd)
+{
+  int result;
+  return NACL_CALL (__nacl_irt_dev_fdio.isatty (fd, &result), result);
+}
+weak_alias (__isatty, isatty)
diff --git a/sysdeps/nacl/nacl-interface-list.h b/sysdeps/nacl/nacl-interface-list.h
index 2ead2a6725..11ad69ac16 100644
--- a/sysdeps/nacl/nacl-interface-list.h
+++ b/sysdeps/nacl/nacl-interface-list.h
@@ -25,3 +25,5 @@ NACL_OPTIONAL_INTERFACE (rtld,
                          NACL_IRT_DEV_GETPID_v0_1, nacl_irt_dev_getpid)
 NACL_OPTIONAL_INTERFACE (rtld,
                          NACL_IRT_DEV_FILENAME_v0_3, nacl_irt_dev_filename)
+NACL_OPTIONAL_INTERFACE (libc,
+                         NACL_IRT_DEV_FDIO_v0_3, nacl_irt_dev_fdio)