fstab-util.c revision a8fbdf5424be099ba1b2b1ec261c02b8759d6b0c
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2015 Zbigniew Jędrzejewski-Szmek
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <errno.h>
#include <mntent.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "alloc-util.h"
#include "device-nodes.h"
#include "fstab-util.h"
#include "macro.h"
#include "mount-util.h"
#include "parse-util.h"
#include "path-util.h"
#include "string-util.h"
#include "strv.h"
#include "util.h"
bool fstab_is_mount_point(const char *mount) {
struct mntent *m;
if (!f)
return false;
while ((m = getmntent(f)))
return true;
return false;
}
if (!opts)
goto answer;
/* If !value and !filtered, this function is not allowed to fail. */
if (!filtered) {
size_t l;
continue;
continue;
/* we know that the string is NUL
* terminated, so *x is valid */
n = name;
if (value) {
free(v);
v = NULL;
else {
assert(*x == '=');
x++;
if (!v)
return -ENOMEM;
}
}
}
}
} else {
char **t, **s;
if (!stor)
return -ENOMEM;
if (!strv)
return -ENOMEM;
for (s = t = strv; *s; s++) {
x = startswith(*s, name);
goto found;
}
*t = *s;
t++;
continue;
/* Keep the last occurence found */
n = name;
if (value) {
free(v);
if (*x == '\0')
v = NULL;
else {
assert(*x == '=');
x++;
v = strdup(x);
if (!v)
return -ENOMEM;
}
}
}
*t = NULL;
}
if (namefound)
*namefound = n;
if (filtered) {
char *f;
if (!f)
return -ENOMEM;
*filtered = f;
}
if (value) {
*value = v;
v = NULL;
}
return !!n;
}
char **s;
if (!optsv)
return -ENOMEM;
STRV_FOREACH(s, optsv) {
char *arg;
int r;
continue;
if (r < 0)
return r;
}
return !!*values;
}
int r;
unsigned pri;
if (r < 0)
return r;
if (r == 0 || !opt)
return 0;
if (r < 0)
return r;
if ((int) pri < 0)
return -ERANGE;
return 1;
}
size_t l;
assert(s);
/* This is rather stupid, simply removes the heading and
* trailing quotes if there is one. Doesn't care about
* escaping or anything.
*
* DON'T USE THIS FOR NEW CODE ANYMORE!*/
l = strlen(s);
if (l < 2)
return strdup(s);
return strdup(s);
}
if (!u)
return NULL;
if (!t)
return NULL;
if (encode_devnode_name(u, t, enc_len) < 0)
return NULL;
}
char *fstab_node_to_udev_node(const char *p) {
assert(p);
if (startswith(p, "LABEL="))
if (startswith(p, "UUID="))
if (startswith(p, "PARTUUID="))
if (startswith(p, "PARTLABEL="))
return strdup(p);
}