lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Sun, 31 Mar 2013 11:51:29 +0900
From:	Namjae Jeon <linkinjeon@...il.com>
To:	jaegeuk.kim@...sung.com
Cc:	linux-f2fs-devel@...ts.sourceforge.net,
	linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
	Namjae Jeon <linkinjeon@...il.com>,
	Namjae Jeon <namjae.jeon@...sung.com>,
	Amit Sahrawat <a.sahrawat@...sung.com>
Subject: [PATCH] f2fs-tools: mkfs: fix to avoid format of device when already mounted

From: Namjae Jeon <namjae.jeon@...sung.com>

In case of embedded devices, where /etc/ is mounted as 'read-only'.
We donot have the /etc/mtab file. So, checking if the device is already
mounted from this file is not sufficient.
Try to read /proc/mounts in case of failure from /etc/mtab.

Issue logs:
/dev/sdb4 /mnt vfat rw,relatime,fmask=0022,dmask=0022,codepage=cp437,
iocharset=ascii,errors=remount-ro 0 0

Here device - sb4 is already mounted.
But, when trying to format using mkfs.f2fs

F2FS-tools: Ver: 1.1.0 (2013-01-14)
Info: sector size = 512
Info: total sectors = 13108784 (in 512bytes)
WARN: Align start sector number in a unit of pages
        i.e., start sector: 2542124, ofs:4 (sectors per page: 8)
Info: zone aligned segment0 blkaddr: 186
Info: This device doesn't support TRIM
Info: format successful

After Change:

F2FS-tools: Ver: 1.1.0 (2013-01-14)
Error: /dev/sdb4 is already mounted

Signed-off-by: Namjae Jeon <namjae.jeon@...sung.com>
Signed-off-by: Amit Sahrawat <a.sahrawat@...sung.com>
---
 lib/libf2fs.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 37ed147..d228492 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -152,8 +152,13 @@ int f2fs_dev_is_mounted(struct f2fs_configuration *c)
 	struct mntent *mnt = NULL;
 
 	file = setmntent(MOUNTED, "r");
-	if (file == NULL)
-		return 0;
+	if (file == NULL) {
+		/* if failed due to /etc/mtab file not present
+		   try with /proc/mounts */
+		file = setmntent("/proc/mounts", "r");
+		if (file == NULL)
+			return 0;
+	}
 
 	while (1) {
 		mnt = getmntent(file);
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists