root/lib/openat.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. chownat
  2. lchownat
  3. chmodat
  4. lchmodat
  5. statat
  6. lstatat

     1 /* provide a replacement openat function
     2    Copyright (C) 2004-2006, 2008-2023 Free Software Foundation, Inc.
     3 
     4    This program is free software: you can redistribute it and/or modify
     5    it under the terms of the GNU General Public License as published by
     6    the Free Software Foundation, either version 3 of the License, or
     7    (at your option) any later version.
     8 
     9    This program is distributed in the hope that it will be useful,
    10    but WITHOUT ANY WARRANTY; without even the implied warranty of
    11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    12    GNU General Public License for more details.
    13 
    14    You should have received a copy of the GNU General Public License
    15    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
    16 
    17 /* written by Jim Meyering */
    18 
    19 #ifndef _GL_HEADER_OPENAT
    20 #define _GL_HEADER_OPENAT
    21 
    22 #include <fcntl.h>
    23 
    24 #include <sys/types.h>
    25 #include <sys/stat.h>
    26 #include <unistd.h>
    27 
    28 #ifndef _GL_INLINE_HEADER_BEGIN
    29  #error "Please include config.h first."
    30 #endif
    31 _GL_INLINE_HEADER_BEGIN
    32 
    33 #if !HAVE_OPENAT
    34 
    35 int openat_permissive (int fd, char const *file, int flags, mode_t mode,
    36                        int *cwd_errno);
    37 bool openat_needs_fchdir (void);
    38 
    39 #else
    40 
    41 # define openat_permissive(Fd, File, Flags, Mode, Cwd_errno) \
    42     openat (Fd, File, Flags, Mode)
    43 # define openat_needs_fchdir() false
    44 
    45 #endif
    46 
    47 _Noreturn void openat_restore_fail (int);
    48 _Noreturn void openat_save_fail (int);
    49 
    50 /* Using these function names makes application code
    51    slightly more readable than it would be with
    52    fchownat (..., 0) or fchownat (..., AT_SYMLINK_NOFOLLOW).  */
    53 
    54 #if GNULIB_CHOWNAT
    55 
    56 # ifndef CHOWNAT_INLINE
    57 #  define CHOWNAT_INLINE _GL_INLINE
    58 # endif
    59 
    60 CHOWNAT_INLINE int
    61 chownat (int fd, char const *file, uid_t owner, gid_t group)
    62 {
    63   return fchownat (fd, file, owner, group, 0);
    64 }
    65 
    66 CHOWNAT_INLINE int
    67 lchownat (int fd, char const *file, uid_t owner, gid_t group)
    68 {
    69   return fchownat (fd, file, owner, group, AT_SYMLINK_NOFOLLOW);
    70 }
    71 
    72 #endif
    73 
    74 #if GNULIB_CHMODAT
    75 
    76 # ifndef CHMODAT_INLINE
    77 #  define CHMODAT_INLINE _GL_INLINE
    78 # endif
    79 
    80 CHMODAT_INLINE int
    81 chmodat (int fd, char const *file, mode_t mode)
    82 {
    83   return fchmodat (fd, file, mode, 0);
    84 }
    85 
    86 CHMODAT_INLINE int
    87 lchmodat (int fd, char const *file, mode_t mode)
    88 {
    89   return fchmodat (fd, file, mode, AT_SYMLINK_NOFOLLOW);
    90 }
    91 
    92 #endif
    93 
    94 #if GNULIB_STATAT
    95 
    96 # ifndef STATAT_INLINE
    97 #  define STATAT_INLINE _GL_INLINE
    98 # endif
    99 
   100 _GL_ATTRIBUTE_DEPRECATED
   101 STATAT_INLINE int
   102 statat (int fd, char const *name, struct stat *st)
   103 {
   104   return fstatat (fd, name, st, 0);
   105 }
   106 
   107 _GL_ATTRIBUTE_DEPRECATED
   108 STATAT_INLINE int
   109 lstatat (int fd, char const *name, struct stat *st)
   110 {
   111   return fstatat (fd, name, st, AT_SYMLINK_NOFOLLOW);
   112 }
   113 
   114 #endif
   115 
   116 /* For now, there are no wrappers named laccessat or leuidaccessat,
   117    since gnulib doesn't support faccessat(,AT_SYMLINK_NOFOLLOW) and
   118    since access rights on symlinks are of limited utility.  Likewise,
   119    wrappers are not provided for accessat or euidaccessat, so as to
   120    avoid dragging in -lgen on some platforms.  */
   121 
   122 _GL_INLINE_HEADER_END
   123 
   124 #endif /* _GL_HEADER_OPENAT */

/* [<][>][^][v][top][bottom][index][help] */