MCPcopy Create free account
hub / github.com/containers/bubblewrap / parse_mountinfo

Function parse_mountinfo

bind-mount.c:229–375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227}
228
229static MountTab
230parse_mountinfo (int proc_fd,
231 const char *root_mount)
232{
233 cleanup_free char *mountinfo = NULL;
234 cleanup_free MountInfoLine *lines = NULL;
235 cleanup_free MountInfoLine **by_id = NULL;
236 cleanup_mount_tab MountTab mount_tab = NULL;
237 MountInfo *end_tab;
238 int n_mounts;
239 char *line;
240 unsigned int i;
241 int max_id;
242 unsigned int n_lines;
243 int root;
244
245 mountinfo = load_file_at (proc_fd, "self/mountinfo");
246 if (mountinfo == NULL)
247 die_with_error ("Can't open /proc/self/mountinfo");
248
249 n_lines = count_lines (mountinfo);
250 lines = xcalloc (n_lines, sizeof (MountInfoLine));
251
252 max_id = 0;
253 line = mountinfo;
254 i = 0;
255 root = -1;
256 while (*line != 0)
257 {
258 int rc, consumed = 0;
259 unsigned int maj, min;
260 char *end;
261 char *rest;
262 char *mountpoint;
263 char *mountpoint_end;
264 char *options;
265 char *options_end;
266 char *next_line;
267
268 assert (i < n_lines);
269
270 end = strchr (line, '\n');
271 if (end != NULL)
272 {
273 *end = 0;
274 next_line = end + 1;
275 }
276 else
277 next_line = line + strlen (line);
278
279 rc = sscanf (line, "%d %d %u:%u %n", &lines[i].id, &lines[i].parent_id, &maj, &min, &consumed);
280 if (rc != 4)
281 die ("Can't parse mountinfo line");
282 rest = line + consumed;
283
284 rest = skip_token (rest, true); /* mountroot */
285 mountpoint = rest;
286 rest = skip_token (rest, false); /* mountpoint */

Callers 1

bind_mountFunction · 0.85

Calls 12

load_file_atFunction · 0.85
die_with_errorFunction · 0.85
count_linesFunction · 0.85
xcallocFunction · 0.85
dieFunction · 0.85
skip_tokenFunction · 0.85
unescape_inlineFunction · 0.85
path_equalFunction · 0.85
steal_pointerFunction · 0.85
has_path_prefixFunction · 0.85
count_mountsFunction · 0.85
collect_mountsFunction · 0.85

Tested by

no test coverage detected