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
[])
31 sock
= parse_and_connect_pid(argv
[1]);
33 if (scan_ch_and_num(argv
[3], &channel
, &size
)) {
34 fprintf(stderr
, "Failed to scan channel and size from"
40 if (ustctl_set_subbuf_size(sock
, argv
[2], channel
, size
)) {
41 ERR("error while trying to set the size of subbuffers "
52 static int set_subbuf_num(int argc
, char *argv
[])
58 sock
= parse_and_connect_pid(argv
[1]);
60 if (scan_ch_and_num(argv
[3], &channel
, &num
)) {
61 fprintf(stderr
, "Failed to scan channel and number from"
67 if (ustctl_set_subbuf_num(sock
, argv
[2], channel
, num
)) {
68 ERR("error while trying to set the number of subbuffers for PID %s\n",
78 static int get_subbuf_size(int argc
, char *argv
[])
83 sock
= parse_and_connect_pid(argv
[1]);
85 if ((size
= ustctl_get_subbuf_size(sock
, argv
[2], argv
[3])) < 0) {
86 ERR("error while trying to get the subbuffer size from PID %s\n",
91 printf("The subbufer size is %d bytes\n", size
);
96 static int get_subbuf_num(int argc
, char *argv
[])
101 sock
= parse_and_connect_pid(argv
[1]);
103 if ((num
= ustctl_get_subbuf_num(sock
, argv
[2], argv
[3])) < 0) {
104 ERR("error while trying to get the subbuffer size from PID %s\n",
109 printf("There are %u subbufers in each buffer\n", num
);
114 struct cli_cmd __cli_cmds channel_cmds
[] = {
116 .name
= "set-subbuf-size",
117 .description
= "Set the subbuffer size for a channel",
118 .help_text
= "set-subbuf-size <pid> <trace> <channel>/<size> \n"
119 "Set the subbuffer size for a channel\n",
120 .function
= set_subbuf_size
,
122 .desired_args_op
= CLI_EQ
,
125 .name
= "set-subbuf-num",
126 .description
= "Set the number of subbuffers for a channel",
127 .help_text
= "set-subbuf-num <pid> <trace> <channel>/<num> \n"
128 "Set the number of subbuffers for a channel\n",
129 .function
= set_subbuf_num
,
131 .desired_args_op
= CLI_EQ
,
134 .name
= "get-subbuf-size",
135 .description
= "Get the subbuffer size for a channel",
136 .help_text
= "get-subbuf-size <pid> <trace> <channel>\n"
137 "Get the subbuffer size for a channel\n",
138 .function
= get_subbuf_size
,
140 .desired_args_op
= CLI_EQ
,
143 .name
= "get-subbuf-num",
144 .description
= "Get the number of subbuffers for a channel",
145 .help_text
= "get-subbuf-num <pid> <trace> <channel>\n"
146 "Get the number of subbuffers for a channel\n",
147 .function
= get_subbuf_num
,
149 .desired_args_op
= CLI_EQ
,