-
Notifications
You must be signed in to change notification settings - Fork 1
/
trace-cmd-local.h
60 lines (50 loc) · 1.47 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
60
/*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
#ifndef _TRACE_CMD_LOCAL_H
#define _TRACE_CMD_LOCAL_H
/* Local for trace-input.c and trace-output.c */
#include "trace-cmd.h"
static int __do_write(int fd, void *data, int size)
{
int tot = 0;
int w;
do {
w = write(fd, data, size - tot);
tot += w;
if (!w)
break;
if (w < 0)
return w;
} while (tot != size);
return tot;
}
static int
__do_write_check(int fd, void *data, int size)
{
int ret;
ret = __do_write(fd, data, size);
if (ret < 0)
return ret;
if (ret != size)
return -1;
return 0;
}
#endif /* _TRACE_CMD_LOCAL_H */