fstab-util.c revision c5e04d51277994cca29234b33a6b8fc90a183cf3
6c03089c32c251d823173bda4d809a9e643219f0Lennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6c03089c32c251d823173bda4d809a9e643219f0Lennart Poettering This file is part of systemd.
6c03089c32c251d823173bda4d809a9e643219f0Lennart Poettering Copyright 2015 Zbigniew Jędrzejewski-Szmek
6c03089c32c251d823173bda4d809a9e643219f0Lennart Poettering systemd is free software; you can redistribute it and/or modify it
6c03089c32c251d823173bda4d809a9e643219f0Lennart Poettering under the terms of the GNU Lesser General Public License as published by
6c03089c32c251d823173bda4d809a9e643219f0Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
6c03089c32c251d823173bda4d809a9e643219f0Lennart Poettering (at your option) any later version.
6c03089c32c251d823173bda4d809a9e643219f0Lennart Poettering systemd is distributed in the hope that it will be useful, but
6c03089c32c251d823173bda4d809a9e643219f0Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
6c03089c32c251d823173bda4d809a9e643219f0Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6c03089c32c251d823173bda4d809a9e643219f0Lennart Poettering Lesser General Public License for more details.
6c03089c32c251d823173bda4d809a9e643219f0Lennart Poettering You should have received a copy of the GNU Lesser General Public License
6c03089c32c251d823173bda4d809a9e643219f0Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
6482f6269c87d2249e52e889a63adbdd50f2d691Ronny Chevalierint fstab_filter_options(const char *opts, const char *names,
0b452006de98294d1690f045f6ea2f7f6630ec3bRonny Chevalier const char **namefound, char **value, char **filtered) {
96cde13ace6406582688028f3df5668a172ba628Zbigniew Jędrzejewski-Szmek const char *name, *n = NULL, *x;
6c03089c32c251d823173bda4d809a9e643219f0Lennart Poettering _cleanup_free_ char *v = NULL, **strv = NULL;
6c03089c32c251d823173bda4d809a9e643219f0Lennart Poettering /* If !value and !filtered, this function is not allowed to fail. */
cfeaa44a09756a93a881f786678973d9b1e382dbLennart Poettering FOREACH_WORD_SEPARATOR(word, l, opts, ",", state)
6c03089c32c251d823173bda4d809a9e643219f0Lennart Poettering /* we know that the string is NUL
6c03089c32c251d823173bda4d809a9e643219f0Lennart Poettering * terminated, so *x is valid */
d4fffc4b8beb86e77fd710c1f43913a490ed083aZbigniew Jędrzejewski-Szmek if (IN_SET(*x, '\0', '=', ',')) {
d7bd3de0654669e65b9642c248c5fa6d1d9a9f61Lennart Poettering char **t, **s;
6c03089c32c251d823173bda4d809a9e643219f0Lennart Poettering strv = memdup(stor, sizeof(char*) * (strv_length(stor) + 1));
d4fffc4b8beb86e77fd710c1f43913a490ed083aZbigniew Jędrzejewski-Szmek for (s = t = strv; *s; s++) {
cfeaa44a09756a93a881f786678973d9b1e382dbLennart Poettering /* Keep the last occurence found */
cfeaa44a09756a93a881f786678973d9b1e382dbLennart Poettering if (*x == '\0')
9444b1f20e311f073864d81e913bd4f32fe95cfdLennart Poetteringint fstab_find_pri(const char *options, int *ret) {
aff38e74bd776471f15ba54b305a24b0251eb865Lennart Poettering r = fstab_filter_options(options, "pri\0", NULL, &opt, NULL);
aff38e74bd776471f15ba54b305a24b0251eb865Lennart Poettering if ((int) pri < 0)