1 /* Copyright (C) 2011 Ericsson AB, Nils Carlson <nils.carlson@ericsson.com>
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 #include <sys/types.h>
20 #include <ust/ustctl.h>
21 #include "scanning_functions.h"
25 static int set_subbuf_size(int argc
, char *argv
[])
32 pid
= parse_pid(argv
[1]);
34 if (scan_ch_and_num(argv
[3], &channel
, &size
)) {
35 fprintf(stderr
, "Failed to scan channel and size from"
41 if (ustctl_set_subbuf_size(argv
[2], channel
, size
, pid
)) {
42 ERR("error while trying to set the size of subbuffers "
53 static int set_subbuf_num(int argc
, char *argv
[])
60 pid
= parse_pid(argv
[1]);
62 if (scan_ch_and_num(argv
[3], &channel
, &num
)) {
63 fprintf(stderr
, "Failed to scan channel and number from"
69 if (ustctl_set_subbuf_num(argv
[2], channel
, num
, pid
)) {
70 ERR("error while trying to set the number of subbuffers for PID %u\n",
80 static int get_subbuf_size(int argc
, char *argv
[])
85 pid
= parse_pid(argv
[1]);
87 if ((size
= ustctl_get_subbuf_size(argv
[2], argv
[3], pid
)) < 0) {
88 ERR("error while trying to get the subbuffer size from PID %u\n",
93 printf("The subbufer size is %d bytes\n", size
);
98 static int get_subbuf_num(int argc
, char *argv
[])
103 pid
= parse_pid(argv
[1]);
105 if ((num
= ustctl_get_subbuf_num(argv
[2], argv
[3], pid
)) < 0) {
106 ERR("error while trying to get the subbuffer size from PID %u\n",
111 printf("There are %u subbufers in each buffer\n", num
);
116 struct cli_cmd __cli_cmds channel_cmds
[] = {
118 .name
= "set-subbuf-size",
119 .description
= "Set the subbuffer size for a channel",
120 .help_text
= "set-subbuf-size <pid> <trace> <channel>/<size> \n"
121 "Set the subbuffer size for a channel\n",
122 .function
= set_subbuf_size
,
124 .desired_args_op
= CLI_EQ
,
127 .name
= "set-subbuf-num",
128 .description
= "Set the number of subbuffers for a channel",
129 .help_text
= "set-subbuf-num <pid> <trace> <channel>/<num> \n"
130 "Set the number of subbuffers for a channel\n",
131 .function
= set_subbuf_num
,
133 .desired_args_op
= CLI_EQ
,
136 .name
= "get-subbuf-size",
137 .description
= "Get the subbuffer size for a channel",
138 .help_text
= "get-subbuf-size <pid> <trace> <channel>\n"
139 "Get the subbuffer size for a channel\n",
140 .function
= get_subbuf_size
,
142 .desired_args_op
= CLI_EQ
,
145 .name
= "get-subbuf-num",
146 .description
= "Get the number of subbuffers for a channel",
147 .help_text
= "get-subbuf-num <pid> <trace> <channel>\n"
148 "Get the number of subbuffers for a channel\n",
149 .function
= get_subbuf_num
,
151 .desired_args_op
= CLI_EQ
,