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