chiark / gitweb /
Add new function to filter fstab options
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 9 Jan 2015 21:58:29 +0000 (16:58 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 12 Jan 2015 04:41:41 +0000 (23:41 -0500)
commitd15d0333be6a1ca7fdd99a1881d967b6be8f387a
tree488ce214314613658c5eda3b0a94deec31353de7
parent1e39ff926f815d241721ed9486945cf599ef8c2f
Add new function to filter fstab options

This fixes parsing of options in shared/generator.c. Existing code
had some issues:

- it would treate whitespace and semicolons as seperators. fstab(5)
  is pretty clear that only commas matter. And the syntax does
  not allow for spaces to be inserted in the field in fstab.
  Whitespace might be escaped, but then it should not seperate
  options. Treat whitespace and semicolons as any other character.
- it assumed that x-systemd.device-timeout would always be followed
  by "=". But this is not guaranteed, hasmntopt will return this
  option even if there's no value. Uninitialized memory could be read.
- some error paths would log, and inconsistently, some would just
  return an error code.

Filtering is split out to a separate function and tests are added.

Similar code paths in other places are adjusted to use the new function.
Makefile.am
src/core/mount.c
src/core/swap.c
src/fstab-generator/fstab-generator.c
src/shared/fstab-util.c [new file with mode: 0644]
src/shared/fstab-util.h [new file with mode: 0644]
src/shared/generator.c
src/shared/util.c
src/shared/util.h
src/test/test-fstab-util.c [new file with mode: 0644]