1
0
forked from pool/util-linux
util-linux/libmount-add-special-MNT_ERR-codes.patch
Petr Uzel 5b9d0884d3 - improve error messages from new mount (bnc#767208)
- backport patches from upstream git:
  - mount-new-add-loopdev-specific-error-message.patch
  - mount-new-use-MNT_ERR-for-error-messages.patch
  - libmount-add-special-MNT_ERR-codes.patch
  - mount-new-improve-error-messages.patch
  - libmount-add-MNT_ERR_LOOPDEV.patch

OBS-URL: https://build.opensuse.org/package/show/Base:System/util-linux?expand=0&rev=139
2012-06-15 13:00:49 +00:00

69 lines
2.4 KiB
Diff

From 47dea49b4cb4a4a98a6c518cc17f6d2c92be9528 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 24 Apr 2012 11:57:32 +0200
Subject: [PATCH] libmount: add special MNT_ERR_ codes
... to detect some situations where standard -errno is too generic.
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
libmount/src/context.c | 20 ++++++++++----------
libmount/src/libmount.h.in | 12 ++++++++++++
2 files changed, 22 insertions(+), 10 deletions(-)
Index: util-linux-2.21.2/libmount/src/context.c
===================================================================
--- util-linux-2.21.2.orig/libmount/src/context.c
+++ util-linux-2.21.2/libmount/src/context.c
@@ -1186,7 +1186,7 @@ int mnt_context_prepare_srcpath(struct l
if (cache)
path = mnt_resolve_tag(t, v, cache);
- rc = path ? mnt_fs_set_source(cxt->fs, path) : -EINVAL;
+ rc = path ? mnt_fs_set_source(cxt->fs, path) : -MNT_ERR_NOSOURCE;
} else if (cache && !mnt_fs_is_pseudofs(cxt->fs)) {
/*
@@ -1247,7 +1247,7 @@ int mnt_context_prepare_target(struct li
cache = mnt_context_get_cache(cxt);
if (cache) {
char *path = mnt_resolve_path(tgt, cache);
- if (strcmp(path, tgt))
+ if (path && strcmp(path, tgt) != 0)
rc = mnt_fs_set_target(cxt->fs, path);
}
@@ -1543,7 +1543,7 @@ static int apply_table(struct libmnt_con
}
if (!fs)
- return -EINVAL;
+ return -MNT_ERR_NOFSTAB; /* not found */
DBG(CXT, mnt_debug_h(cxt, "apply entry:"));
DBG(CXT, mnt_fs_print_debug(fs, stderr));
Index: util-linux-2.21.2/libmount/src/libmount.h.in
===================================================================
--- util-linux-2.21.2.orig/libmount/src/libmount.h.in
+++ util-linux-2.21.2/libmount/src/libmount.h.in
@@ -115,6 +115,18 @@ enum {
MNT_ACT_UMOUNT
};
+/*
+ * Errors -- by default libmount returns -errno for generic errors (ENOMEM,
+ * EINVAL, ...) and for mount(2) errors, but for some specific operations it
+ * returns private error codes. Note that maximum system errno value should be
+ * 4095 on UNIXes.
+ *
+ * See also mnt_context_get_syscall_errno() and mnt_context_get_helper_status().
+ */
+#define MNT_ERR_NOFSTAB 5000 /* not found required entry in fstab */
+#define MNT_ERR_NOFSTYPE 5001 /* failed to detect filesystem type */
+#define MNT_ERR_NOSOURCE 5002 /* required mount source undefined */
+
/* init.c */
extern void mnt_init_debug(int mask);