(root)/
coreutils-9.4/
lib/
root-dev-ino.h
       1  /* Root device and inode number checking.
       2  
       3     Copyright (C) 2003-2023 Free Software Foundation, Inc.
       4  
       5     This program is free software: you can redistribute it and/or modify
       6     it under the terms of the GNU General Public License as published by
       7     the Free Software Foundation, either version 3 of the License, or
       8     (at your option) any later version.
       9  
      10     This program 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
      13     GNU General Public License for more details.
      14  
      15     You should have received a copy of the GNU General Public License
      16     along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
      17  
      18  #ifndef ROOT_DEV_INO_H
      19  # define ROOT_DEV_INO_H 1
      20  
      21  # include "dev-ino.h"
      22  # include "same-inode.h"
      23  
      24  struct dev_ino *
      25  get_root_dev_ino (struct dev_ino *root_d_i) _GL_ATTRIBUTE_NONNULL ();
      26  
      27  /* These macros are common to the programs that support the
      28     --preserve-root and --no-preserve-root options.  */
      29  
      30  # define ROOT_DEV_INO_CHECK(Root_dev_ino, Dir_statbuf) \
      31      (Root_dev_ino && SAME_INODE (*Dir_statbuf, *Root_dev_ino))
      32  
      33  # define ROOT_DEV_INO_WARN(Dirname)					\
      34    do									\
      35      {									\
      36        if (STREQ (Dirname, "/"))						\
      37          error (0, 0, _("it is dangerous to operate recursively on %s"),	\
      38                 quoteaf (Dirname));					\
      39        else								\
      40          error (0, 0,							\
      41                 _("it is dangerous to operate recursively on %s (same as %s)"), \
      42                 quoteaf_n (0, Dirname), quoteaf_n (1, "/"));		\
      43        error (0, 0, _("use --no-preserve-root to override this failsafe")); \
      44      }									\
      45    while (0)
      46  
      47  #endif