*/
int mnt_context_reset_status(struct libmnt_context *cxt)
{
- assert(cxt);
if (!cxt)
return -EINVAL;
DBG(CXT, ul_debugobj(cxt, "checking for writable tab files"));
+#ifdef USE_LIBMOUNT_FORCE_MOUNTINFO
+ cxt->mtab_writable = 0;
+#else
mnt_has_regular_mtab(&cxt->mtab_path, &cxt->mtab_writable);
+#endif
if (!cxt->mtab_writable)
/* use /run/mount/utab if /etc/mtab is useless */
*/
int mnt_context_set_optsmode(struct libmnt_context *cxt, int mode)
{
- assert(cxt);
if (!cxt)
return -EINVAL;
cxt->optsmode = mode;
int mnt_context_get_optsmode(struct libmnt_context *cxt)
{
- assert(cxt);
return cxt->optsmode;
}
*/
struct libmnt_fs *mnt_context_get_fs(struct libmnt_context *cxt)
{
- assert(cxt);
if (!cxt)
return NULL;
if (!cxt->fs)
*/
void *mnt_context_get_fs_userdata(struct libmnt_context *cxt)
{
- assert(cxt);
return cxt->fs ? mnt_fs_get_userdata(cxt->fs) : NULL;
}
*/
void *mnt_context_get_fstab_userdata(struct libmnt_context *cxt)
{
- assert(cxt);
return cxt->fstab ? mnt_table_get_userdata(cxt->fstab) : NULL;
}
*/
void *mnt_context_get_mtab_userdata(struct libmnt_context *cxt)
{
- assert(cxt);
return cxt->mtab ? mnt_table_get_userdata(cxt->mtab) : NULL;
}
*/
int mnt_context_set_source(struct libmnt_context *cxt, const char *source)
{
- assert(cxt);
return mnt_fs_set_source(mnt_context_get_fs(cxt), source);
}
*/
const char *mnt_context_get_source(struct libmnt_context *cxt)
{
- assert(cxt);
return mnt_fs_get_source(mnt_context_get_fs(cxt));
}
*/
int mnt_context_set_target(struct libmnt_context *cxt, const char *target)
{
- assert(cxt);
return mnt_fs_set_target(mnt_context_get_fs(cxt), target);
}
*/
const char *mnt_context_get_target(struct libmnt_context *cxt)
{
- assert(cxt);
return mnt_fs_get_target(mnt_context_get_fs(cxt));
}
*/
int mnt_context_set_fstype(struct libmnt_context *cxt, const char *fstype)
{
- assert(cxt);
return mnt_fs_set_fstype(mnt_context_get_fs(cxt), fstype);
}
*/
const char *mnt_context_get_fstype(struct libmnt_context *cxt)
{
- assert(cxt);
return mnt_fs_get_fstype(mnt_context_get_fs(cxt));
}
*/
int mnt_context_set_options(struct libmnt_context *cxt, const char *optstr)
{
- assert(cxt);
return mnt_fs_set_options(mnt_context_get_fs(cxt), optstr);
}
*/
int mnt_context_append_options(struct libmnt_context *cxt, const char *optstr)
{
- assert(cxt);
return mnt_fs_append_options(mnt_context_get_fs(cxt), optstr);
}
*/
const char *mnt_context_get_options(struct libmnt_context *cxt)
{
- assert(cxt);
return mnt_fs_get_options(mnt_context_get_fs(cxt));
}
{
char *p = NULL;
- assert(cxt);
if (!cxt)
return -EINVAL;
if (pattern) {
{
char *p = NULL;
- assert(cxt);
if (!cxt)
return -EINVAL;
if (pattern) {
*/
int mnt_context_set_fstab(struct libmnt_context *cxt, struct libmnt_table *tb)
{
- assert(cxt);
if (!cxt)
return -EINVAL;
*/
int mnt_context_get_fstab(struct libmnt_context *cxt, struct libmnt_table **tb)
{
- assert(cxt);
if (!cxt)
return -EINVAL;
if (!cxt->fstab) {
*/
int mnt_context_get_mtab(struct libmnt_context *cxt, struct libmnt_table **tb)
{
- assert(cxt);
if (!cxt)
return -EINVAL;
if (!cxt->mtab) {
int (*fltr)(struct libmnt_fs *, void *),
void *data)
{
- assert(cxt);
if (!cxt)
return -EINVAL;
{
int rc;
- assert(cxt);
- assert(tb);
if (!cxt || !tb)
return -EINVAL;
int mnt_context_set_tables_errcb(struct libmnt_context *cxt,
int (*cb)(struct libmnt_table *tb, const char *filename, int line))
{
- assert(cxt);
if (!cxt)
return -EINVAL;
*/
struct libmnt_cache *mnt_context_get_cache(struct libmnt_context *cxt)
{
- assert(cxt);
if (!cxt || mnt_context_is_nocanonicalize(cxt))
return NULL;
char *(*get)(struct libmnt_context *),
void (*release)(struct libmnt_context *, char *))
{
- assert(cxt);
if (!cxt)
return -EINVAL;
cxt->pwd_get_cb = get;
*/
struct libmnt_lock *mnt_context_get_lock(struct libmnt_context *cxt)
{
- assert(cxt);
/*
* DON'T call this function within libmount, it will always allocate
* the lock. The mnt_update_* functions are able to allocate the lock
*/
int mnt_context_set_mflags(struct libmnt_context *cxt, unsigned long flags)
{
- assert(cxt);
if (!cxt)
return -EINVAL;
int rc = 0;
struct list_head *p;
- assert(cxt);
- assert(flags);
if (!cxt || !flags)
return -EINVAL;
{
int rc = 0;
- assert(cxt);
- assert(flags);
if (!cxt || !flags)
return -EINVAL;
*/
int mnt_context_set_mountdata(struct libmnt_context *cxt, void *data)
{
- assert(cxt);
if (!cxt)
return -EINVAL;
cxt->mountdata = data;
assert(cxt->fs);
assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
+ DBG(CXT, ul_debugobj(cxt, "preparing fstype"));
+
if (!cxt || !cxt->fs)
return -EINVAL;
if (type)
goto done;
- if (cxt->flags & MS_REMOUNT)
+ if (cxt->mountflags & MS_REMOUNT)
goto none;
if (cxt->fstype_pattern)
goto done;
target = mnt_fs_get_target(cxt->fs);
- if (cxt->action == MNT_ACT_UMOUNT && target && !strcmp(target, "/"))
- /* Don't try to touch mtab if umounting root FS */
+ if (cxt->action == MNT_ACT_UMOUNT && target && !strcmp(target, "/")) {
+ DBG(CXT, ul_debugobj(cxt, "root umount: setting NOMTAB"));
mnt_context_disable_mtab(cxt, TRUE);
-
+ }
if (mnt_context_is_nomtab(cxt)) {
DBG(CXT, ul_debugobj(cxt, "skip update: NOMTAB flag"));
return 0;
const char *src = NULL, *tgt = NULL;
unsigned long mflags = 0;
- assert(cxt);
- assert(cxt->fs);
-
- if (!cxt)
+ if (!cxt || !cxt->fs)
return -EINVAL;
if (mnt_context_tab_applied(cxt)) /* already applied */
}
if (!src && tgt
- && !(cxt->optsmode & MNT_OMODE_FORCE)
&& !(cxt->optsmode & MNT_OMODE_FSTAB)
&& !(cxt->optsmode & MNT_OMODE_MTAB)) {
DBG(CXT, ul_debugobj(cxt, "only target; fstab/mtab not required "
ignore_result( mnt_context_get_fs(cxt) );
/* try fstab */
- if (cxt->optsmode & (MNT_OMODE_FSTAB | MNT_OMODE_FORCE)) {
+ if (cxt->optsmode & MNT_OMODE_FSTAB) {
DBG(CXT, ul_debugobj(cxt, "trying to apply fstab (src=%s, target=%s)", src, tgt));
rc = mnt_context_get_fstab(cxt, &tab);
if (!rc)
}
/* try mtab */
- if (rc < 0 && (cxt->optsmode & (MNT_OMODE_MTAB | MNT_OMODE_FORCE))) {
+ if (rc < 0 && (cxt->optsmode & MNT_OMODE_MTAB)
+ && (isremount || cxt->action == MNT_ACT_UMOUNT)) {
DBG(CXT, ul_debugobj(cxt, "trying to apply mtab (src=%s, target=%s)", src, tgt));
if (tgt)
rc = mnt_context_get_mtab_for_target(cxt, &tab, tgt);
*/
int mnt_context_tab_applied(struct libmnt_context *cxt)
{
- assert(cxt);
return cxt->flags & MNT_FL_TAB_APPLIED;
}
*/
int mnt_context_propagation_only(struct libmnt_context *cxt)
{
- assert(cxt);
- assert(cxt->fs);
-
if (cxt->action != MNT_ACT_MOUNT)
return 0;
*/
int mnt_context_get_status(struct libmnt_context *cxt)
{
- assert(cxt);
return !cxt->syscall_status || !cxt->helper_exec_status;
}
*/
int mnt_context_helper_executed(struct libmnt_context *cxt)
{
- assert(cxt);
return cxt->helper_exec_status != 1;
}
*/
int mnt_context_get_helper_status(struct libmnt_context *cxt)
{
- assert(cxt);
return cxt->helper_status;
}
*/
int mnt_context_syscall_called(struct libmnt_context *cxt)
{
- assert(cxt);
return cxt->syscall_status != 1;
}
*/
int mnt_context_get_syscall_errno(struct libmnt_context *cxt)
{
- assert(cxt);
if (cxt->syscall_status < 0)
return -cxt->syscall_status;
return 0;
*/
int mnt_context_set_syscall_status(struct libmnt_context *cxt, int status)
{
- assert(cxt);
if (!cxt)
return -EINVAL;
{
int rc;
- assert(cxt);
+ if (!cxt)
+ return -EINVAL;
rc = mnt_context_disable_helpers(cxt, TRUE);
if (!rc)
struct libmnt_table *mtab;
int rc;
- assert(cxt);
if (!cxt || !fs || !mounted)
return -EINVAL;
{
pid_t *pids;
- assert(cxt);
if (!cxt)
return -EINVAL;
{
int i;
- assert(cxt);
if (!cxt)
return -EINVAL;