forked from pool/util-linux
update to 2.19.1
OBS-URL: https://build.opensuse.org/package/show/Base:System/util-linux?expand=0&rev=76
This commit is contained in:
parent
71b5113d8b
commit
bcb2ee8c13
@ -1,166 +0,0 @@
|
||||
From f4612577c942a3683b97632ad0b49671897c2070 Mon Sep 17 00:00:00 2001
|
||||
From: Petr Uzel <petr.uzel@suse.cz>
|
||||
Date: Thu, 17 Feb 2011 12:52:43 +0100
|
||||
Subject: [PATCH] umount: allow unmounting loopdev specified by associated file
|
||||
|
||||
Make it possible to unmount a filesystem on a loop device if it is
|
||||
specified by associated backing file. It does not attempt to unmount
|
||||
anything if there are more than one loop device associated with the
|
||||
given file.
|
||||
|
||||
Umount looks for associated loopdevice(s) only if umount is called
|
||||
with the regular file as an argument.
|
||||
|
||||
Before:
|
||||
mount -o loop -t ext2 img mnt
|
||||
umount -v img
|
||||
> Could not find /home/puzel/upstream/util-linux/img in mtab
|
||||
> umount: img: not mounted
|
||||
|
||||
After:
|
||||
mount -o loop -t ext2 img mnt
|
||||
umount -v img
|
||||
> img is associated with /dev/loop0, trying to unmount it
|
||||
> /dev/loop0 has been unmounted
|
||||
|
||||
[kzak@redhat.com: - fix memory leak in lomount.c]
|
||||
|
||||
Addresses: https://bugzilla.novell.com/show_bug.cgi?id=666161
|
||||
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
|
||||
Signed-off-by: Karel Zak <kzak@redhat.com>
|
||||
---
|
||||
mount/lomount.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
mount/lomount.h | 1 +
|
||||
mount/umount.c | 22 ++++++++++++++++++++++
|
||||
3 files changed, 76 insertions(+), 0 deletions(-)
|
||||
|
||||
Index: util-linux-2.19/mount/lomount.c
|
||||
===================================================================
|
||||
--- util-linux-2.19.orig/mount/lomount.c
|
||||
+++ util-linux-2.19/mount/lomount.c
|
||||
@@ -409,6 +409,51 @@ done:
|
||||
return -1;
|
||||
}
|
||||
|
||||
+/* Find loop device associated with given @filename. Used for unmounting loop
|
||||
+ * device specified by associated backing file.
|
||||
+ *
|
||||
+ * returns: 1 no such device/error
|
||||
+ * 2 more than one loop device associated with @filename
|
||||
+ * 0 exactly one loop device associated with @filename
|
||||
+ * (@loopdev points to string containing full device name)
|
||||
+ */
|
||||
+int
|
||||
+find_loopdev_by_backing_file(const char *filename, char **loopdev)
|
||||
+{
|
||||
+ struct looplist ll;
|
||||
+ struct stat filestat;
|
||||
+ int fd;
|
||||
+ int devs_n = 0; /* number of loop devices found */
|
||||
+ char* devname = NULL;
|
||||
+
|
||||
+ if (stat(filename, &filestat) == -1) {
|
||||
+ perror(filename);
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ if (looplist_open(&ll, LLFLG_USEDONLY) == -1) {
|
||||
+ error(_("%s: /dev directory does not exist."), progname);
|
||||
+ return 1;
|
||||
+ }
|
||||
+
|
||||
+ while((devs_n < 2) && (fd = looplist_next(&ll)) != -1) {
|
||||
+ if (is_associated(fd, &filestat, 0, 0) == 1) {
|
||||
+ if (!devname)
|
||||
+ devname = xstrdup(ll.name);
|
||||
+ devs_n++;
|
||||
+ }
|
||||
+ close(fd);
|
||||
+ }
|
||||
+ looplist_close(&ll);
|
||||
+
|
||||
+ if (devs_n == 1) {
|
||||
+ *loopdev = devname;
|
||||
+ return 0; /* exactly one loopdev */
|
||||
+ }
|
||||
+ free(devname);
|
||||
+ return devs_n ? 2 : 1; /* more loopdevs or error */
|
||||
+}
|
||||
+
|
||||
#ifdef MAIN
|
||||
|
||||
static int
|
||||
@@ -581,6 +626,7 @@ show_associated_loop_devices(char *filen
|
||||
return 0;
|
||||
}
|
||||
|
||||
+
|
||||
#endif /* MAIN */
|
||||
|
||||
/* check if the loopfile is already associated with the same given
|
||||
@@ -1054,6 +1100,13 @@ find_unused_loop_device (void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
+int
|
||||
+find_loopdev_by_backing_file(const char *filename, char **loopdev)
|
||||
+{
|
||||
+ mutter();
|
||||
+ return 1;
|
||||
+}
|
||||
+
|
||||
#endif /* !LOOP_SET_FD */
|
||||
|
||||
#ifdef MAIN
|
||||
Index: util-linux-2.19/mount/lomount.h
|
||||
===================================================================
|
||||
--- util-linux-2.19.orig/mount/lomount.h
|
||||
+++ util-linux-2.19/mount/lomount.h
|
||||
@@ -11,6 +11,7 @@ extern char * find_unused_loop_device(vo
|
||||
extern int loopfile_used_with(char *devname, const char *filename, unsigned long long offset);
|
||||
extern char *loopfile_used (const char *filename, unsigned long long offset);
|
||||
extern char *loopdev_get_loopfile(const char *device);
|
||||
+extern int find_loopdev_by_backing_file(const char *filename, char **loopdev);
|
||||
|
||||
|
||||
#define SETLOOP_RDONLY (1<<0) /* Open loop read-only */
|
||||
Index: util-linux-2.19/mount/umount.c
|
||||
===================================================================
|
||||
--- util-linux-2.19.orig/mount/umount.c
|
||||
+++ util-linux-2.19/mount/umount.c
|
||||
@@ -502,6 +502,7 @@ umount_file (char *arg) {
|
||||
const char *file, *options;
|
||||
int fstab_has_user, fstab_has_users, fstab_has_owner, fstab_has_group;
|
||||
int ok;
|
||||
+ struct stat statbuf;
|
||||
|
||||
if (!*arg) { /* "" would be expanded to `pwd` */
|
||||
die(2, _("Cannot unmount \"\"\n"));
|
||||
@@ -509,6 +510,27 @@ umount_file (char *arg) {
|
||||
}
|
||||
|
||||
file = canonicalize(arg); /* mtab paths are canonicalized */
|
||||
+
|
||||
+ /* if file is a regular file, check if it is associated
|
||||
+ * with some loop device
|
||||
+ */
|
||||
+ if (!stat(file, &statbuf) && S_ISREG(statbuf.st_mode)) {
|
||||
+ char *loopdev = NULL;
|
||||
+ switch (find_loopdev_by_backing_file(file, &loopdev)) {
|
||||
+ case 0:
|
||||
+ if (verbose)
|
||||
+ printf(_("%s is associated with %s, trying to unmount it\n"),
|
||||
+ arg, loopdev);
|
||||
+ file = loopdev;
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ if (verbose)
|
||||
+ printf(_("%s is associated with more than one loop device: not unmounting\n"),
|
||||
+ arg);
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
if (verbose > 1)
|
||||
printf(_("Trying to unmount %s\n"), file);
|
||||
|
3
util-linux-2.19.1.tar.bz2
Normal file
3
util-linux-2.19.1.tar.bz2
Normal file
@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d3eac4afcc687b3ae1ffedcab2dc12df84c7ba7045cce31386d2b7040a011c7d
|
||||
size 4396543
|
@ -1,3 +0,0 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:d8189ba6dfb508d5c36f50103a7b84943d893e51e6d7a314155a82f68efb33b6
|
||||
size 4376791
|
@ -1,3 +1,12 @@
|
||||
-------------------------------------------------------------------
|
||||
Tue May 3 09:39:37 UTC 2011 - puzel@novell.com
|
||||
|
||||
- update to util-linux-2.19.1
|
||||
- numerous bugfixes, including (bnc#690486 and bnc#690488)
|
||||
- drop umount-by-imgname.patch (merged upstream)
|
||||
- cleanup: do not register ipc.info.gz (not provided by
|
||||
this package)
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Apr 14 16:27:27 UTC 2011 - puzel@novell.com
|
||||
|
||||
|
@ -30,7 +30,7 @@ BuildRequires: pam-devel
|
||||
BuildRequires: pkg-config
|
||||
BuildRequires: readline-devel
|
||||
BuildRequires: zlib-devel
|
||||
Version: 2.19
|
||||
Version: 2.19.1
|
||||
Release: 5
|
||||
Url: http://kernel.org/~kzak/util-linux/
|
||||
Supplements: filesystem(minix)
|
||||
@ -80,7 +80,6 @@ Source51: blkid.conf
|
||||
Patch1: util-linux-2.12r-fdisk_remove_bogus_warnings.patch
|
||||
# crypto patch
|
||||
Patch3: util-linux-2.17.1-mount_losetup_crypto.patch
|
||||
Patch5: umount-by-imgname.patch
|
||||
##
|
||||
## adjtimex
|
||||
##
|
||||
@ -181,7 +180,6 @@ Files to develop applications using the libmount library.
|
||||
%setup -q -a 9 -b 11 -b 12 -b 13 -n %{name}-%{version}
|
||||
%patch1 -p1
|
||||
%patch3 -p1
|
||||
%patch5 -p1
|
||||
|
||||
#
|
||||
cd adjtimex-*
|
||||
@ -192,7 +190,6 @@ cp %{S:22} %{S:23} .
|
||||
# nologin
|
||||
cp %{S:2} %{S:3} %{S:26} %{S:30} .
|
||||
cd ../klogconsole
|
||||
#%#patch55 -p1 -b .quiet
|
||||
%patch55 -p1
|
||||
%patch56 -p1
|
||||
cd ../time-*
|
||||
@ -376,7 +373,6 @@ rm -rf %{buildroot}
|
||||
|
||||
%post
|
||||
%{fillup_and_insserv raw}
|
||||
%install_info --info-dir=%{_infodir} %{_infodir}/ipc.info.gz
|
||||
%install_info --entry="* time: (time). summarizing used system resources" --info-dir=%{_infodir} %{_infodir}/time.info.gz
|
||||
%install_info --info-dir=%{_infodir} %{_infodir}/which.info.gz
|
||||
%if 0%{?suse_version} <= 1130
|
||||
|
Loading…
Reference in New Issue
Block a user