From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Subject: Re: sys_umount() returns EBUSY when doing: sh -c "mount /dev/sdc1 /mnt; umount /mnt" Date: Mon, 15 Mar 2010 16:34:54 +0000 Message-ID: <20100315163454.GV30031@ZenIV.linux.org.uk> References: <38b2ab8a1003130056u4b025839i556a797ccad894de@mail.gmail.com> <38b2ab8a1003131230q469158b3qd7dcb9f880ea68e1@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Francis Moreau , linux-fsdevel@vger.kernel.org To: Andreas Dilger Return-path: Received: from zeniv.linux.org.uk ([195.92.253.2]:57020 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964955Ab0COQe4 (ORCPT ); Mon, 15 Mar 2010 12:34:56 -0400 Content-Disposition: inline In-Reply-To: Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Mon, Mar 15, 2010 at 10:04:46AM -0600, Andreas Dilger wrote: > On 2010-03-13, at 13:30, Francis Moreau wrote: > >I've some shell scripts which try to find out the filesystem hosted by > >a block device. > > > >They basically do this: > > > > mount /dev/sdc1 /mnt > > fs=$(stat -f -c %T $mount_point) > > umount /mnt > > Mounting an in-use filesystem is a bad idea. Huh? mount() will happily create another vfsmount refering to the same superblock in that case. It *is* OK to mount the same block device twice; any fs that uses get_sb_bdev() will DTRT. It should be safe. The lack of error checking after mount, OTOH, is not.