} else
unmangle_string(src);
- unmangle_string(fs->fs_optstr);
+ if (!strcmp(fs->fs_optstr, "none")) {
+ free(fs->fs_optstr);
+ fs->fs_optstr = NULL;
+ } else
+ unmangle_string(fs->fs_optstr);
rc = __mnt_fs_set_fstype_ptr(fs, fstype);
if (!rc)
if (rc && writable)
upd = mnt_new_update(TRUE);
- else
- return -EACCES;
+ else {
+ fprintf(stderr, "utab useless: %m\n");
+ return -1;
+ }
}
rc = mnt_update_set_fs(upd, mountflags, target, fs);
- if (rc)
- goto done;
if (rc == 1) {
- fprintf(stderr, "update is unnecessary\n");
+ /* update is unnecessary */
rc = 0;
goto done;
}
+ if (rc) {
+ fprintf(stderr, "failed to set FS\n");
+ goto done;
+ }
/* [... here should be mount(2) call ...] */
int rc;
const char *filename = mtab && *mtab ? *mtab : mnt_get_mtab_path();
+ if (writable)
+ *writable = 0;
if (mtab && !*mtab)
*mtab = filename;
*writable = !try_write(filename);
return 1;
}
- return 0; /* it's not regular file */
+ goto done;
}
/* try to create the file */
if (writable) {
*writable = !try_write(filename);
- return *writable;
+ if (*writable)
+ return 1;
}
+done:
+ DBG(UTILS, mnt_debug("%s: irregular/non-writable", filename));
return 0;
}
+
/**
*
* mnt_has_regular_utab:
int rc;
const char *filename = utab && *utab ? *utab : mnt_get_utab_path();
+ if (writable)
+ *writable = 0;
if (utab && !*utab)
*utab = filename;
/* file exist */
if (S_ISREG(st.st_mode)) {
if (writable)
- *writable = try_write(filename);
+ *writable = !try_write(filename);
return 1;
}
- return 0; /* it's not regular file */
+ goto done; /* it's not regular file */
}
if (writable) {
char *dirname = strdup(filename);
if (!dirname)
- return 0;
+ goto done;
stripoff_last_component(dirname); /* remove filename */
rc = mkdir(dirname, 755);
free(dirname);
if (rc && errno != EEXIST)
- return 0; /* probably EACCES */
+ goto done; /* probably EACCES */
*writable = !try_write(filename);
- return *writable;
+ if (*writable)
+ return 1;
}
+done:
+ DBG(UTILS, mnt_debug("%s: irregular/non-writable file", filename));
return 0;
}