-
Notifications
You must be signed in to change notification settings - Fork 4
/
trace-cmd-local.h
59 lines (49 loc) · 1.42 KB
/
trace-cmd-local.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* Copyright (C) 2010 Red Hat Inc, Steven Rostedt <[email protected]>
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License (not later!)
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this program; if not, see <http://www.gnu.org/licenses>
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
#ifndef _TRACE_CMD_LOCAL_H
#define _TRACE_CMD_LOCAL_H
/* Local for trace-input.c and trace-output.c */
#include "trace-cmd.h"
static ssize_t __do_write(int fd, void *data, size_t size)
{
ssize_t tot = 0;
ssize_t w;
do {
w = write(fd, data, size - tot);
tot += w;
if (!w)
break;
if (w < 0)
return w;
} while (tot != size);
return tot;
}
static ssize_t
__do_write_check(int fd, void *data, size_t size)
{
ssize_t ret;
ret = __do_write(fd, data, size);
if (ret < 0)
return ret;
if (ret != size)
return -1;
return 0;
}
#endif /* _TRACE_CMD_LOCAL_H */