From owner-freebsd-fs@FreeBSD.ORG Wed Apr 12 13:32:26 2006 Return-Path: X-Original-To: freebsd-fs@FreeBSD.ORG Delivered-To: freebsd-fs@FreeBSD.ORG Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 436F716A403 for ; Wed, 12 Apr 2006 13:32:26 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (lurza.secnetix.de [83.120.8.8]) by mx1.FreeBSD.org (Postfix) with ESMTP id 335F543D62 for ; Wed, 12 Apr 2006 13:32:18 +0000 (GMT) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (enmbcn@localhost [127.0.0.1]) by lurza.secnetix.de (8.13.4/8.13.4) with ESMTP id k3CDWC4b086257 for ; Wed, 12 Apr 2006 15:32:17 +0200 (CEST) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.13.4/8.13.1/Submit) id k3CDWCtp086256; Wed, 12 Apr 2006 15:32:12 +0200 (CEST) (envelope-from olli) Date: Wed, 12 Apr 2006 15:32:12 +0200 (CEST) Message-Id: <200604121332.k3CDWCtp086256@lurza.secnetix.de> From: Oliver Fromme To: freebsd-fs@FreeBSD.ORG In-Reply-To: <200603241646.58415.mi+mx@aldan.algebra.com> X-Newsgroups: list.freebsd-fs User-Agent: tin/1.8.0-20051224 ("Ronay") (UNIX) (FreeBSD/4.11-STABLE (i386)) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Wed, 12 Apr 2006 15:32:17 +0200 (CEST) Cc: Subject: Re: How 'honest' is fstat(1)? X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-fs@FreeBSD.ORG List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Apr 2006 13:32:26 -0000 Mikhail Teterin wrote: > As a policy I try to keep my /, /usr, and other filesystems (except /var > and /home) mounted readonly. (Not so much for security as for safety.) That's not a bad idea, basically. > When I need to make a modification, I remount them: > > mount -orw -u / > > make the change, and remount back: > > mount -oro -u /usr/local Note that you will lose any additional options that way, such as "nosuid". To retain the current options, use a command like this: mount -u -o current,ro /usr/local Or to use the options from your /etc/fstab: mount -u -o fstab,ro /usr/local > This works for "small" changes, but sometimes, however, after a bigger on > (such as rebuilding of some ports), the last step fails with "busy". Maybe there are still things in the softupdates backlog. Those don't appear in fstat(1) output because they're not associated with a particular process or descriptor. Is the FS still busy after waiting a few minutes? However, I _think_ the unmount() should just block in that case until all softupdates changes are flushed to disk, not report EBUSY. But I'm not 100% sure. > At this time nothing should have a file open, and nothing does according to > fstat. The command: > > fstat | awk '$5 == "/usr/local" && $NF != "r"' > > does not list anything. Does it list anything when you omit the check for $NF!="r"? Did you try to use lsof(8) instead (from ports collection)? > My only guess is, the earlier versions of the just reinstalled executables are > still running and that trigger's the rarely noticed bug. It would be a bug, because running executables should not be open for writing. In the past, the mount update code (-u flag) had bugs which could even lead to FS corruption when you switched back and forth between ro and rw multiple times. But I believe those bugs were fixed. Best regards Oliver -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. "If you aim the gun at your foot and pull the trigger, it's UNIX's job to ensure reliable delivery of the bullet to where you aimed the gun (in this case, Mr. Foot)." -- Terry Lambert, FreeBSD-hackers mailing list.