From: Karel Zak Date: Thu, 26 Apr 2018 09:04:07 +0000 (+0200) Subject: libmount: improve docs about mnt_context_mount() return codes X-Git-Tag: v2.32.1~49 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=993774b20cbf13ef2b4ecae9ca5ffd556d82340d;p=thirdparty%2Futil-linux.git libmount: improve docs about mnt_context_mount() return codes Signed-off-by: Karel Zak --- diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c index fc07ca1844..a6de361784 100644 --- a/libmount/src/context_mount.c +++ b/libmount/src/context_mount.c @@ -961,8 +961,9 @@ int mnt_context_prepare_mount(struct libmnt_context *cxt) * 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! -* + * Check mnt_context_get_status() after error! See mnt_context_mount() for more + * details about errors and warnings. + * * Returns: 0 on success; * >0 in case of mount(2) error (returns syscall errno), * <0 in case of other errors. @@ -1086,7 +1087,32 @@ int mnt_context_finalize_mount(struct libmnt_context *cxt) * 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! + * Always use mnt_context_get_status(): + * + * + * + * rc = mnt_context_mount(cxt); + * + * if (mnt_context_helper_executed(cxt)) + * return mnt_context_get_helper_status(cxt); + * if (rc == 0 && mnt_context_get_status(cxt) == 1) + * return MNT_EX_SUCCESS; + * return MNT_EX_FAIL; + * + * + * + * or mnt_context_get_excode() to generate mount(8) compatible error + * or warning message: + * + * + * + * rc = mnt_context_mount(cxt); + * rc = mnt_context_get_excode(cxt, rc, buf, sizeof(buf)); + * if (buf) + * warnx(_("%s: %s"), mnt_context_get_target(cxt), buf); + * return rc; // MNT_EX_* + * + * * * Returns: 0 on success; * >0 in case of mount(2) error (returns syscall errno), @@ -1163,6 +1189,8 @@ again: * Use also mnt_context_get_status() to check if the filesystem was * successfully mounted. * + * See mnt_context_mount() for more details about errors and warnings. + * * Returns: 0 on success, * <0 in case of error (!= mount(2) errors) * 1 at the end of the list.