From: Roland McGrath Date: Mon, 2 Mar 2015 21:28:55 +0000 (-0800) Subject: Implement all nacl_irt_dev_fdio calls except getdents. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48a5cf1639ad1aa81f314543b84f150f3bd8f521;p=thirdparty%2Fglibc.git Implement all nacl_irt_dev_fdio calls except getdents. --- diff --git a/sysdeps/nacl/fchdir.c b/sysdeps/nacl/fchdir.c new file mode 100644 index 00000000000..4295bc2c6d5 --- /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 00000000000..a51094d4ade --- /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 00000000000..cd7a55ff415 --- /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 00000000000..6f6622b7db3 --- /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 00000000000..1235f0d8044 --- /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 00000000000..e40129af66d --- /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 00000000000..6e2b01ad94e --- /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 2ead2a67250..11ad69ac16d 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)