Blame include/file_change_detection.h

Packit Service bd5658
/* Detecting file changes using modification times.
Packit Service bd5658
   Copyright (C) 2017-2020 Free Software Foundation, Inc.
Packit Service bd5658
   This file is part of the GNU C Library.
Packit Service bd5658
Packit Service bd5658
   The GNU C Library is free software; you can redistribute it and/or
Packit Service bd5658
   modify it under the terms of the GNU Lesser General Public
Packit Service bd5658
   License as published by the Free Software Foundation; either
Packit Service bd5658
   version 2.1 of the License, or (at your option) any later version.
Packit Service bd5658
Packit Service bd5658
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service bd5658
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service bd5658
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service bd5658
   Lesser General Public License for more details.
Packit Service bd5658
Packit Service bd5658
   You should have received a copy of the GNU Lesser General Public
Packit Service bd5658
   License along with the GNU C Library; if not, see
Packit Service bd5658
   <https://www.gnu.org/licenses/>.  */
Packit Service bd5658
Packit Service bbd36c
#ifndef _FILE_CHANGE_DETECTION_H
Packit Service bbd36c
#define _FILE_CHANGE_DETECTION_H
Packit Service bbd36c
Packit Service bd5658
#include <stdbool.h>
Packit Service bd5658
#include <stdio.h>
Packit Service bd5658
#include <sys/stat.h>
Packit Service bd5658
#include <sys/types.h>
Packit Service bd5658
Packit Service bd5658
/* Items for identifying a particular file version.  Excerpt from
Packit Service bd5658
   struct stat64.  */
Packit Service bd5658
struct file_change_detection
Packit Service bd5658
{
Packit Service bd5658
  /* Special values: 0 if file does not exist.  -1 to force mismatch
Packit Service bd5658
     with the next comparison.  */
Packit Service bd5658
  off64_t size;
Packit Service bd5658
Packit Service bd5658
  ino64_t ino;
Packit Service bd5658
  struct timespec mtime;
Packit Service bd5658
  struct timespec ctime;
Packit Service bd5658
};
Packit Service bd5658
Packit Service bd5658
/* Returns true if *LEFT and *RIGHT describe the same version of the
Packit Service bd5658
   same file.  */
Packit Service bbd36c
bool __file_is_unchanged (const struct file_change_detection *left,
Packit Service bbd36c
                          const struct file_change_detection *right);
Packit Service bd5658
Packit Service bd5658
/* Extract file change information to *FILE from the stat buffer
Packit Service bd5658
   *ST.  */
Packit Service bbd36c
void __file_change_detection_for_stat (struct file_change_detection *file,
Packit Service bbd36c
                                       const struct stat64 *st);
Packit Service bd5658
Packit Service bd5658
/* Writes file change information for PATH to *FILE.  Returns true on
Packit Service bd5658
   success.  For benign errors, *FILE is cleared, and true is
Packit Service bd5658
   returned.  For errors indicating resource outages and the like,
Packit Service bd5658
   false is returned.  */
Packit Service bbd36c
bool __file_change_detection_for_path (struct file_change_detection *file,
Packit Service bbd36c
                                       const char *path);
Packit Service bd5658
Packit Service bd5658
/* Writes file change information for the stream FP to *FILE.  Returns
Packit Service bd5658
   ture on success, false on failure.  If FP is NULL, treat the file
Packit Service bd5658
   as non-existing.  */
Packit Service bbd36c
bool __file_change_detection_for_fp (struct file_change_detection *file,
Packit Service bbd36c
                                     FILE *fp);
Packit Service bbd36c
Packit Service bbd36c
#ifndef _ISOMAC
Packit Service bbd36c
libc_hidden_proto (__file_is_unchanged)
Packit Service bbd36c
libc_hidden_proto (__file_change_detection_for_stat)
Packit Service bbd36c
libc_hidden_proto (__file_change_detection_for_path)
Packit Service bbd36c
libc_hidden_proto (__file_change_detection_for_fp)
Packit Service bbd36c
#endif
Packit Service bbd36c
Packit Service bbd36c
#endif /* _FILE_CHANGE_DETECTION_H */