From: Sami Kerola <kerolasa@iki.fi>
To: util-linux@vger.kernel.org
Cc: kerolasa@iki.fi
Subject: [PATCH 13/14] lib/ismounted: detect loopback mounts
Date: Sun, 16 Dec 2012 10:44:01 +0000 [thread overview]
Message-ID: <1355654642-22106-14-git-send-email-kerolasa@iki.fi> (raw)
In-Reply-To: <1355654642-22106-1-git-send-email-kerolasa@iki.fi>
While double checking the minix changes worked I noticed fsck.minix not
to abort check if the file system was mounted using loopback device. The
commands before this commit which one needs to reproduce the issue are:
dd if=/dev/zero count=100 of=minixfs
./mkfs.minix ./minixfs
mkdir x
./mount ./minixfs x
./fsck.minix minixfs
One would expect to see following print out.
minixfs is mounted.
check aborted.
Neither did that appear, nor the fsck check got to be aborted. It seems
the generic fsck, and mkswap had same problem as they rely on
is_mounted().
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
lib/Makemodule.am | 1 +
lib/ismounted.c | 8 ++++++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/lib/Makemodule.am b/lib/Makemodule.am
index 806f9e5..244a9e8 100644
--- a/lib/Makemodule.am
+++ b/lib/Makemodule.am
@@ -76,6 +76,7 @@ test_blkdev_LDADD = libcommon.la
test_ismounted_SOURCES = lib/ismounted.c
test_ismounted_CFLAGS = -DTEST_PROGRAM
+test_ismounted_LDADD = $(LDADD) libcommon.la libmount.la
test_wholedisk_SOURCES = lib/wholedisk.c
test_wholedisk_CFLAGS = -DTEST_PROGRAM
diff --git a/lib/ismounted.c b/lib/ismounted.c
index 273a7d9..c3545bb 100644
--- a/lib/ismounted.c
+++ b/lib/ismounted.c
@@ -25,6 +25,7 @@
#include "pathnames.h"
#include "ismounted.h"
+#include "loopdev.h"
#include "c.h"
#ifdef HAVE_MNTENT_H
@@ -42,7 +43,7 @@ static int check_mntent_file(const char *mtab_file, const char *file,
dev_t file_dev=0, file_rdev=0;
ino_t file_ino=0;
FILE *f;
- int fd;
+ int fd, src_is_file = 1;
*mount_flags = 0;
if ((f = setmntent (mtab_file, "r")) == NULL)
@@ -55,6 +56,7 @@ static int check_mntent_file(const char *mtab_file, const char *file,
} else {
file_dev = st_buf.st_dev;
file_ino = st_buf.st_ino;
+ src_is_file = 0;
}
}
while ((mnt = getmntent (f)) != NULL) {
@@ -63,12 +65,14 @@ static int check_mntent_file(const char *mtab_file, const char *file,
if (strcmp(file, mnt->mnt_fsname) == 0)
break;
if (stat(mnt->mnt_fsname, &st_buf) == 0) {
- if (S_ISBLK(st_buf.st_mode)) {
+ if (S_ISBLK(st_buf.st_mode) && src_is_file) {
#ifndef __GNU__
if (file_rdev && (file_rdev == st_buf.st_rdev))
break;
#endif /* __GNU__ */
} else {
+ if (is_loopdev(mnt->mnt_fsname))
+ stat(loopdev_get_backing_file(mnt->mnt_fsname), &st_buf);
if (file_dev && ((file_dev == st_buf.st_dev) &&
(file_ino == st_buf.st_ino)))
break;
--
1.8.0.2
next prev parent reply other threads:[~2012-12-16 10:44 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-16 10:43 [00/14]: pull: ipcs resubmission, bug fixes, minix todo, etc Sami Kerola
2012-12-16 10:43 ` [PATCH 01/14] docs: swapon.8 option name fix Sami Kerola
2012-12-16 10:43 ` [PATCH 02/14] ipcs: assist debugging Sami Kerola
2012-12-16 10:43 ` [PATCH 03/14] ipcs: add --human readable size conversion option Sami Kerola
2012-12-16 10:43 ` [PATCH 04/14] ipcs: add --bytes size output option Sami Kerola
2012-12-16 10:43 ` [PATCH 05/14] isosize: fix usage() -h option print out Sami Kerola
2012-12-16 10:43 ` [PATCH 06/14] isosize: inform if file does not look like iso file system Sami Kerola
2012-12-16 10:43 ` [PATCH 07/14] more: remove unnecessary variable Sami Kerola
2012-12-16 10:43 ` [PATCH 08/14] tunelp: deprecation: remove command from default build Sami Kerola
2012-12-16 10:43 ` [PATCH 09/14] minix: change types in header file Sami Kerola
2012-12-16 10:43 ` [PATCH 10/14] minix: use off_t, size_t, etc appropriate types Sami Kerola
2012-12-16 10:43 ` [PATCH 11/14] minix: replace magic constants with macro names Sami Kerola
2012-12-16 10:44 ` [PATCH 12/14] docs: add missing exit value to fsck.minix(8) Sami Kerola
2012-12-16 10:44 ` Sami Kerola [this message]
2012-12-19 13:38 ` [PATCH 13/14] lib/ismounted: detect loopback mounts Karel Zak
2012-12-16 10:44 ` [PATCH 14/14] docs: fsck(8), mkfs(8): update manual references Sami Kerola
2012-12-19 13:54 ` Karel Zak
2012-12-19 14:29 ` [00/14]: pull: ipcs resubmission, bug fixes, minix todo, etc Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1355654642-22106-14-git-send-email-kerolasa@iki.fi \
--to=kerolasa@iki.fi \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox