return 0;
}
if (cxt->syscall_status) {
- DBG(CXT, mnt_debug_h(cxt, "don't update: syscall failed"));
+ DBG(CXT, mnt_debug_h(cxt, "don't update: syscall failed/not called"));
return 0;
}
* mnt_context_get_status:
* @cxt: mount context
*
- * Returns: 1 if /sbin/mount.type or mount(2) syscall was successfull or 0.
+ * Returns: 0 if /sbin/mount.type or mount(2) syscall was successfull or -errno.
*/
int mnt_context_get_status(struct libmnt_context *cxt)
{
return cxt && (!cxt->syscall_status || !cxt->helper_exec_status);
}
+/**
+ * mnt_context_set_syscall_status:
+ * @cxt: mount context
+ * @status: mount(2) return code
+ *
+ * This function should be used if [u]mount(2) syscall was NOT called by
+ * libmount (mnt_mount_context() or mnt_context_do_mount()) only.
+ *
+ * Returns: 0 or negative number in case of error.
+ */
+int mnt_context_set_syscall_status(struct libmnt_context *cxt, int status)
+{
+ if (!cxt)
+ return -EINVAL;
+
+ cxt->syscall_status = status;
+ return 0;
+}
+
/**
* mnt_context_strerror
* @cxt: context
if (!rc)
return set_flag(cxt, MNT_FL_HELPER, 1);
+
+ DBG(CXT, mnt_debug_h(cxt, "initialized for [u]mount.<type> helper"));
return rc;
}
if (!rc)
rc = mnt_context_prepare_srcpath(cxt);
if (!rc)
- rc = mnt_context_prepare_target(cxt);
+ rc = mnt_context_prepare_target(cxt);
if (!rc)
rc = mnt_context_guess_fstype(cxt);
if (!rc)
* mnt_context_finalize_mount:
* @cxt: context
*
- * Mtab update, etc. Unnecessary for mnt_context_mount().
+ * Mtab update, etc. Unnecessary for mnt_context_mount(), but should be called
+ * after mnt_context_do_mount(). See also mnt_context_set_syscall_status().
*
* Returns: negative number on error, 0 on success.
*/
*/
int mnt_fs_set_source(struct libmnt_fs *fs, const char *source)
{
- char *p;
+ char *p = NULL;
int rc;
- if (!fs && !source)
+ if (!fs)
return -EINVAL;
- p = strdup(source);
- if (!p)
- return -ENOMEM;
+ if (source) {
+ p = strdup(source);
+ if (!p)
+ return -ENOMEM;
+ }
rc = __mnt_fs_set_source_ptr(fs, p);
if (rc)
*/
int mnt_fs_set_target(struct libmnt_fs *fs, const char *target)
{
- char *p;
+ char *p = NULL;
assert(fs);
- if (!fs || !target)
+ if (!fs)
return -EINVAL;
- p = strdup(target);
- if (!p)
- return -ENOMEM;
+ if (target) {
+ p = strdup(target);
+ if (!p)
+ return -ENOMEM;
+ }
free(fs->target);
fs->target = p;
int mnt_fs_set_fstype(struct libmnt_fs *fs, const char *fstype)
{
char *p = NULL;
- int rc;
if (!fs)
return -EINVAL;
if (!p)
return -ENOMEM;
}
- rc = __mnt_fs_set_fstype_ptr(fs, p);
- if (rc)
- free(p);
- return rc;
+ return __mnt_fs_set_fstype_ptr(fs, p);
}
/*
extern int mnt_context_prepare_mount(struct libmnt_context *cxt);
extern int mnt_context_do_mount(struct libmnt_context *cxt);
extern int mnt_context_finalize_mount(struct libmnt_context *cxt);
+extern int mnt_context_set_syscall_status(struct libmnt_context *cxt, int status);
extern int mnt_context_do_umount(struct libmnt_context *cxt);
mnt_context_set_options_pattern;
mnt_context_set_optsmode;
mnt_context_set_source;
+ mnt_context_set_syscall_status;
mnt_context_set_target;
mnt_context_set_user_mflags;
mnt_context_strerror;
strcmp(type, "tmpfs") == 0 ||
strcmp(type, "sysfs") == 0 ||
strcmp(type, "devpts") == 0||
- strcmp(type, "cgroups") == 0 ||
+ strcmp(type, "cgroup") == 0 ||
strcmp(type, "devfs") == 0 ||
strcmp(type, "dlmfs") == 0 ||
strcmp(type, "cpuset") == 0 ||