root/include/crm/common/io_internal.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. pcmk__open_devnull

   1 /*
   2  * Copyright 2022-2024 the Pacemaker project contributors
   3  *
   4  * The version control history for this file may have further details.
   5  *
   6  * This source code is licensed under the GNU Lesser General Public License
   7  * version 2.1 or later (LGPLv2.1+) WITHOUT ANY WARRANTY.
   8  */
   9 
  10 #ifndef PCMK__CRM_COMMON_IO_INTERNAL__H
  11 #define PCMK__CRM_COMMON_IO_INTERNAL__H
  12 
  13 #include <fcntl.h>              // open()
  14 #include <stdbool.h>            // bool
  15 #include <unistd.h>             // uid_t, gid_t
  16 
  17 #ifdef __cplusplus
  18 extern "C" {
  19 #endif
  20 
  21 int pcmk__real_path(const char *path, char **resolved_path);
  22 
  23 char *pcmk__series_filename(const char *directory, const char *series,
  24                             unsigned int sequence, bool bzip);
  25 int pcmk__read_series_sequence(const char *directory, const char *series,
  26                                unsigned int *seq);
  27 void pcmk__write_series_sequence(const char *directory, const char *series,
  28                                  unsigned int sequence, int max);
  29 int pcmk__chown_series_sequence(const char *directory, const char *series,
  30                                 uid_t uid, gid_t gid);
  31 
  32 int pcmk__build_path(const char *path_c, mode_t mode);
  33 char *pcmk__full_path(const char *filename, const char *dirname);
  34 bool pcmk__daemon_can_write(const char *dir, const char *file);
  35 void pcmk__sync_directory(const char *name);
  36 
  37 int pcmk__file_contents(const char *filename, char **contents);
  38 int pcmk__write_sync(int fd, const char *contents);
  39 int pcmk__set_nonblocking(int fd);
  40 const char *pcmk__get_tmpdir(void);
  41 
  42 void pcmk__close_fds_in_child(bool);
  43 
  44 /*!
  45  * \internal
  46  * \brief Open /dev/null to consume next available file descriptor
  47  *
  48  * Open /dev/null, disregarding the result. This is intended when daemonizing to
  49  * be able to null stdin, stdout, and stderr.
  50  *
  51  * \param[in] flags  O_RDONLY (stdin) or O_WRONLY (stdout and stderr)
  52  */
  53 static inline void
  54 pcmk__open_devnull(int flags)
     /* [previous][next][first][last][top][bottom][index][help] */
  55 {
  56     // Static analysis clutter
  57     // cppcheck-suppress leakReturnValNotUsed
  58     (void) open("/dev/null", flags);
  59 }
  60 
  61 #ifdef __cplusplus
  62 }
  63 #endif
  64 
  65 #endif // PCMK__CRM_COMMON_IO_INTERNAL__H

/* [previous][next][first][last][top][bottom][index][help] */