]>
Commit | Line | Data |
---|---|---|
0d8733c4 | 1 | /* Determine whether descriptor has given property. |
d614a753 | 2 | Copyright (C) 1996-2020 Free Software Foundation, Inc. |
0d8733c4 | 3 | This file is part of the GNU C Library. |
503054c0 | 4 | |
0d8733c4 | 5 | The GNU C Library is free software; you can redistribute it and/or |
41bdb6e2 AJ |
6 | modify it under the terms of the GNU Lesser General Public |
7 | License as published by the Free Software Foundation; either | |
8 | version 2.1 of the License, or (at your option) any later version. | |
503054c0 | 9 | |
0d8733c4 UD |
10 | The GNU C Library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
41bdb6e2 | 13 | Lesser General Public License for more details. |
503054c0 | 14 | |
41bdb6e2 | 15 | You should have received a copy of the GNU Lesser General Public |
59ba27a6 | 16 | License along with the GNU C Library; if not, see |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
503054c0 RM |
18 | |
19 | #include <errno.h> | |
20 | #include <sys/stat.h> | |
21 | #include <sys/socket.h> | |
0d8733c4 | 22 | #include <sys/types.h> |
503054c0 RM |
23 | |
24 | int | |
25 | isfdtype (int fildes, int fdtype) | |
26 | { | |
8edf6e0d | 27 | struct stat64 st; |
503054c0 RM |
28 | int result; |
29 | ||
30 | { | |
31 | int save_error = errno; | |
8edf6e0d | 32 | result = fstat64 (fildes, &st); |
c4029823 | 33 | __set_errno (save_error); |
503054c0 RM |
34 | } |
35 | ||
0d8733c4 | 36 | return result ?: (st.st_mode & S_IFMT) == (mode_t) fdtype; |
503054c0 | 37 | } |