d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek This file is part of systemd.
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek Copyright 2015 Zbigniew Jędrzejewski-Szmek
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek systemd is free software; you can redistribute it and/or modify it
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek under the terms of the GNU Lesser General Public License as published by
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek the Free Software Foundation; either version 2.1 of the License, or
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek (at your option) any later version.
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek systemd is distributed in the hope that it will be useful, but
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek WITHOUT ANY WARRANTY; without even the implied warranty of
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek Lesser General Public License for more details.
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek You should have received a copy of the GNU Lesser General Public License
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek along with systemd; If not, see <http://www.gnu.org/licenses/>.
0b6b6787e3f0ae8906ce0212bd629edbe931b73dKay Sievers return false;
0b6b6787e3f0ae8906ce0212bd629edbe931b73dKay Sievers while ((m = getmntent(f)))
0b6b6787e3f0ae8906ce0212bd629edbe931b73dKay Sievers return true;
0b6b6787e3f0ae8906ce0212bd629edbe931b73dKay Sievers return false;
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmekint fstab_filter_options(const char *opts, const char *names,
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek const char **namefound, char **value, char **filtered) {
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek const char *name, *n = NULL, *x;
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek _cleanup_strv_free_ char **stor = NULL;
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek _cleanup_free_ char *v = NULL, **strv = NULL;
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek /* If !value and !filtered, this function is not allowed to fail. */
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek FOREACH_WORD_SEPARATOR(word, l, opts, ",", state)
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek if (!strneq(word, name, strlen(name)))
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek /* we know that the string is NUL
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek * terminated, so *x is valid */
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek if (IN_SET(*x, '\0', '=', ',')) {
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek v = strndup(x, l - strlen(name) - 1);
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek strv = memdup(stor, sizeof(char*) * (strv_length(stor) + 1));
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek for (s = t = strv; *s; s++) {
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek /* Keep the last occurence found */
3519d230c8bafe834b2dac26ace49fcfba139823Karel Zakint fstab_extract_values(const char *opts, const char *name, char ***values) {
3519d230c8bafe834b2dac26ace49fcfba139823Karel Zak _cleanup_strv_free_ char **optsv = NULL, **res = NULL;
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmekint fstab_find_pri(const char *options, int *ret) {
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek _cleanup_free_ char *opt = NULL;
d15d0333be6a1ca7fdd99a1881d967b6be8f387aZbigniew Jędrzejewski-Szmek r = fstab_filter_options(options, "pri\0", NULL, &opt, NULL);
6550203eb471595e41e27f46e5d0a00a4c0e47bbLennart Poetteringstatic char *unquote(const char *s, const char* quotes) {
6550203eb471595e41e27f46e5d0a00a4c0e47bbLennart Poettering /* This is rather stupid, simply removes the heading and
6550203eb471595e41e27f46e5d0a00a4c0e47bbLennart Poettering * trailing quotes if there is one. Doesn't care about
6550203eb471595e41e27f46e5d0a00a4c0e47bbLennart Poettering * escaping or anything.
6550203eb471595e41e27f46e5d0a00a4c0e47bbLennart Poettering * DON'T USE THIS FOR NEW CODE ANYMORE!*/
6550203eb471595e41e27f46e5d0a00a4c0e47bbLennart Poettering if (strchr(quotes, s[0]) && s[l-1] == s[0])
6550203eb471595e41e27f46e5d0a00a4c0e47bbLennart Poetteringstatic char *tag_to_udev_node(const char *tagvalue, const char *by) {
6550203eb471595e41e27f46e5d0a00a4c0e47bbLennart Poettering _cleanup_free_ char *t = NULL, *u = NULL;
6550203eb471595e41e27f46e5d0a00a4c0e47bbLennart Poettering if (encode_devnode_name(u, t, enc_len) < 0)
6550203eb471595e41e27f46e5d0a00a4c0e47bbLennart Poettering return strjoin("/dev/disk/by-", by, "/", t, NULL);
6550203eb471595e41e27f46e5d0a00a4c0e47bbLennart Poetteringchar *fstab_node_to_udev_node(const char *p) {
6550203eb471595e41e27f46e5d0a00a4c0e47bbLennart Poettering return tag_to_udev_node(p+9, "partuuid");
6550203eb471595e41e27f46e5d0a00a4c0e47bbLennart Poettering return tag_to_udev_node(p+10, "partlabel");