From: Karel Zak Date: Mon, 14 Mar 2011 13:33:53 +0000 (+0100) Subject: libmount: cleanup *_do_[u]mount() return codes and docs X-Git-Tag: v2.19.1-rc1~40 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=73f60bc3d577f5b53db26c8de64a8800472e06b4;p=thirdparty%2Futil-linux.git libmount: cleanup *_do_[u]mount() return codes and docs Signed-off-by: Karel Zak --- diff --git a/shlibs/mount/src/context.c b/shlibs/mount/src/context.c index 487859a3f9..61a2b9edd9 100644 --- a/shlibs/mount/src/context.c +++ b/shlibs/mount/src/context.c @@ -1481,7 +1481,7 @@ int mnt_context_apply_fstab(struct libmnt_context *cxt) * mnt_context_get_status: * @cxt: mount context * - * Returns: 0 if /sbin/mount.type or mount(2) syscall was successfull or -errno. + * Returns: 0 if /sbin/mount.type or mount(2) syscall was successfull. */ int mnt_context_get_status(struct libmnt_context *cxt) { @@ -1493,6 +1493,9 @@ int mnt_context_get_status(struct libmnt_context *cxt) * @cxt: mount context * @status: mount(2) return code * + * The @status should be 0 on succcess, or negative number on error (-1 or + * -errno). + * * This function should be used if [u]mount(2) syscall was NOT called by * libmount (by mnt_context_mount() or mnt_context_do_mount()) only. * diff --git a/shlibs/mount/src/context_mount.c b/shlibs/mount/src/context_mount.c index 0c67546444..d8da5a5f54 100644 --- a/shlibs/mount/src/context_mount.c +++ b/shlibs/mount/src/context_mount.c @@ -401,7 +401,7 @@ static int do_mount(struct libmnt_context *cxt, const char *try_type) cxt->syscall_status = -errno; DBG(CXT, mnt_debug_h(cxt, "mount(2) failed [errno=%d %m]", -cxt->syscall_status)); - return cxt->syscall_status; + return -cxt->syscall_status; } DBG(CXT, mnt_debug_h(cxt, "mount(2) success")); cxt->syscall_status = 0; @@ -530,7 +530,14 @@ int mnt_context_prepare_mount(struct libmnt_context *cxt) * * Call mount(2) or mount. helper. Unnecessary for mnt_context_mount(). * - * Returns: negative number on error, zero on success + * WARNING: non-zero return code does not mean that mount(2) syscall or + * umount.type helper wasn't sucessfully 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_do_mount(struct libmnt_context *cxt) { @@ -594,9 +601,14 @@ int mnt_context_finalize_mount(struct libmnt_context *cxt) * * See also mnt_context_disable_helpers(). * - * Returns: 0 on success, and negative number in case of error. WARNING: error - * does not mean that mount(2) syscall or mount.type helper wasn't - * sucessfully called. Check mnt_context_get_status() after error! + * WARNING: non-zero return code does not mean that mount(2) syscall or + * mount.type helper wasn't sucessfully 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) { diff --git a/shlibs/mount/src/context_umount.c b/shlibs/mount/src/context_umount.c index 1187a87cd7..69819e5c2d 100644 --- a/shlibs/mount/src/context_umount.c +++ b/shlibs/mount/src/context_umount.c @@ -486,7 +486,7 @@ static int do_umount(struct libmnt_context *cxt) DBG(CXT, mnt_debug_h(cxt, "read-only re-mount(2) failed " "[errno=%d]", -cxt->syscall_status)); - return cxt->syscall_status; + return -cxt->syscall_status; } cxt->syscall_status = 0; DBG(CXT, mnt_debug_h(cxt, "read-only re-mount(2) success")); @@ -562,7 +562,14 @@ int mnt_context_prepare_umount(struct libmnt_context *cxt) * * See also mnt_context_disable_helpers(). * - * Returns: 0 on success, and negative number in case of error. + * WARNING: non-zero return code does not mean that umount(2) syscall or + * umount.type helper wasn't sucessfully 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_do_umount(struct libmnt_context *cxt) { @@ -650,9 +657,14 @@ int mnt_context_finalize_umount(struct libmnt_context *cxt) * * See also mnt_context_disable_helpers(). * - * Returns: 0 on success, and negative number in case of error. WARNING: error - * does not mean that umount(2) syscall or mount.type helper wasn't - * sucessfully called. Check mnt_context_get_status() after error! + * WARNING: non-zero return code does not mean that umount(2) syscall or + * umount.type helper wasn't sucessfully 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) {