/** * mnt_context_finalize_umount: * @cxt: context * * Mtab update, etc. Unnecessary for mnt_context_umount(), but should be called * after mnt_context_do_umount(). See also mnt_context_set_syscall_status(). * * Returns: negative number on error, 0 on success. */ int mnt_context_finalize_umount(struct libmnt_context *cxt) { int rc; assert(cxt); assert(cxt->fs); assert((cxt->flags & MNT_FL_PREPARED)); assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED)); rc = mnt_context_prepare_update(cxt); if (!rc) rc = mnt_context_update_tabs(cxt);; return rc; }
/** * mnt_context_umount: * @cxt: umount context * * High-level, umounts filesystem by umount(2) or fork()+exec(/sbin/umount.type). * * This is similar to: * * mnt_context_prepare_umount(cxt); * mnt_context_do_umount(cxt); * mnt_context_finalize_umount(cxt); * * See also mnt_context_disable_helpers(). * * WARNING: non-zero return code does not mean that umount(2) syscall or * umount.type helper wasn't successfully called. * * Check mnt_context_get_status() after error! * * Returns: 0 on success; * >0 in case of umount(2) error (returns syscall errno), * <0 in case of other errors. */ int mnt_context_umount(struct libmnt_context *cxt) { int rc; assert(cxt); assert(cxt->fs); assert(cxt->helper_exec_status == 1); assert(cxt->syscall_status == 1); DBG(CXT, mnt_debug_h(cxt, "umount: %s", mnt_context_get_target(cxt))); rc = mnt_context_prepare_umount(cxt); if (!rc) rc = mnt_context_prepare_update(cxt); if (!rc) rc = mnt_context_do_umount(cxt); if (!rc) rc = mnt_context_update_tabs(cxt); return rc; }
/** * mnt_context_mount: * @cxt: mount context * * High-level, mounts filesystem by mount(2) or fork()+exec(/sbin/mount.type). * * This is similar to: * * mnt_context_prepare_mount(cxt); * mnt_context_do_mount(cxt); * mnt_context_finalize_mount(cxt); * * See also mnt_context_disable_helpers(). * * Note that this function could be called only once. If you want to mount with * different setting than you have to call mnt_reset_context(). It's NOT enough * to call mnt_context_reset_status() if you want call this function more than * once, whole context has to be reseted. * * WARNING: non-zero return code does not mean that mount(2) syscall or * mount.type helper wasn't successfully called. * * Check mnt_context_get_status() after error! * * Returns: 0 on success; * >0 in case of mount(2) error (returns syscall errno), * <0 in case of other errors. */ int mnt_context_mount(struct libmnt_context *cxt) { int rc; assert(cxt); assert(cxt->fs); assert(cxt->helper_exec_status == 1); assert(cxt->syscall_status == 1); rc = mnt_context_prepare_mount(cxt); if (!rc) rc = mnt_context_prepare_update(cxt); if (!rc) rc = mnt_context_do_mount(cxt); /* TODO: if mtab update is expected then check if the * target is really mounted read-write to avoid 'ro' in * mtab and 'rw' in /proc/mounts. */ if (!rc) rc = mnt_context_update_tabs(cxt); return rc; }