{
assert(fs);
- if (!source)
- return -1;
+ if (source && !strcmp(source, "none"))
+ source = NULL;
- if (strchr(source, '=')) {
+ if (source && strchr(source, '=')) {
char *name, *val;
if (blkid_parse_tag_string(source, &name, &val) != 0)
*/
int mnt_fs_set_optstr(mnt_fs *fs, const char *optstr)
{
- char *p, *v, *f;
+ char *p = NULL, *v = NULL, *f = NULL;
assert(fs);
- if (!fs || !optstr)
- return -1;
- if (mnt_split_optstr((char *) optstr, NULL, &v, &f, 0, 0))
+ if (!fs)
return -1;
- p = strdup(optstr);
- if (!p) {
- free(v);
- free(f);
- return -1;
+ if (optstr) {
+ if (mnt_split_optstr((char *) optstr, NULL, &v, &f, 0, 0))
+ return -1;
+
+ p = strdup(optstr);
+ if (!p) {
+ free(v);
+ free(f);
+ return -1;
+ }
}
free(fs->optstr);
fs->fs_optstr = next_word(&s);
if (!fs->fs_optstr)
return 1;
-
+ if (!strcmp(fs->fs_optstr, "none")) {
+ free(fs->fs_optstr);
+ fs->fs_optstr = NULL;
+ }
return 0;
}
/**
* mnt_get_writable_mtab_path:
*
- * Returns: pointer to the static string with path to the file with userspace
- * mount options (classic /etc/mtab or /var/run/mount/mountinfo)
+ * It's not error if this function return NULL and errno is not set. In case of
+ * error the errno is set by open(2).
+ *
+ * Returns: pointer to the static string with path to mtab or NULL.
*/
const char *mnt_get_writable_mtab_path(void)
{
mtab = !lstat(_PATH_MOUNTED, &mst);
info = !stat(MNT_PATH_RUNDIR, &ist);
+ errno = 0;
+
/* A) mtab is symlink, /var/run/mount is available */
if (mtab && S_ISLNK(mst.st_mode) && info) {
int fd = open(MNT_PATH_MOUNTINFO, O_RDWR | O_CREAT, 0644);