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