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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/* blsctl.h
*
* Copyright 2019 Alberto Ruiz <aruiz@gnome.org>
*
* This file 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; either version 3 of the
* License, or (at your option) any later version.
*
* This file 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/>.
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
typedef char bls_bool; // Redefines char as a boolean
/**
* CmdlineParam:
*
* Represents a set of values associated to a given kernel command line parameter,
* A %NULL value in it represents an instance of a parameter in the kernel
* cmdline with no value set.
*
* For example, a kernel cmdline such as "foo=3 foo foo=2" would have a
* #CmdlineParam for "foo" with the following values: {"3", NULL, "2"}
*/
typedef struct BLSCmdlineParam;
/*
* CmdlineParamCallback:
* @param_value: A value of the value list of the #CmdlineParam
* @user_data: A pointer to a private structure set by the caller of
* #bls_cmdline_param_foreach
*
* A callback to perform an operation on each value of a #CmdlineParam,
* when @param_value is %NULL it means the parameter has an instance where
* the value was not set.
*
*/
typedef void ;
/**
* bls_cmdline_param_length:
*
* @self: A set of values for a kernel cmdline parameter
*
* Returns: the amount of values for a specific parameter
*/
size_t ;
/**
* bls_cmdline_param_foreach:
*
* @self: A set of values for a kernel cmdline parameter
* @callback: The callback to be executed on each parameter value
* @user_data: A pointer to data owned by the caller to be passed to the callback
*
* This function iterates over the internal list of values for the #CmdlineParam
* and executes @callback on each one of them.
*
*/
void ;
/**
* bls_cmdline_param_destroy:
*
* @self: A set of values for a kernel cmdline parameter
*
* Destroys the @self
*/
void ;
/* BLS Entry Operations */
/**
* BLSEntry:
* Represents a BLS .conf entry in the BLS directory
*/
typedef struct BLSEntry;
/**
* BLSEntryList:
* Opaque structure representing a list of #BLSEntry
*/
typedef struct BLSEntryList;
/**
* bls_entry_new:
*
* @entry: A string that can be an index integer, the name of the entry
* (with or without .conf extension), the full entry path or the
* kernel version string (if only one BLS entry has that kernel)
*
* Returns: A #BLSEntry object representing @entry, caller is responsible for
* calling #bls_entry_destroy to dispose it.
*/
BLSEntry* ;
/**
* bls_entry_destroy:
*
* @self: A #BLSEntry instance
*
* Disposes all resources used by @self
*/
void ;
/**
* bls_entry_get:
*
* @self: A #BLSEntry instance
* @command: The command to get the arguments for
*
* Gets the arguments for the BLS command @command
*
* Returns: 0 on failure and 1 on success
*/
char* ;
/**
* bls_entry_get:
*
* @self: A #BLSEntry instance
* @command: The command to set @args to
* @args: A string reprenseting the arguments to set to @command
*
* Sets the arguments in @args to the BLS command @command
*
* Returns: Whether the call was succesful or not
*/
bls_bool ;
/**
* bls_entry_get:
*
* @self: A #BLSEntry instance
* @command: The command to remove from @self
*
* Removes a specific @command from @self
*
* Returns: Whether the call was succesful or not
*/
bls_bool ;
/**
* bls_entry_list:
*
* Retrieves a #BLSEntryList that represents all the BLS entries in the host
*
* Returns: A #BLSEntryList instance, the caller is responisble for calling
* #bls_entry_list_destroy to dispose the returned value.
*/
BLSEntryList* ;
/**
* bls_entry_list_destroy:
*
* @self: The #BLSEntryList to be disposed
*
* Disposes memory and resources held by @self
*/
void ;
/**
* CmdlineHandler:
*
* Opaque structure that represents a fat pointer to a #CmdlineHandler vtable
* and the object that implements it trait/interface. This trait is implemented
* by #BLSEntry and #BLSEntryList. See *_to_cmdline_handler methods to
* cast those three types.
*
* Do not use this after the object that it was casted from has been destroyed
*/
typedef struct BLSCmdline;
/**
* bls_entry_to_cmdline:
*
* @env: The #BLSEntry instance to be casted to a #Cmdline
*
* Creates a #Cmdline instance
*/
BLSCmdline ;
/**
* bls_entry_list_to_cmdline:
*
* @env: The #BLSEntryList instance to be casted to a #Cmdline
*
* Creates a #Cmdline instance, do not use after
*/
BLSCmdline ;
/**
* bls_env_cmdline_get:
*
* @self: The #CmdlineHandler object
* @kparam: The kernel commandline parameter name to get
*
* Gets the list of values for parameter @kparam as a #CmdlineParam
*
* Returns: A #CmdlineParam owned by the caller, it holds all the values
* for @kparam or %NULL if the parameter is not present or an error
* ocurred. The caller must use #bls_cmdline_param_destroy to dispose
* the returned #CmdlineParam.
*/
BLSCmdlineParam* ;
/**
* bls_cmdline_set:
*
* @self: The #CmdlineHandler object
* @kparams: A %NULL terminated list of strings representing the parameters
* to be set.
*
* Sets the list of parameters in @kparams in the kernel cmdline.
*
* This is an example on how to use it:
* |[<!-- language="C" -->
* const char* params[] = {"param=value1", "param", "param2=value2", 0};
* int ret = bls_env_cmdline_set(self, params);
* ]|
*
* Returns: Whether the call was succesful or not
*/
bls_bool ;
/**
* bls_cmdline_add:
*
* @self: The #CmdlineHandler object
* @kparams: A %NULL terminated list of strings representing the parameters
* to be added.
*
* Adds the parameters listed in @kparam, this prevents replacing existing
* paramter assignments. For example in a cmdline "param=2" we can add "param=3",
* and it would keep the two assigments resulting in "param=2 paran=3"
*
* Returns: Whether the call was succesful or not
*/
bls_bool ;
/**
* bls_cmdline_remove:
*
* @self: The #CmdlineHandler object
* @kparams: A %NULL terminated list of strings representing the parameters
* to be removed.
*
* Removes specific parameter assigments from the cmdline, for example, removing
* "param=value param=value2" from "param=value param=value2 param" would result
* in the cmdline "param".
*
* Returns: Whether the call was succesful or not
*/
bls_bool ;
/**
* bls_cmdline_clear:
*
* @self: The #CmdlineHandler object
* @kparams: A %NULL terminated list of parameter names to be cleared.
*
* Removes all instances of the parameters listed in @kparams.
*
* Returns: Whether the call was succesful or not
*/
bls_bool ;