1
0
forked from pool/util-linux

- 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
This commit is contained in:
Petr Uzel 2012-06-15 13:00:49 +00:00 committed by Git OBS Bridge
parent 34c9b14737
commit 5b9d0884d3
8 changed files with 308 additions and 4 deletions

View File

@ -0,0 +1,59 @@
From 82756a747e4bcfc13a27b7618d889af080649584 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 28 May 2012 12:26:36 +0200
Subject: [PATCH] libmount: add MNT_ERR_LOOPDEV
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
lib/loopdev.c | 4 ++++
libmount/src/context_loopdev.c | 1 +
libmount/src/libmount.h.in | 1 +
3 files changed, 6 insertions(+), 0 deletions(-)
Index: util-linux-2.21.2/lib/loopdev.c
===================================================================
--- util-linux-2.21.2.orig/lib/loopdev.c
+++ util-linux-2.21.2/lib/loopdev.c
@@ -173,6 +173,8 @@ int loopcxt_init(struct loopdev_cxt *lc,
*/
void loopcxt_deinit(struct loopdev_cxt *lc)
{
+ int errsv = errno;
+
if (!lc)
return;
@@ -183,6 +185,8 @@ void loopcxt_deinit(struct loopdev_cxt *
loopcxt_set_device(lc, NULL);
loopcxt_deinit_iterator(lc);
+
+ errno = errsv;
}
/*
Index: util-linux-2.21.2/libmount/src/context_loopdev.c
===================================================================
--- util-linux-2.21.2.orig/libmount/src/context_loopdev.c
+++ util-linux-2.21.2/libmount/src/context_loopdev.c
@@ -261,6 +261,7 @@ int mnt_context_setup_loopdev(struct lib
if (loopdev || rc != -EBUSY) {
DBG(CXT, mnt_debug_h(cxt, "failed to setup device"));
+ rc = -MNT_ERR_LOOPDEV;
goto done;
}
DBG(CXT, mnt_debug_h(cxt, "loopdev stolen...trying again"));
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
@@ -126,6 +126,7 @@ enum {
#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 */
+#define MNT_ERR_LOOPDEV 5003 /* loopdev setup failed, errno set by libc */
/* init.c */
extern void mnt_init_debug(int mask);

View File

@ -0,0 +1,68 @@
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);

View File

@ -0,0 +1,51 @@
From 10389b1e4535dda7d27e5ab39d3d4f9d7868a5c9 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Mon, 28 May 2012 12:26:41 +0200
Subject: [PATCH] mount: (new) add loopdev specific error message
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
sys-utils/mount.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
Index: util-linux-2.21.2/sys-utils/mount.c
===================================================================
--- util-linux-2.21.2.orig/sys-utils/mount.c
+++ util-linux-2.21.2/sys-utils/mount.c
@@ -354,6 +354,9 @@ try_readonly:
return MOUNT_EX_SUCCESS; /* mount(2) success */
}
+ mnt_context_get_mflags(cxt, &mflags); /* mount(2) flags */
+ mnt_context_get_user_mflags(cxt, &uflags); /* userspace flags */
+
if (!mnt_context_syscall_called(cxt)) {
/*
* libmount errors (extra library checks)
@@ -382,7 +385,15 @@ try_readonly:
else
warnx(_("mount source not defined"));
return MOUNT_EX_USAGE;
-
+ case -MNT_ERR_LOOPDEV:
+ if (errno == ENOENT
+ && (uflags & MNT_MS_ENCRYPTION)
+ && src && stat(src, &st) == 0)
+ warnx(_("%s: failed to setup loop device "
+ "(probably unknown encryption type)"), src);
+ else
+ warn(_("%s: failed to setup loop device"), src);
+ return MOUNT_EX_FAIL;
default:
return handle_generic_errors(rc, _("%s: mount failed"),
tgt ? tgt : src);
@@ -406,8 +417,6 @@ try_readonly:
*/
syserr = mnt_context_get_syscall_errno(cxt);
- mnt_context_get_mflags(cxt, &mflags); /* mount(2) flags */
- mnt_context_get_user_mflags(cxt, &uflags); /* userspace flags */
switch(syserr) {
case EPERM:

View File

@ -0,0 +1,46 @@
From 58f108ef2b9c8cc0362e7781a72e5e921dc383b3 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 17 Apr 2012 11:36:36 +0200
Subject: [PATCH] mount: (new) improve error messages
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
sys-utils/mount.c | 15 +++++++--------
1 files changed, 7 insertions(+), 8 deletions(-)
Index: util-linux-2.21.2/sys-utils/mount.c
===================================================================
--- util-linux-2.21.2.orig/sys-utils/mount.c
+++ util-linux-2.21.2/sys-utils/mount.c
@@ -367,16 +367,13 @@ try_readonly:
return MOUNT_EX_USAGE;
}
- /*
- * TODO: add mnt_context_fstab_applied() to check if we found
- * target/source in the file.
- */
- if (!tgt) {
- if (mflags & MS_REMOUNT)
- warnx(_("%s not mounted"), src ? src : tgt);
- else
+ if (!tgt || (!src && !(mflags & MS_PROPAGATION))) {
+ if (!mnt_context_fstab_applied(cxt))
warnx(_("can't find %s in %s"), src ? src : tgt,
mnt_get_fstab_path());
+ else if (mflags & MS_REMOUNT)
+ warnx(_("%s not mounted"), src ? src : tgt);
+
return MOUNT_EX_USAGE;
}
@@ -485,6 +482,8 @@ try_readonly:
case EINVAL:
if (mflags & MS_REMOUNT)
warnx(_("%s not mounted or bad option"), tgt);
+ else if (mflags & MS_PROPAGATION)
+ warnx(_("%s is not mountpoint or bad option"), tgt);
else
warnx(_("wrong fs type, bad option, bad superblock on %s,\n"
" missing codepage or helper program, or other error"),

View File

@ -0,0 +1,56 @@
From ba24923e97e099668b8c96dba9596c90cb58c417 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Tue, 24 Apr 2012 11:59:18 +0200
Subject: [PATCH] mount: (new) use MNT_ERR_ for error messages
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
---
sys-utils/mount.c | 27 +++++++++++++--------------
1 files changed, 13 insertions(+), 14 deletions(-)
Index: util-linux-2.21.2/sys-utils/mount.c
===================================================================
--- util-linux-2.21.2.orig/sys-utils/mount.c
+++ util-linux-2.21.2/sys-utils/mount.c
@@ -365,29 +365,28 @@ try_readonly:
case -EBUSY:
warnx(_("%s is already mounted"), src);
return MOUNT_EX_USAGE;
- }
-
- if (!tgt || (!src && !(mflags & MS_PROPAGATION))) {
- if (!mnt_context_fstab_applied(cxt))
+ case -MNT_ERR_NOFSTAB:
warnx(_("can't find %s in %s"), src ? src : tgt,
mnt_get_fstab_path());
- else if (mflags & MS_REMOUNT)
- warnx(_("%s not mounted"), src ? src : tgt);
-
return MOUNT_EX_USAGE;
- }
-
- if (!mnt_context_get_fstype(cxt)) {
+ case -MNT_ERR_NOFSTYPE:
if (restricted)
warnx(_("I could not determine the filesystem type, "
"and none was specified"));
else
warnx(_("you must specify the filesystem type"));
return MOUNT_EX_USAGE;
- }
+ case -MNT_ERR_NOSOURCE:
+ if (src)
+ warnx(_("can't find %s"), src);
+ else
+ warnx(_("mount source not defined"));
+ return MOUNT_EX_USAGE;
+
+ default:
return handle_generic_errors(rc, _("%s: mount failed"),
tgt ? tgt : src);
-
+ }
} else if (mnt_context_get_syscall_errno(cxt) == 0) {
/*
* mount(2) syscall success, but something else failed

View File

@ -1,8 +1,8 @@
Index: util-linux-2.20/libmount/src/Makefile.am
Index: util-linux-2.21.2/libmount/src/Makefile.am
===================================================================
--- util-linux-2.20.orig/libmount/src/Makefile.am
+++ util-linux-2.20/libmount/src/Makefile.am
@@ -29,7 +29,7 @@ nodist_libmount_la_SOURCES = mountP.h
--- util-linux-2.21.2.orig/libmount/src/Makefile.am
+++ util-linux-2.21.2/libmount/src/Makefile.am
@@ -30,7 +30,7 @@ nodist_libmount_la_SOURCES = mountP.h
libmount_la_LIBADD = $(ul_libblkid_la) $(SELINUX_LIBS)

View File

@ -1,3 +1,14 @@
-------------------------------------------------------------------
Fri Jun 15 12:57:06 UTC 2012 - puzel@suse.com
- 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
-------------------------------------------------------------------
Thu Jun 14 13:04:40 UTC 2012 - puzel@suse.com

View File

@ -91,6 +91,14 @@ Patch3: fdisk-tinfo.patch
Patch4: mount-new-allow-sloppy-for-non-root.patch
Patch5: libmount-don-t-use-nosuid-noexec-nodev-for-cifs-user.patch
# Patches 6-10: bcn#767208 (taken from upstream
Patch6: mount-new-improve-error-messages.patch
Patch7: libmount-add-special-MNT_ERR-codes.patch
Patch8: mount-new-use-MNT_ERR-for-error-messages.patch
Patch9: libmount-add-MNT_ERR_LOOPDEV.patch
Patch10: mount-new-add-loopdev-specific-error-message.patch
#####
##
## adjtimex
##
@ -194,6 +202,11 @@ Files to develop applications using the libmount library.
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
#
cd adjtimex-*