From 48a5cf1639ad1aa81f314543b84f150f3bd8f521 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 2 Mar 2015 13:28:55 -0800 Subject: Implement all nacl_irt_dev_fdio calls except getdents. --- sysdeps/nacl/fchdir.c | 28 ++++++++++++++++++++++++++++ sysdeps/nacl/fchmod.c | 28 ++++++++++++++++++++++++++++ sysdeps/nacl/fdatasync.c | 28 ++++++++++++++++++++++++++++ sysdeps/nacl/fsync.c | 27 +++++++++++++++++++++++++++ sysdeps/nacl/ftruncate.c | 32 ++++++++++++++++++++++++++++++++ sysdeps/nacl/ftruncate64.c | 1 + sysdeps/nacl/isatty.c | 29 +++++++++++++++++++++++++++++ sysdeps/nacl/nacl-interface-list.h | 2 ++ 8 files changed, 175 insertions(+) create mode 100644 sysdeps/nacl/fchdir.c create mode 100644 sysdeps/nacl/fchmod.c create mode 100644 sysdeps/nacl/fdatasync.c create mode 100644 sysdeps/nacl/fsync.c create mode 100644 sysdeps/nacl/ftruncate.c create mode 100644 sysdeps/nacl/ftruncate64.c create mode 100644 sysdeps/nacl/isatty.c 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 + . */ + +#include +#include + +/* 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 + . */ + +#include +#include + +/* 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 + . */ + +#include +#include + +/* 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 + . */ + +#include +#include + +/* 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 + . */ + +#include +#include + +/* 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 + . */ + +#include +#include + +/* 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) -- cgit 1.4.1