root/opal/mca/pmix/pmix4x/pmix/src/util/fd.h

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

INCLUDED FROM


   1 /*
   2  * Copyright (c) 2008-2014 Cisco Systems, Inc.  All rights reserved.
   3  * Copyright (c) 2009      Sandia National Laboratories. All rights reserved.
   4  * Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
   5  *
   6  * Copyright (c) 2015      Research Organization for Information Science
   7  *                         and Technology (RIST). All rights reserved.
   8  * $COPYRIGHT$
   9  *
  10  * Additional copyrights may follow
  11  *
  12  * $HEADER$
  13  */
  14 
  15 /* @file */
  16 
  17 #ifndef PMIX_UTIL_FD_H_
  18 #define PMIX_UTIL_FD_H_
  19 
  20 #include <src/include/pmix_config.h>
  21 
  22 
  23 BEGIN_C_DECLS
  24 
  25 /**
  26  * Read a complete buffer from a file descriptor.
  27  *
  28  * @param fd File descriptor
  29  * @param len Number of bytes to read
  30  * @param buffer Pre-allocated buffer (large enough to hold len bytes)
  31  *
  32  * @returns PMIX_SUCCESS upon success.
  33  * @returns PMIX_ERR_TIMEOUT if the fd closes before reading the full amount.
  34  * @returns PMIX_ERR_IN_ERRNO otherwise.
  35  *
  36  * Loop over reading from the fd until len bytes are read or an error
  37  * occurs.  EAGAIN and EINTR are transparently handled.
  38  */
  39 PMIX_EXPORT pmix_status_t pmix_fd_read(int fd, int len, void *buffer);
  40 
  41 /**
  42  * Write a complete buffer to a file descriptor.
  43  *
  44  * @param fd File descriptor
  45  * @param len Number of bytes to write
  46  * @param buffer Buffer to write from
  47  *
  48  * @returns PMIX_SUCCESS upon success.
  49  * @returns PMIX_ERR_IN_ERRNO otherwise.
  50  *
  51  * Loop over writing to the fd until len bytes are written or an error
  52  * occurs.  EAGAIN and EINTR are transparently handled.
  53  */
  54 PMIX_EXPORT pmix_status_t pmix_fd_write(int fd, int len, const void *buffer);
  55 
  56 /**
  57  * Convenience function to set a file descriptor to be close-on-exec.
  58  *
  59  * @param fd File descriptor
  60  *
  61  * @returns PMIX_SUCCESS upon success (or if the system does not
  62  * support close-on-exec behavior).
  63  * @returns PMIX_ERR_IN_ERRNO otherwise.
  64  *
  65  * This is simply a convenience function because there's a few steps
  66  * to setting a file descriptor to be close-on-exec.
  67  */
  68 PMIX_EXPORT pmix_status_t pmix_fd_set_cloexec(int fd);
  69 
  70 /**
  71  * Convenience function to check if fd point to an accessible regular file.
  72  *
  73  * @param fd File descriptor
  74  *
  75  * @returns true if "fd" points to a regular file.
  76  * @returns false otherwise.
  77  */
  78 PMIX_EXPORT bool pmix_fd_is_regular(int fd);
  79 
  80 /**
  81  * Convenience function to check if fd point to an accessible character device.
  82  *
  83  * @param fd File descriptor
  84  *
  85  * @returns true if "fd" points to a regular file.
  86  * @returns false otherwise.
  87  */
  88 PMIX_EXPORT bool pmix_fd_is_chardev(int fd);
  89 
  90 /**
  91  * Convenience function to check if fd point to an accessible block device.
  92  *
  93  * @param fd File descriptor
  94  *
  95  * @returns true if "fd" points to a regular file.
  96  * @returns false otherwise.
  97  */
  98 PMIX_EXPORT bool pmix_fd_is_blkdev(int fd);
  99 
 100 
 101 END_C_DECLS
 102 
 103 #endif

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