Add helper function for mnt_table_parse_{stream,mtab}
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 5 Apr 2019 12:43:06 +0000 (14:43 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 23 Apr 2019 21:29:29 +0000 (23:29 +0200)
commite2857b3d87306d93f0fba526f3e79f4f6806fb02
tree80e0b279f908dec754abb1ee8fe497d087839026
parent7d991d4818dcf55916c1076003c3508c91df9934
Add helper function for mnt_table_parse_{stream,mtab}

This wraps a few common steps. It is defined as inline function instead of in a
.c file to avoid having a .c file. With a .c file, we would have three choices:
- either link it into libshared, but then then libshared would have to be
  linked to libmount.
- or compile the .c file into each target separately. This has the disdvantage
  that configuration of every target has to be updated and stuff will be compiled
  multiple times anyway, which is not too different from keeping this in the
  header file.
- or create a new convenience library just for this. This also has the disadvantage
  that the every target would have to be updated, and a separate library for a
  10 line function seems overkill.

By keeping everything in a header file, we compile this a few times, but
otherwise it's the least painful option. The compiler can optimize most of the
function away, because it knows if 'source' is set or not.
src/core/mount.c
src/mount/mount-tool.c
src/shared/libmount-util.h
src/shared/mount-util.c
src/shutdown/umount.c
src/test/test-libmount.c