Home | History | Annotate | Download | only in libutil
      1 /**
      2  * @file op_deviceio.h
      3  * Reading from a special device
      4  *
      5  * @remark Copyright 2002 OProfile authors
      6  * @remark Read the file COPYING
      7  *
      8  * @author John Levon
      9  * @author Philippe Elie
     10  */
     11 
     12 #ifndef OP_DEVICEIO_H
     13 #define OP_DEVICEIO_H
     14 
     15 #ifdef __cplusplus
     16 extern "C" {
     17 #endif
     18 
     19 #include "op_types.h"
     20 
     21 #include <unistd.h>
     22 
     23 /**
     24  * op_open_device - open a special char device for reading
     25  * @param name  file name of device file
     26  *
     27  * Open the special file name. Returns the file descriptor
     28  * for the file or -1 on error.
     29  */
     30 fd_t op_open_device(char const * name);
     31 
     32 /**
     33  * op_read_device - read from a special char device
     34  * @param devfd  file descriptor of device
     35  * @param buf  buffer
     36  * @param size  size of buffer
     37  *
     38  * Read size bytes from a device into buffer buf.
     39  * A seek to the start of the device file is done first
     40  * then a read is requested in one go of size bytes.
     41  *
     42  * It is the caller's responsibility to do further op_read_device()
     43  * calls if the number of bytes read is not what is requested
     44  * (where this is applicable).
     45  *
     46  * The number of bytes read is returned, or a negative number
     47  * on failure (in which case errno will be set). If the call is
     48  * interrupted, then errno will be EINTR, and the client should
     49  * arrange for re-starting the read if necessary.
     50  */
     51 ssize_t op_read_device(fd_t devfd, void * buf, size_t size);
     52 
     53 #ifdef __cplusplus
     54 }
     55 #endif
     56 
     57 #endif /* OP_DEVICEIO_H */
     58