forked from pool/util-linux
This commit is contained in:
parent
7083e5a509
commit
35a9ff314b
127
util-linux-2.14-loop_autoclear.patch
Normal file
127
util-linux-2.14-loop_autoclear.patch
Normal file
@ -0,0 +1,127 @@
|
||||
On Wed, Jun 25, 2008 at 12:59:32PM +0200, Matthias Koenig wrote:
|
||||
> The new loop auto-destruct feature detaches automatically loop devices
|
||||
> when no longer used. This means they are detached with the umount()
|
||||
> call. But when we call umount with -d, del_loop is called and fails
|
||||
> because the ioctl() returns ENXIO.
|
||||
|
||||
ah, good catch. Thanks!
|
||||
|
||||
> We probably should ignore this error here.
|
||||
|
||||
I think we could be smarter. We can try to detect autoclear
|
||||
loop devices. See the patch below.
|
||||
|
||||
[I'm going to create a stable/v2.14 branch.]
|
||||
|
||||
Karel
|
||||
|
||||
|
||||
>From e84feaecfdf44a33ef9eccc5a56c8a6999466140 Mon Sep 17 00:00:00 2001
|
||||
From: Karel Zak <kzak@redhat.com>
|
||||
Date: Wed, 2 Jul 2008 14:26:51 +0200
|
||||
Subject: [PATCH] umount: improve "-d" option for autoclear loops
|
||||
|
||||
The new loop auto-destruct feature detaches automatically loop devices
|
||||
when no longer used. This means they are detached with the umount()
|
||||
call. But when we call umount with -d, del_loop() is called and fails
|
||||
because the ioctl() returns ENXIO. We have to check for autoclear
|
||||
loop devices rather than blindly call del_loop().
|
||||
|
||||
Reported-by: Matthias Koenig <mkoenig@suse.de>
|
||||
Signed-off-by: Karel Zak <kzak@redhat.com>
|
||||
---
|
||||
mount/lomount.c | 23 +++++++++++++++++++++++
|
||||
mount/lomount.h | 1 +
|
||||
mount/umount.c | 12 ++++++++++--
|
||||
3 files changed, 34 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/mount/lomount.c b/mount/lomount.c
|
||||
index c3ac68a..7937052 100644
|
||||
--- a/mount/lomount.c
|
||||
+++ b/mount/lomount.c
|
||||
@@ -102,6 +102,29 @@ is_loop_used(int fd)
|
||||
return ioctl (fd, LOOP_GET_STATUS, &li) == 0;
|
||||
}
|
||||
|
||||
+int
|
||||
+is_loop_autoclear(const char *device)
|
||||
+{
|
||||
+ struct loop_info lo;
|
||||
+ struct loop_info64 lo64;
|
||||
+ int fd, rc = 0;
|
||||
+
|
||||
+ if ((fd = open(device, O_RDONLY)) < 0)
|
||||
+ return 0;
|
||||
+
|
||||
+ if (ioctl(fd, LOOP_GET_STATUS64, &lo64) == 0) {
|
||||
+ if (lo64.lo_flags & LO_FLAGS_AUTOCLEAR)
|
||||
+ rc = 1;
|
||||
+
|
||||
+ } else if (ioctl(fd, LOOP_GET_STATUS, &lo) == 0) {
|
||||
+ if (lo.lo_flags & LO_FLAGS_AUTOCLEAR)
|
||||
+ rc = 1;
|
||||
+ }
|
||||
+
|
||||
+ close(fd);
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
static char *
|
||||
looplist_mk_devname(struct looplist *ll, int num)
|
||||
{
|
||||
diff --git a/mount/lomount.h b/mount/lomount.h
|
||||
index f332a70..59108d4 100644
|
||||
--- a/mount/lomount.h
|
||||
+++ b/mount/lomount.h
|
||||
@@ -2,6 +2,7 @@ extern int set_loop(const char *, const char *, unsigned long long, unsigned lon
|
||||
const char *, int, int *);
|
||||
extern int del_loop(const char *);
|
||||
extern int is_loop_device(const char *);
|
||||
+extern int is_loop_autoclear(const char *device);
|
||||
extern char * find_unused_loop_device(void);
|
||||
|
||||
extern int loopfile_used_with(char *devname, const char *filename, unsigned long long offset);
|
||||
diff --git a/mount/umount.c b/mount/umount.c
|
||||
index 65c8622..b2bbdae 100644
|
||||
--- a/mount/umount.c
|
||||
+++ b/mount/umount.c
|
||||
@@ -190,6 +190,7 @@ umount_one (const char *spec, const char *node, const char *type,
|
||||
int res;
|
||||
int status;
|
||||
const char *loopdev;
|
||||
+ int myloop = 0;
|
||||
|
||||
/* Special case for root. As of 0.99pl10 we can (almost) unmount root;
|
||||
the kernel will remount it readonly so that we can carry on running
|
||||
@@ -201,7 +202,7 @@ umount_one (const char *spec, const char *node, const char *type,
|
||||
|| streq (node, "rootfs"));
|
||||
if (isroot)
|
||||
nomtab++;
|
||||
-
|
||||
+
|
||||
/*
|
||||
* Call umount.TYPE for types that require a separate umount program.
|
||||
* All such special things must occur isolated in the types string.
|
||||
@@ -209,6 +210,13 @@ umount_one (const char *spec, const char *node, const char *type,
|
||||
if (check_special_umountprog(spec, node, type, &status))
|
||||
return status;
|
||||
|
||||
+ /*
|
||||
+ * Ignore the option "-d" for non-loop devices and loop devices with
|
||||
+ * LO_FLAGS_AUTOCLEAR flag.
|
||||
+ */
|
||||
+ if (delloop && is_loop_device(spec) && !is_loop_autoclear(spec))
|
||||
+ myloop = 1;
|
||||
+
|
||||
umnt_err = umnt_err2 = 0;
|
||||
if (lazy) {
|
||||
res = umount2 (node, MNT_DETACH);
|
||||
@@ -310,7 +318,7 @@ umount_one (const char *spec, const char *node, const char *type,
|
||||
}
|
||||
|
||||
/* Also free loop devices when -d flag is given */
|
||||
- if (delloop && is_loop_device(spec))
|
||||
+ if (myloop)
|
||||
loopdev = spec;
|
||||
}
|
||||
gotloop:
|
@ -1,37 +0,0 @@
|
||||
Index: util-linux-ng-2.14/mount/lomount.c
|
||||
===================================================================
|
||||
--- util-linux-ng-2.14.orig/mount/lomount.c 2008-06-25 11:35:27.000000000 +0200
|
||||
+++ util-linux-ng-2.14/mount/lomount.c 2008-06-25 12:47:28.000000000 +0200
|
||||
@@ -878,6 +878,7 @@ set_loop(const char *device, const char
|
||||
int
|
||||
del_loop (const char *device) {
|
||||
int fd;
|
||||
+ int res = 0;
|
||||
|
||||
if ((fd = open (device, O_RDONLY)) < 0) {
|
||||
int errsv = errno;
|
||||
@@ -886,10 +887,22 @@ del_loop (const char *device) {
|
||||
return 1;
|
||||
}
|
||||
if (ioctl (fd, LOOP_CLR_FD, 0) < 0) {
|
||||
- perror ("ioctl: LOOP_CLR_FD");
|
||||
+ if (errno == ENXIO) {
|
||||
+ /* ignore ENXIO, device has probably been
|
||||
+ * auto-destructed */
|
||||
+ if (verbose > 1)
|
||||
+ printf(_("del_loop(%s): already deleted\n"),
|
||||
+ device);
|
||||
+ res = 0;
|
||||
+ } else {
|
||||
+ perror ("ioctl: LOOP_CLR_FD");
|
||||
+ res = 1;
|
||||
+ }
|
||||
+
|
||||
close(fd);
|
||||
- return 1;
|
||||
+ return res;
|
||||
}
|
||||
+
|
||||
close (fd);
|
||||
if (verbose > 1)
|
||||
printf(_("del_loop(%s): success\n"), device);
|
@ -1,3 +1,15 @@
|
||||
-------------------------------------------------------------------
|
||||
Wed Jul 2 15:47:08 CEST 2008 - mkoenig@suse.de
|
||||
|
||||
- replace util-linux-2.14-mount_ignore_ENXIO_in_del_loop.patch
|
||||
with upstream version
|
||||
util-linux-2.14-loop_autoclear.patch
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Jun 27 17:05:46 CEST 2008 - schwab@suse.de
|
||||
|
||||
- Fix lib64 check.
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Jun 25 14:26:49 CEST 2008 - mkoenig@suse.de
|
||||
|
||||
|
@ -22,7 +22,7 @@ License: BSD 3-Clause; GPL v2 or later
|
||||
Group: System/Base
|
||||
AutoReqProv: on
|
||||
Version: 2.14
|
||||
Release: 1
|
||||
Release: 3
|
||||
Requires: %name-lang = %{version}
|
||||
Summary: A collection of basic system utilities
|
||||
Source: ftp://ftp.kernel.org/pub/linux/utils/util-linux/%name-ng-%version.tar.bz2
|
||||
@ -62,7 +62,7 @@ Patch3: util-linux-2.12r-fdisk_remove_bogus_warnings.patch
|
||||
Patch4: util-linux-2.13-hwclock_rtc_wait_busy_tempfix.patch
|
||||
#
|
||||
Patch5: util-linux-2.13.1-fdisk_cfdisk_yesno.patch
|
||||
Patch6: util-linux-2.14-mount_ignore_ENXIO_in_del_loop.patch
|
||||
Patch6: util-linux-2.14-loop_autoclear.patch
|
||||
Patch7: util-linux-2.14-mount_retry_on_nomedium.patch
|
||||
# crypto patch
|
||||
Patch20: util-linux-mount_losetup_crypto.patch
|
||||
@ -569,6 +569,12 @@ fi
|
||||
#%endif
|
||||
|
||||
%changelog
|
||||
* Wed Jul 02 2008 mkoenig@suse.de
|
||||
- replace util-linux-2.14-mount_ignore_ENXIO_in_del_loop.patch
|
||||
with upstream version
|
||||
util-linux-2.14-loop_autoclear.patch
|
||||
* Fri Jun 27 2008 schwab@suse.de
|
||||
- Fix lib64 check.
|
||||
* Wed Jun 25 2008 mkoenig@suse.de
|
||||
- update to version 2.14
|
||||
most important changes:
|
||||
|
@ -1,6 +1,6 @@
|
||||
--- acinclude.m4
|
||||
+++ acinclude.m4
|
||||
@@ -3,7 +3,7 @@
|
||||
@@ -3,21 +3,26 @@ dnl [, ACTION-IF-NOT-FOUND [, OTHER-L
|
||||
dnl Like AC_CHECK_LIB but looking for static libraries.
|
||||
dnl LIBRARY must be of the form libxxx.a.
|
||||
dnl The current language must be C (AC_LANG_C).
|
||||
@ -9,14 +9,15 @@
|
||||
[AC_MSG_CHECKING([for $2 in $1])
|
||||
dnl Use a cache variable name containing both the library and function name,
|
||||
dnl because the test really is for library $1 defining function $2, not
|
||||
@@ -11,10 +11,15 @@
|
||||
dnl just for library $1. Separate tests with the same $1 and different $2s
|
||||
dnl may have different results.
|
||||
ac_lib_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'`
|
||||
AC_CACHE_VAL(ac_cv_lib_static_$ac_lib_var,
|
||||
-AC_CACHE_VAL(ac_cv_lib_static_$ac_lib_var,
|
||||
+AC_CACHE_VAL(ac_cv_lib_static_$ac_lib_var, [
|
||||
+if test "$libdir" != "${exec_prefix}/lib"; then
|
||||
+ if test ! -z `grep 64 $libdir`&& test ; then
|
||||
+ case $libdir in *64)
|
||||
+ libsuffix=64
|
||||
+ fi
|
||||
+ esac
|
||||
+fi
|
||||
if test -r /etc/ld.so.conf ; then
|
||||
- ld_so_paths="/lib /usr/lib `cat /etc/ld.so.conf`"
|
||||
@ -26,4 +27,8 @@
|
||||
+ ld_so_paths="/lib${libsuffix} /usr/lib${libsuffix}"
|
||||
fi
|
||||
for path in $ld_so_paths; do
|
||||
[ac_save_LIBS="$LIBS"
|
||||
- [ac_save_LIBS="$LIBS"
|
||||
+ ac_save_LIBS="$LIBS"
|
||||
LIBS="$path/$1 $5 $LIBS"
|
||||
AC_TRY_LINK(dnl
|
||||
ifelse([$2], [main], , dnl Avoid conflicting decl of main.
|
||||
|
Loading…
Reference in New Issue
Block a user