From mboxrd@z Thu Jan 1 00:00:00 1970 From: Francis Moreau Subject: Re: sys_umount() returns EBUSY when doing: sh -c "mount /dev/sdc1 /mnt; umount /mnt" Date: Mon, 15 Mar 2010 21:23:02 +0100 Message-ID: <38b2ab8a1003151323q6155e917ia74da84475db66f9@mail.gmail.com> References: <38b2ab8a1003130056u4b025839i556a797ccad894de@mail.gmail.com> <38b2ab8a1003131230q469158b3qd7dcb9f880ea68e1@mail.gmail.com> <20100315163454.GV30031@ZenIV.linux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Andreas Dilger , linux-fsdevel@vger.kernel.org To: Al Viro Return-path: Received: from mail-fx0-f219.google.com ([209.85.220.219]:63962 "EHLO mail-fx0-f219.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936679Ab0COUXJ convert rfc822-to-8bit (ORCPT ); Mon, 15 Mar 2010 16:23:09 -0400 Received: by fxm19 with SMTP id 19so3619551fxm.21 for ; Mon, 15 Mar 2010 13:23:06 -0700 (PDT) In-Reply-To: <20100315163454.GV30031@ZenIV.linux.org.uk> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Mon, Mar 15, 2010 at 5:34 PM, Al Viro wrot= e: > 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: >> > >> > =A0mount /dev/sdc1 /mnt >> > =A0fs=3D$(stat -f -c %T $mount_point) >> > =A0umount /mnt >> >> Mounting an in-use filesystem is a bad idea. > > Huh? =A0mount() will happily create another vfsmount refering to the = same > superblock in that case. =A0It *is* OK to mount the same block device= twice; > any fs that uses get_sb_bdev() will DTRT. > > It should be safe. =A0The lack of error checking after mount, OTOH, i= s not. > Well I omitted the error checking since it was not revelant in my case: umount(8) fails but not mount(8). --=20 =46rancis -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel= " in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html