1/**
2 * @file op_deviceio.c
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#include "op_deviceio.h"
13
14#include <sys/types.h>
15#include <fcntl.h>
16
17#include <stdio.h>
18#include <stdlib.h>
19#include <string.h>
20#include <errno.h>
21
22fd_t op_open_device(char const * name)
23{
24	return open(name, O_RDONLY);
25}
26
27
28ssize_t op_read_device(fd_t devfd, void * buf, size_t size)
29{
30	ssize_t count;
31
32	lseek(devfd, 0, SEEK_SET);
33
34	count = read(devfd, buf, size);
35
36	if (count < 0 && errno != EINTR && errno != EAGAIN) {
37		perror("oprofiled:op_read_device: ");
38		exit(EXIT_FAILURE);
39	}
40
41	return count;
42}
43