00001 /** 00002 * @file op_deviceio.h 00003 * Reading from a special device 00004 * 00005 * @remark Copyright 2002 OProfile authors 00006 * @remark Read the file COPYING 00007 * 00008 * @author John Levon 00009 * @author Philippe Elie 00010 */ 00011 00012 #ifndef OP_DEVICEIO_H 00013 #define OP_DEVICEIO_H 00014 00015 #ifdef __cplusplus 00016 extern "C" { 00017 #endif 00018 00019 #include "op_types.h" 00020 00021 #include <unistd.h> 00022 00023 /** 00024 * op_open_device - open a special char device for reading 00025 * @param name file name of device file 00026 * 00027 * Open the special file name. Returns the file descriptor 00028 * for the file or -1 on error. 00029 */ 00030 fd_t op_open_device(char const * name); 00031 00032 /** 00033 * op_read_device - read from a special char device 00034 * @param devfd file descriptor of device 00035 * @param buf buffer 00036 * @param size size of buffer 00037 * 00038 * Read size bytes from a device into buffer buf. 00039 * A seek to the start of the device file is done first 00040 * then a read is requested in one go of size bytes. 00041 * 00042 * It is the caller's responsibility to do further op_read_device() 00043 * calls if the number of bytes read is not what is requested 00044 * (where this is applicable). 00045 * 00046 * The number of bytes read is returned, or a negative number 00047 * on failure (in which case errno will be set). If the call is 00048 * interrupted, then errno will be EINTR, and the client should 00049 * arrange for re-starting the read if necessary. 00050 */ 00051 ssize_t op_read_device(fd_t devfd, void * buf, size_t size); 00052 00053 #ifdef __cplusplus 00054 } 00055 #endif 00056 00057 #endif /* OP_DEVICEIO_H */
1.6.1