diff options
Diffstat (limited to 'io')
-rw-r--r-- | io/Makefile | 1 | ||||
-rw-r--r-- | io/Versions | 3 | ||||
-rw-r--r-- | io/fcntl.h | 7 | ||||
-rw-r--r-- | io/isatty.c | 31 | ||||
-rw-r--r-- | io/tst-stat-time64.c | 6 | ||||
-rw-r--r-- | io/tst-stat.c | 25 |
6 files changed, 34 insertions, 39 deletions
diff --git a/io/Makefile b/io/Makefile index e06f3cb..435f5a9 100644 --- a/io/Makefile +++ b/io/Makefile @@ -91,7 +91,6 @@ routines := \ getcwd \ getdirname \ getwd \ - isatty \ lchmod \ lchown \ link \ diff --git a/io/Versions b/io/Versions index 4e19540..04d196e 100644 --- a/io/Versions +++ b/io/Versions @@ -26,9 +26,6 @@ libc { # g* get_current_dir_name; getcwd; getwd; - # i* - isatty; - # l* lchown; link; lockf; lseek; @@ -281,16 +281,17 @@ extern int creat64 (const char *__file, mode_t __mode) __nonnull ((1)); # define F_TEST 3 /* Test a region for other processes locks. */ # ifndef __USE_FILE_OFFSET64 -extern int lockf (int __fd, int __cmd, off_t __len); +extern int lockf (int __fd, int __cmd, off_t __len) __wur; # else # ifdef __REDIRECT -extern int __REDIRECT (lockf, (int __fd, int __cmd, __off64_t __len), lockf64); +extern int __REDIRECT (lockf, (int __fd, int __cmd, __off64_t __len), + lockf64) __wur; # else # define lockf lockf64 # endif # endif # ifdef __USE_LARGEFILE64 -extern int lockf64 (int __fd, int __cmd, off64_t __len); +extern int lockf64 (int __fd, int __cmd, off64_t __len) __wur; # endif #endif diff --git a/io/isatty.c b/io/isatty.c deleted file mode 100644 index 3f3912d..0000000 --- a/io/isatty.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (C) 1991-2025 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 - <https://www.gnu.org/licenses/>. */ - -#include <errno.h> -#include <unistd.h> - -/* Return 1 if FD is a terminal, 0 if not. */ -int -__isatty (int fd) -{ - __set_errno (ENOSYS); - return -1; -} - -weak_alias (__isatty, isatty) - -stub_warning (isatty) diff --git a/io/tst-stat-time64.c b/io/tst-stat-time64.c index a20265c..4415765 100644 --- a/io/tst-stat-time64.c +++ b/io/tst-stat-time64.c @@ -52,6 +52,12 @@ fstat_check (int fd, const char *path, struct stat *st) static void fstatat_check (int fd, const char *path, struct stat *st) { + TEST_COMPARE (fstatat (fd, "", st, 0), -1); + TEST_COMPARE (errno, ENOENT); + + TEST_COMPARE (fstatat (AT_FDCWD, "_non_existing_file", st, 0), -1); + TEST_COMPARE (errno, ENOENT); + TEST_COMPARE (fstatat (fd, path, st, 0), 0); } diff --git a/io/tst-stat.c b/io/tst-stat.c index cc57aec..5e0bfcc 100644 --- a/io/tst-stat.c +++ b/io/tst-stat.c @@ -27,6 +27,7 @@ #include <sys/sysmacros.h> #include <stdio.h> #include <unistd.h> +#include <stdlib.h> static void stat_check (int fd, const char *path, struct stat *st) @@ -56,15 +57,30 @@ fstatat_check (int fd, const char *path, struct stat *st) TEST_COMPARE (fstatat (fd, "", st, 0), -1); TEST_COMPARE (errno, ENOENT); + TEST_COMPARE (fstatat (AT_FDCWD, "_non_existing_file", st, 0), -1); + TEST_COMPARE (errno, ENOENT); + TEST_COMPARE (fstatat (fd, path, st, 0), 0); } +static void +fstatat_link (const char *path, struct stat *st) +{ + TEST_COMPARE (fstatat (AT_FDCWD, path, st, 0), -1); + TEST_COMPARE (errno, ENOENT); + + TEST_COMPARE (fstatat (AT_FDCWD, path, st, AT_SYMLINK_NOFOLLOW), 0); + TEST_COMPARE (!S_ISLNK(st->st_mode), 0); +} + typedef void (*test_t)(int, const char *path, struct stat *); static int do_test (void) { char *path; + char *tempdir = support_create_temp_directory ("tst-stat-"); + char *linkname = xasprintf ("%s/tst-fstat.linkname", tempdir); int fd = create_temp_file ("tst-fstat.", &path); TEST_VERIFY_EXIT (fd >= 0); support_write_file_string (path, "abc"); @@ -78,13 +94,13 @@ do_test (void) printf ("warning: timestamp with nanoseconds not supported\n"); struct statx stx; + struct stat st; TEST_COMPARE (statx (fd, path, 0, STATX_BASIC_STATS, &stx), 0); test_t tests[] = { stat_check, lstat_check, fstat_check, fstatat_check }; for (int i = 0; i < array_length (tests); i++) { - struct stat st; tests[i](fd, path, &st); TEST_COMPARE (stx.stx_dev_major, major (st.st_dev)); @@ -108,6 +124,13 @@ do_test (void) } } + TEST_COMPARE (symlink ("tst-fstat.target", linkname), 0); + add_temp_file (linkname); + fstatat_link (linkname, &st); + + free (linkname); + free (tempdir); + return 0; } |