|
|
a2cf7d |
From: Florian Weimer <fweimer@redhat.com>
|
|
|
a2cf7d |
Date: Tue, 18 Feb 2020 12:44:48 +0000 (+0100)
|
|
|
a2cf7d |
Subject: Move implementation of <file_change_detection.h> into a C file
|
|
|
a2cf7d |
X-Git-Url: https://sourceware.org/git/?p=glibc.git;a=commitdiff_plain;h=631cf64bc1d8306e011ef39f60b8cb6de91bd271
|
|
|
a2cf7d |
|
|
|
a2cf7d |
Move implementation of <file_change_detection.h> into a C file
|
|
|
a2cf7d |
|
|
|
a2cf7d |
file_change_detection_for_stat partially initialize
|
|
|
a2cf7d |
struct file_change_detection in some cases, when the size member
|
|
|
a2cf7d |
alone determines the outcome of all comparisons. This results
|
|
|
a2cf7d |
in maybe-uninitialized compiler warnings in case of sufficiently
|
|
|
a2cf7d |
aggressive inlining.
|
|
|
a2cf7d |
|
|
|
a2cf7d |
Once the implementation is moved into a separate C file, this kind
|
|
|
a2cf7d |
of inlining is no longer possible, so the compiler warnings are gone.
|
|
|
a2cf7d |
---
|
|
|
a2cf7d |
|
|
|
a2cf7d |
diff --git a/include/file_change_detection.h b/include/file_change_detection.h
|
|
|
a2cf7d |
index aaed0a9b6d..767e578555 100644
|
|
|
a2cf7d |
--- a/include/file_change_detection.h
|
|
|
a2cf7d |
+++ b/include/file_change_detection.h
|
|
|
a2cf7d |
@@ -16,9 +16,10 @@
|
|
|
a2cf7d |
License along with the GNU C Library; if not, see
|
|
|
a2cf7d |
<https://www.gnu.org/licenses/>. */
|
|
|
a2cf7d |
|
|
|
a2cf7d |
-#include <errno.h>
|
|
|
a2cf7d |
+#ifndef _FILE_CHANGE_DETECTION_H
|
|
|
a2cf7d |
+#define _FILE_CHANGE_DETECTION_H
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
#include <stdbool.h>
|
|
|
a2cf7d |
-#include <stddef.h>
|
|
|
a2cf7d |
#include <stdio.h>
|
|
|
a2cf7d |
#include <sys/stat.h>
|
|
|
a2cf7d |
#include <sys/types.h>
|
|
|
a2cf7d |
@@ -38,103 +39,32 @@ struct file_change_detection
|
|
|
a2cf7d |
|
|
|
a2cf7d |
/* Returns true if *LEFT and *RIGHT describe the same version of the
|
|
|
a2cf7d |
same file. */
|
|
|
a2cf7d |
-static bool __attribute__ ((unused))
|
|
|
a2cf7d |
-file_is_unchanged (const struct file_change_detection *left,
|
|
|
a2cf7d |
- const struct file_change_detection *right)
|
|
|
a2cf7d |
-{
|
|
|
a2cf7d |
- if (left->size < 0 || right->size < 0)
|
|
|
a2cf7d |
- /* Negative sizes are used as markers and never match. */
|
|
|
a2cf7d |
- return false;
|
|
|
a2cf7d |
- else if (left->size == 0 && right->size == 0)
|
|
|
a2cf7d |
- /* Both files are empty or do not exist, so they have the same
|
|
|
a2cf7d |
- content, no matter what the other fields indicate. */
|
|
|
a2cf7d |
- return true;
|
|
|
a2cf7d |
- else
|
|
|
a2cf7d |
- return left->size == right->size
|
|
|
a2cf7d |
- && left->ino == right->ino
|
|
|
a2cf7d |
- && left->mtime.tv_sec == right->mtime.tv_sec
|
|
|
a2cf7d |
- && left->mtime.tv_nsec == right->mtime.tv_nsec
|
|
|
a2cf7d |
- && left->ctime.tv_sec == right->ctime.tv_sec
|
|
|
a2cf7d |
- && left->ctime.tv_nsec == right->ctime.tv_nsec;
|
|
|
a2cf7d |
-}
|
|
|
a2cf7d |
+bool __file_is_unchanged (const struct file_change_detection *left,
|
|
|
a2cf7d |
+ const struct file_change_detection *right);
|
|
|
a2cf7d |
|
|
|
a2cf7d |
/* Extract file change information to *FILE from the stat buffer
|
|
|
a2cf7d |
*ST. */
|
|
|
a2cf7d |
-static void __attribute__ ((unused))
|
|
|
a2cf7d |
-file_change_detection_for_stat (struct file_change_detection *file,
|
|
|
a2cf7d |
- const struct stat64 *st)
|
|
|
a2cf7d |
-{
|
|
|
a2cf7d |
- if (S_ISDIR (st->st_mode))
|
|
|
a2cf7d |
- /* Treat as empty file. */
|
|
|
a2cf7d |
- file->size = 0;
|
|
|
a2cf7d |
- else if (!S_ISREG (st->st_mode))
|
|
|
a2cf7d |
- /* Non-regular files cannot be cached. */
|
|
|
a2cf7d |
- file->size = -1;
|
|
|
a2cf7d |
- else
|
|
|
a2cf7d |
- {
|
|
|
a2cf7d |
- file->size = st->st_size;
|
|
|
a2cf7d |
- file->ino = st->st_ino;
|
|
|
a2cf7d |
- file->mtime = st->st_mtim;
|
|
|
a2cf7d |
- file->ctime = st->st_ctim;
|
|
|
a2cf7d |
- }
|
|
|
a2cf7d |
-}
|
|
|
a2cf7d |
+void __file_change_detection_for_stat (struct file_change_detection *file,
|
|
|
a2cf7d |
+ const struct stat64 *st);
|
|
|
a2cf7d |
|
|
|
a2cf7d |
/* Writes file change information for PATH to *FILE. Returns true on
|
|
|
a2cf7d |
success. For benign errors, *FILE is cleared, and true is
|
|
|
a2cf7d |
returned. For errors indicating resource outages and the like,
|
|
|
a2cf7d |
false is returned. */
|
|
|
a2cf7d |
-static bool __attribute__ ((unused))
|
|
|
a2cf7d |
-file_change_detection_for_path (struct file_change_detection *file,
|
|
|
a2cf7d |
- const char *path)
|
|
|
a2cf7d |
-{
|
|
|
a2cf7d |
- struct stat64 st;
|
|
|
a2cf7d |
- if (stat64 (path, &st) != 0)
|
|
|
a2cf7d |
- switch (errno)
|
|
|
a2cf7d |
- {
|
|
|
a2cf7d |
- case EACCES:
|
|
|
a2cf7d |
- case EISDIR:
|
|
|
a2cf7d |
- case ELOOP:
|
|
|
a2cf7d |
- case ENOENT:
|
|
|
a2cf7d |
- case ENOTDIR:
|
|
|
a2cf7d |
- case EPERM:
|
|
|
a2cf7d |
- /* Ignore errors due to file system contents. Instead, treat
|
|
|
a2cf7d |
- the file as empty. */
|
|
|
a2cf7d |
- file->size = 0;
|
|
|
a2cf7d |
- return true;
|
|
|
a2cf7d |
- default:
|
|
|
a2cf7d |
- /* Other errors are fatal. */
|
|
|
a2cf7d |
- return false;
|
|
|
a2cf7d |
- }
|
|
|
a2cf7d |
- else /* stat64 was successfull. */
|
|
|
a2cf7d |
- {
|
|
|
a2cf7d |
- file_change_detection_for_stat (file, &st);
|
|
|
a2cf7d |
- return true;
|
|
|
a2cf7d |
- }
|
|
|
a2cf7d |
-}
|
|
|
a2cf7d |
+bool __file_change_detection_for_path (struct file_change_detection *file,
|
|
|
a2cf7d |
+ const char *path);
|
|
|
a2cf7d |
|
|
|
a2cf7d |
/* Writes file change information for the stream FP to *FILE. Returns
|
|
|
a2cf7d |
ture on success, false on failure. If FP is NULL, treat the file
|
|
|
a2cf7d |
as non-existing. */
|
|
|
a2cf7d |
-static bool __attribute__ ((unused))
|
|
|
a2cf7d |
-file_change_detection_for_fp (struct file_change_detection *file,
|
|
|
a2cf7d |
- FILE *fp)
|
|
|
a2cf7d |
-{
|
|
|
a2cf7d |
- if (fp == NULL)
|
|
|
a2cf7d |
- {
|
|
|
a2cf7d |
- /* The file does not exist. */
|
|
|
a2cf7d |
- file->size = 0;
|
|
|
a2cf7d |
- return true;
|
|
|
a2cf7d |
- }
|
|
|
a2cf7d |
- else
|
|
|
a2cf7d |
- {
|
|
|
a2cf7d |
- struct stat64 st;
|
|
|
a2cf7d |
- if (fstat64 (__fileno (fp), &st) != 0)
|
|
|
a2cf7d |
- /* If we already have a file descriptor, all errors are fatal. */
|
|
|
a2cf7d |
- return false;
|
|
|
a2cf7d |
- else
|
|
|
a2cf7d |
- {
|
|
|
a2cf7d |
- file_change_detection_for_stat (file, &st);
|
|
|
a2cf7d |
- return true;
|
|
|
a2cf7d |
- }
|
|
|
a2cf7d |
- }
|
|
|
a2cf7d |
-}
|
|
|
a2cf7d |
+bool __file_change_detection_for_fp (struct file_change_detection *file,
|
|
|
a2cf7d |
+ FILE *fp);
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+#ifndef _ISOMAC
|
|
|
a2cf7d |
+libc_hidden_proto (__file_is_unchanged)
|
|
|
a2cf7d |
+libc_hidden_proto (__file_change_detection_for_stat)
|
|
|
a2cf7d |
+libc_hidden_proto (__file_change_detection_for_path)
|
|
|
a2cf7d |
+libc_hidden_proto (__file_change_detection_for_fp)
|
|
|
a2cf7d |
+#endif
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+#endif /* _FILE_CHANGE_DETECTION_H */
|
|
|
a2cf7d |
diff --git a/io/Makefile b/io/Makefile
|
|
|
a2cf7d |
index 04c4647dc0..cf380f3516 100644
|
|
|
a2cf7d |
--- a/io/Makefile
|
|
|
a2cf7d |
+++ b/io/Makefile
|
|
|
a2cf7d |
@@ -55,7 +55,7 @@ routines := \
|
|
|
a2cf7d |
posix_fadvise posix_fadvise64 \
|
|
|
a2cf7d |
posix_fallocate posix_fallocate64 \
|
|
|
a2cf7d |
sendfile sendfile64 copy_file_range \
|
|
|
a2cf7d |
- utimensat futimens
|
|
|
a2cf7d |
+ utimensat futimens file_change_detection
|
|
|
a2cf7d |
|
|
|
a2cf7d |
# These routines will be omitted from the libc shared object.
|
|
|
a2cf7d |
# Instead the static object files will be included in a special archive
|
|
|
a2cf7d |
diff --git a/io/Versions b/io/Versions
|
|
|
a2cf7d |
index f7e5dbe49e..ee468055ff 100644
|
|
|
a2cf7d |
--- a/io/Versions
|
|
|
a2cf7d |
+++ b/io/Versions
|
|
|
a2cf7d |
@@ -137,5 +137,9 @@ libc {
|
|
|
a2cf7d |
__fcntl_nocancel;
|
|
|
a2cf7d |
__open64_nocancel;
|
|
|
a2cf7d |
__write_nocancel;
|
|
|
a2cf7d |
+ __file_is_unchanged;
|
|
|
a2cf7d |
+ __file_change_detection_for_stat;
|
|
|
a2cf7d |
+ __file_change_detection_for_path;
|
|
|
a2cf7d |
+ __file_change_detection_for_fp;
|
|
|
a2cf7d |
}
|
|
|
a2cf7d |
}
|
|
|
a2cf7d |
diff --git a/io/file_change_detection.c b/io/file_change_detection.c
|
|
|
a2cf7d |
new file mode 100644
|
|
|
a2cf7d |
index 0000000000..c6d700ed05
|
|
|
a2cf7d |
--- /dev/null
|
|
|
a2cf7d |
+++ b/io/file_change_detection.c
|
|
|
a2cf7d |
@@ -0,0 +1,118 @@
|
|
|
a2cf7d |
+/* Detecting file changes using modification times.
|
|
|
a2cf7d |
+ Copyright (C) 2017-2020 Free Software Foundation, Inc.
|
|
|
a2cf7d |
+ This file is part of the GNU C Library.
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
a2cf7d |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
a2cf7d |
+ License as published by the Free Software Foundation; either
|
|
|
a2cf7d |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
a2cf7d |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
a2cf7d |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
a2cf7d |
+ Lesser General Public License for more details.
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
a2cf7d |
+ License along with the GNU C Library; if not, see
|
|
|
a2cf7d |
+ <https://www.gnu.org/licenses/>. */
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+#include <file_change_detection.h>
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+#include <errno.h>
|
|
|
a2cf7d |
+#include <stddef.h>
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+bool
|
|
|
a2cf7d |
+__file_is_unchanged (const struct file_change_detection *left,
|
|
|
a2cf7d |
+ const struct file_change_detection *right)
|
|
|
a2cf7d |
+{
|
|
|
a2cf7d |
+ if (left->size < 0 || right->size < 0)
|
|
|
a2cf7d |
+ /* Negative sizes are used as markers and never match. */
|
|
|
a2cf7d |
+ return false;
|
|
|
a2cf7d |
+ else if (left->size == 0 && right->size == 0)
|
|
|
a2cf7d |
+ /* Both files are empty or do not exist, so they have the same
|
|
|
a2cf7d |
+ content, no matter what the other fields indicate. */
|
|
|
a2cf7d |
+ return true;
|
|
|
a2cf7d |
+ else
|
|
|
a2cf7d |
+ return left->size == right->size
|
|
|
a2cf7d |
+ && left->ino == right->ino
|
|
|
a2cf7d |
+ && left->mtime.tv_sec == right->mtime.tv_sec
|
|
|
a2cf7d |
+ && left->mtime.tv_nsec == right->mtime.tv_nsec
|
|
|
a2cf7d |
+ && left->ctime.tv_sec == right->ctime.tv_sec
|
|
|
a2cf7d |
+ && left->ctime.tv_nsec == right->ctime.tv_nsec;
|
|
|
a2cf7d |
+}
|
|
|
a2cf7d |
+libc_hidden_def (__file_is_unchanged)
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+void
|
|
|
a2cf7d |
+__file_change_detection_for_stat (struct file_change_detection *file,
|
|
|
a2cf7d |
+ const struct stat64 *st)
|
|
|
a2cf7d |
+{
|
|
|
a2cf7d |
+ if (S_ISDIR (st->st_mode))
|
|
|
a2cf7d |
+ /* Treat as empty file. */
|
|
|
a2cf7d |
+ file->size = 0;
|
|
|
a2cf7d |
+ else if (!S_ISREG (st->st_mode))
|
|
|
a2cf7d |
+ /* Non-regular files cannot be cached. */
|
|
|
a2cf7d |
+ file->size = -1;
|
|
|
a2cf7d |
+ else
|
|
|
a2cf7d |
+ {
|
|
|
a2cf7d |
+ file->size = st->st_size;
|
|
|
a2cf7d |
+ file->ino = st->st_ino;
|
|
|
a2cf7d |
+ file->mtime = st->st_mtim;
|
|
|
a2cf7d |
+ file->ctime = st->st_ctim;
|
|
|
a2cf7d |
+ }
|
|
|
a2cf7d |
+}
|
|
|
a2cf7d |
+libc_hidden_def (__file_change_detection_for_stat)
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+bool
|
|
|
a2cf7d |
+__file_change_detection_for_path (struct file_change_detection *file,
|
|
|
a2cf7d |
+ const char *path)
|
|
|
a2cf7d |
+{
|
|
|
a2cf7d |
+ struct stat64 st;
|
|
|
a2cf7d |
+ if (stat64 (path, &st) != 0)
|
|
|
a2cf7d |
+ switch (errno)
|
|
|
a2cf7d |
+ {
|
|
|
a2cf7d |
+ case EACCES:
|
|
|
a2cf7d |
+ case EISDIR:
|
|
|
a2cf7d |
+ case ELOOP:
|
|
|
a2cf7d |
+ case ENOENT:
|
|
|
a2cf7d |
+ case ENOTDIR:
|
|
|
a2cf7d |
+ case EPERM:
|
|
|
a2cf7d |
+ /* Ignore errors due to file system contents. Instead, treat
|
|
|
a2cf7d |
+ the file as empty. */
|
|
|
a2cf7d |
+ file->size = 0;
|
|
|
a2cf7d |
+ return true;
|
|
|
a2cf7d |
+ default:
|
|
|
a2cf7d |
+ /* Other errors are fatal. */
|
|
|
a2cf7d |
+ return false;
|
|
|
a2cf7d |
+ }
|
|
|
a2cf7d |
+ else /* stat64 was successfull. */
|
|
|
a2cf7d |
+ {
|
|
|
a2cf7d |
+ __file_change_detection_for_stat (file, &st);
|
|
|
a2cf7d |
+ return true;
|
|
|
a2cf7d |
+ }
|
|
|
a2cf7d |
+}
|
|
|
a2cf7d |
+libc_hidden_def (__file_change_detection_for_path)
|
|
|
a2cf7d |
+
|
|
|
a2cf7d |
+bool
|
|
|
a2cf7d |
+__file_change_detection_for_fp (struct file_change_detection *file,
|
|
|
a2cf7d |
+ FILE *fp)
|
|
|
a2cf7d |
+{
|
|
|
a2cf7d |
+ if (fp == NULL)
|
|
|
a2cf7d |
+ {
|
|
|
a2cf7d |
+ /* The file does not exist. */
|
|
|
a2cf7d |
+ file->size = 0;
|
|
|
a2cf7d |
+ return true;
|
|
|
a2cf7d |
+ }
|
|
|
a2cf7d |
+ else
|
|
|
a2cf7d |
+ {
|
|
|
a2cf7d |
+ struct stat64 st;
|
|
|
a2cf7d |
+ if (fstat64 (__fileno (fp), &st) != 0)
|
|
|
a2cf7d |
+ /* If we already have a file descriptor, all errors are fatal. */
|
|
|
a2cf7d |
+ return false;
|
|
|
a2cf7d |
+ else
|
|
|
a2cf7d |
+ {
|
|
|
a2cf7d |
+ __file_change_detection_for_stat (file, &st);
|
|
|
a2cf7d |
+ return true;
|
|
|
a2cf7d |
+ }
|
|
|
a2cf7d |
+ }
|
|
|
a2cf7d |
+}
|
|
|
a2cf7d |
+libc_hidden_def (__file_change_detection_for_fp)
|
|
|
a2cf7d |
diff --git a/io/tst-file_change_detection.c b/io/tst-file_change_detection.c
|
|
|
a2cf7d |
index 035dd39c4d..6e00e787b1 100644
|
|
|
a2cf7d |
--- a/io/tst-file_change_detection.c
|
|
|
a2cf7d |
+++ b/io/tst-file_change_detection.c
|
|
|
a2cf7d |
@@ -16,10 +16,6 @@
|
|
|
a2cf7d |
License along with the GNU C Library; if not, see
|
|
|
a2cf7d |
<https://www.gnu.org/licenses/>. */
|
|
|
a2cf7d |
|
|
|
a2cf7d |
-/* The header uses the internal __fileno symbol, which is not
|
|
|
a2cf7d |
- available outside of libc (even to internal tests). */
|
|
|
a2cf7d |
-#define __fileno(fp) fileno (fp)
|
|
|
a2cf7d |
-
|
|
|
a2cf7d |
#include <file_change_detection.h>
|
|
|
a2cf7d |
|
|
|
a2cf7d |
#include <array_length.h>
|
|
|
a2cf7d |
@@ -40,7 +36,7 @@ all_same (struct file_change_detection *array, size_t length)
|
|
|
a2cf7d |
{
|
|
|
a2cf7d |
if (test_verbose > 0)
|
|
|
a2cf7d |
printf ("info: comparing %zu and %zu\n", i, j);
|
|
|
a2cf7d |
- TEST_VERIFY (file_is_unchanged (array + i, array + j));
|
|
|
a2cf7d |
+ TEST_VERIFY (__file_is_unchanged (array + i, array + j));
|
|
|
a2cf7d |
}
|
|
|
a2cf7d |
}
|
|
|
a2cf7d |
|
|
|
a2cf7d |
@@ -54,7 +50,7 @@ all_different (struct file_change_detection *array, size_t length)
|
|
|
a2cf7d |
continue;
|
|
|
a2cf7d |
if (test_verbose > 0)
|
|
|
a2cf7d |
printf ("info: comparing %zu and %zu\n", i, j);
|
|
|
a2cf7d |
- TEST_VERIFY (!file_is_unchanged (array + i, array + j));
|
|
|
a2cf7d |
+ TEST_VERIFY (!__file_is_unchanged (array + i, array + j));
|
|
|
a2cf7d |
}
|
|
|
a2cf7d |
}
|
|
|
a2cf7d |
|
|
|
a2cf7d |
@@ -105,24 +101,24 @@ do_test (void)
|
|
|
a2cf7d |
struct file_change_detection fcd[10];
|
|
|
a2cf7d |
int i = 0;
|
|
|
a2cf7d |
/* Two empty files always have the same contents. */
|
|
|
a2cf7d |
- TEST_VERIFY (file_change_detection_for_path (&fcd[i++], path_empty1));
|
|
|
a2cf7d |
- TEST_VERIFY (file_change_detection_for_path (&fcd[i++], path_empty2));
|
|
|
a2cf7d |
+ TEST_VERIFY (__file_change_detection_for_path (&fcd[i++], path_empty1));
|
|
|
a2cf7d |
+ TEST_VERIFY (__file_change_detection_for_path (&fcd[i++], path_empty2));
|
|
|
a2cf7d |
/* So does a missing file (which is treated as empty). */
|
|
|
a2cf7d |
- TEST_VERIFY (file_change_detection_for_path (&fcd[i++],
|
|
|
a2cf7d |
- path_does_not_exist));
|
|
|
a2cf7d |
+ TEST_VERIFY (__file_change_detection_for_path (&fcd[i++],
|
|
|
a2cf7d |
+ path_does_not_exist));
|
|
|
a2cf7d |
/* And a symbolic link loop. */
|
|
|
a2cf7d |
- TEST_VERIFY (file_change_detection_for_path (&fcd[i++], path_loop));
|
|
|
a2cf7d |
+ TEST_VERIFY (__file_change_detection_for_path (&fcd[i++], path_loop));
|
|
|
a2cf7d |
/* And a dangling symbolic link. */
|
|
|
a2cf7d |
- TEST_VERIFY (file_change_detection_for_path (&fcd[i++], path_dangling));
|
|
|
a2cf7d |
+ TEST_VERIFY (__file_change_detection_for_path (&fcd[i++], path_dangling));
|
|
|
a2cf7d |
/* And a directory. */
|
|
|
a2cf7d |
- TEST_VERIFY (file_change_detection_for_path (&fcd[i++], tempdir));
|
|
|
a2cf7d |
+ TEST_VERIFY (__file_change_detection_for_path (&fcd[i++], tempdir));
|
|
|
a2cf7d |
/* And a symbolic link to an empty file. */
|
|
|
a2cf7d |
- TEST_VERIFY (file_change_detection_for_path (&fcd[i++], path_to_empty1));
|
|
|
a2cf7d |
+ TEST_VERIFY (__file_change_detection_for_path (&fcd[i++], path_to_empty1));
|
|
|
a2cf7d |
/* Likewise for access the file via a FILE *. */
|
|
|
a2cf7d |
- TEST_VERIFY (file_change_detection_for_fp (&fcd[i++], fp_empty1));
|
|
|
a2cf7d |
- TEST_VERIFY (file_change_detection_for_fp (&fcd[i++], fp_empty2));
|
|
|
a2cf7d |
+ TEST_VERIFY (__file_change_detection_for_fp (&fcd[i++], fp_empty1));
|
|
|
a2cf7d |
+ TEST_VERIFY (__file_change_detection_for_fp (&fcd[i++], fp_empty2));
|
|
|
a2cf7d |
/* And a NULL FILE * (missing file). */
|
|
|
a2cf7d |
- TEST_VERIFY (file_change_detection_for_fp (&fcd[i++], NULL));
|
|
|
a2cf7d |
+ TEST_VERIFY (__file_change_detection_for_fp (&fcd[i++], NULL));
|
|
|
a2cf7d |
TEST_COMPARE (i, array_length (fcd));
|
|
|
a2cf7d |
|
|
|
a2cf7d |
all_same (fcd, array_length (fcd));
|
|
|
a2cf7d |
@@ -132,9 +128,9 @@ do_test (void)
|
|
|
a2cf7d |
{
|
|
|
a2cf7d |
struct file_change_detection fcd[3];
|
|
|
a2cf7d |
int i = 0;
|
|
|
a2cf7d |
- TEST_VERIFY (file_change_detection_for_path (&fcd[i++], path_file1));
|
|
|
a2cf7d |
- TEST_VERIFY (file_change_detection_for_path (&fcd[i++], path_to_file1));
|
|
|
a2cf7d |
- TEST_VERIFY (file_change_detection_for_fp (&fcd[i++], fp_file1));
|
|
|
a2cf7d |
+ TEST_VERIFY (__file_change_detection_for_path (&fcd[i++], path_file1));
|
|
|
a2cf7d |
+ TEST_VERIFY (__file_change_detection_for_path (&fcd[i++], path_to_file1));
|
|
|
a2cf7d |
+ TEST_VERIFY (__file_change_detection_for_fp (&fcd[i++], fp_file1));
|
|
|
a2cf7d |
TEST_COMPARE (i, array_length (fcd));
|
|
|
a2cf7d |
all_same (fcd, array_length (fcd));
|
|
|
a2cf7d |
}
|
|
|
a2cf7d |
@@ -144,20 +140,20 @@ do_test (void)
|
|
|
a2cf7d |
struct file_change_detection fcd[5];
|
|
|
a2cf7d |
int i = 0;
|
|
|
a2cf7d |
/* The other files are not empty. */
|
|
|
a2cf7d |
- TEST_VERIFY (file_change_detection_for_path (&fcd[i++], path_empty1));
|
|
|
a2cf7d |
+ TEST_VERIFY (__file_change_detection_for_path (&fcd[i++], path_empty1));
|
|
|
a2cf7d |
/* These two files have the same contents, but have different file
|
|
|
a2cf7d |
identity. */
|
|
|
a2cf7d |
- TEST_VERIFY (file_change_detection_for_path (&fcd[i++], path_file1));
|
|
|
a2cf7d |
- TEST_VERIFY (file_change_detection_for_path (&fcd[i++], path_file2));
|
|
|
a2cf7d |
+ TEST_VERIFY (__file_change_detection_for_path (&fcd[i++], path_file1));
|
|
|
a2cf7d |
+ TEST_VERIFY (__file_change_detection_for_path (&fcd[i++], path_file2));
|
|
|
a2cf7d |
/* FIFOs are always different, even with themselves. */
|
|
|
a2cf7d |
- TEST_VERIFY (file_change_detection_for_path (&fcd[i++], path_fifo));
|
|
|
a2cf7d |
- TEST_VERIFY (file_change_detection_for_path (&fcd[i++], path_fifo));
|
|
|
a2cf7d |
+ TEST_VERIFY (__file_change_detection_for_path (&fcd[i++], path_fifo));
|
|
|
a2cf7d |
+ TEST_VERIFY (__file_change_detection_for_path (&fcd[i++], path_fifo));
|
|
|
a2cf7d |
TEST_COMPARE (i, array_length (fcd));
|
|
|
a2cf7d |
all_different (fcd, array_length (fcd));
|
|
|
a2cf7d |
|
|
|
a2cf7d |
/* Replacing the file with its symbolic link does not make a
|
|
|
a2cf7d |
difference. */
|
|
|
a2cf7d |
- TEST_VERIFY (file_change_detection_for_path (&fcd[1], path_to_file1));
|
|
|
a2cf7d |
+ TEST_VERIFY (__file_change_detection_for_path (&fcd[1], path_to_file1));
|
|
|
a2cf7d |
all_different (fcd, array_length (fcd));
|
|
|
a2cf7d |
}
|
|
|
a2cf7d |
|
|
|
a2cf7d |
@@ -166,16 +162,17 @@ do_test (void)
|
|
|
a2cf7d |
for (int use_stdio = 0; use_stdio < 2; ++use_stdio)
|
|
|
a2cf7d |
{
|
|
|
a2cf7d |
struct file_change_detection initial;
|
|
|
a2cf7d |
- TEST_VERIFY (file_change_detection_for_path (&initial, path_file1));
|
|
|
a2cf7d |
+ TEST_VERIFY (__file_change_detection_for_path (&initial, path_file1));
|
|
|
a2cf7d |
while (true)
|
|
|
a2cf7d |
{
|
|
|
a2cf7d |
support_write_file_string (path_file1, "line\n");
|
|
|
a2cf7d |
struct file_change_detection current;
|
|
|
a2cf7d |
if (use_stdio)
|
|
|
a2cf7d |
- TEST_VERIFY (file_change_detection_for_fp (¤t, fp_file1));
|
|
|
a2cf7d |
+ TEST_VERIFY (__file_change_detection_for_fp (¤t, fp_file1));
|
|
|
a2cf7d |
else
|
|
|
a2cf7d |
- TEST_VERIFY (file_change_detection_for_path (¤t, path_file1));
|
|
|
a2cf7d |
- if (!file_is_unchanged (&initial, ¤t))
|
|
|
a2cf7d |
+ TEST_VERIFY (__file_change_detection_for_path
|
|
|
a2cf7d |
+ (¤t, path_file1));
|
|
|
a2cf7d |
+ if (!__file_is_unchanged (&initial, ¤t))
|
|
|
a2cf7d |
break;
|
|
|
a2cf7d |
/* Wait for a bit to reduce system load. */
|
|
|
a2cf7d |
usleep (100 * 1000);
|
|
|
a2cf7d |
diff --git a/resolv/res_init.c b/resolv/res_init.c
|
|
|
a2cf7d |
index 98d84f264d..ee5dfdd391 100644
|
|
|
a2cf7d |
--- a/resolv/res_init.c
|
|
|
a2cf7d |
+++ b/resolv/res_init.c
|
|
|
a2cf7d |
@@ -583,7 +583,7 @@ __resolv_conf_load (struct __res_state *preinit,
|
|
|
a2cf7d |
if (ok && change != NULL)
|
|
|
a2cf7d |
/* Update the file change information if the configuration was
|
|
|
a2cf7d |
loaded successfully. */
|
|
|
a2cf7d |
- ok = file_change_detection_for_fp (change, fp);
|
|
|
a2cf7d |
+ ok = __file_change_detection_for_fp (change, fp);
|
|
|
a2cf7d |
|
|
|
a2cf7d |
if (ok)
|
|
|
a2cf7d |
{
|
|
|
a2cf7d |
diff --git a/resolv/resolv_conf.c b/resolv/resolv_conf.c
|
|
|
a2cf7d |
index 29a1f4fb94..286149ffad 100644
|
|
|
a2cf7d |
--- a/resolv/resolv_conf.c
|
|
|
a2cf7d |
+++ b/resolv/resolv_conf.c
|
|
|
a2cf7d |
@@ -121,7 +121,7 @@ struct resolv_conf *
|
|
|
a2cf7d |
__resolv_conf_get_current (void)
|
|
|
a2cf7d |
{
|
|
|
a2cf7d |
struct file_change_detection initial;
|
|
|
a2cf7d |
- if (!file_change_detection_for_path (&initial, _PATH_RESCONF))
|
|
|
a2cf7d |
+ if (!__file_change_detection_for_path (&initial, _PATH_RESCONF))
|
|
|
a2cf7d |
return NULL;
|
|
|
a2cf7d |
|
|
|
a2cf7d |
struct resolv_conf_global *global_copy = get_locked_global ();
|
|
|
a2cf7d |
@@ -129,7 +129,7 @@ __resolv_conf_get_current (void)
|
|
|
a2cf7d |
return NULL;
|
|
|
a2cf7d |
struct resolv_conf *conf;
|
|
|
a2cf7d |
if (global_copy->conf_current != NULL
|
|
|
a2cf7d |
- && file_is_unchanged (&initial, &global_copy->file_resolve_conf))
|
|
|
a2cf7d |
+ && __file_is_unchanged (&initial, &global_copy->file_resolve_conf))
|
|
|
a2cf7d |
/* We can reuse the cached configuration object. */
|
|
|
a2cf7d |
conf = global_copy->conf_current;
|
|
|
a2cf7d |
else
|
|
|
a2cf7d |
@@ -149,7 +149,7 @@ __resolv_conf_get_current (void)
|
|
|
a2cf7d |
/etc/resolv.conf is temporarily replaced while the file
|
|
|
a2cf7d |
is read (after the initial measurement), and restored to
|
|
|
a2cf7d |
the initial version later. */
|
|
|
a2cf7d |
- if (file_is_unchanged (&initial, &after_load))
|
|
|
a2cf7d |
+ if (__file_is_unchanged (&initial, &after_load))
|
|
|
a2cf7d |
global_copy->file_resolve_conf = after_load;
|
|
|
a2cf7d |
else
|
|
|
a2cf7d |
/* If there is a discrepancy, trigger a reload during the
|