elf: Add a way to check if tunable is set (BZ 27069)
[glibc.git] / include / file_change_detection.h
blobc9b86b727ea738b32a38b80cf79d7a63271f28d6
1 /* Detecting file changes using modification times.
2 Copyright (C) 2017-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
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.
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
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
19 #ifndef _FILE_CHANGE_DETECTION_H
20 #define _FILE_CHANGE_DETECTION_H
22 #include <stdbool.h>
23 #include <stdio.h>
24 #include <sys/stat.h>
25 #include <sys/types.h>
27 /* Items for identifying a particular file version. Excerpt from
28 struct stat64. */
29 struct file_change_detection
31 /* Special values: 0 if file does not exist. -1 to force mismatch
32 with the next comparison. */
33 off64_t size;
35 ino64_t ino;
36 struct __timespec64 mtime;
37 struct __timespec64 ctime;
40 /* Returns true if *LEFT and *RIGHT describe the same version of the
41 same file. */
42 bool __file_is_unchanged (const struct file_change_detection *left,
43 const struct file_change_detection *right);
45 /* Extract file change information to *FILE from the stat buffer
46 *ST. */
47 void __file_change_detection_for_stat (struct file_change_detection *file,
48 const struct __stat64_t64 *st);
50 /* Writes file change information for PATH to *FILE. Returns true on
51 success. For benign errors, *FILE is cleared, and true is
52 returned. For errors indicating resource outages and the like,
53 false is returned. */
54 bool __file_change_detection_for_path (struct file_change_detection *file,
55 const char *path);
57 /* Writes file change information for the stream FP to *FILE. Returns
58 true on success, false on failure. If FP is NULL, treat the file
59 as non-existing. */
60 bool __file_change_detection_for_fp (struct file_change_detection *file,
61 FILE *fp);
63 #ifndef _ISOMAC
64 libc_hidden_proto (__file_is_unchanged)
65 libc_hidden_proto (__file_change_detection_for_stat)
66 libc_hidden_proto (__file_change_detection_for_path)
67 libc_hidden_proto (__file_change_detection_for_fp)
68 #endif
70 #endif /* _FILE_CHANGE_DETECTION_H */