From owner-freebsd-hackers Thu Aug 17 18:56:32 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.129.65]) by hub.freebsd.org (Postfix) with ESMTP id D9BC637BF20 for ; Thu, 17 Aug 2000 18:51:43 -0700 (PDT) Received: from gatekeeper.whistle.com (gatekeeper.whistle.com [207.76.204.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id D41EB6E3E51 for ; Thu, 17 Aug 2000 17:38:18 -0700 (PDT) Received: from bubba.whistle.com (bubba.whistle.com [207.76.205.7]) by gatekeeper.whistle.com (8.9.3/8.9.3) with ESMTP id RAA12979; Thu, 17 Aug 2000 17:38:23 -0700 (PDT) (envelope-from archie@whistle.com) Received: (from archie@localhost) by bubba.whistle.com (8.9.3/8.9.3) id RAA02350; Thu, 17 Aug 2000 17:38:22 -0700 (PDT) (envelope-from archie) From: Archie Cobbs Message-Id: <200008180038.RAA02350@bubba.whistle.com> Subject: Re: Critical (or equivalent) section in Userland? In-Reply-To: <20000817100652.A31452@walton.maths.tcd.ie> from David Malone at "Aug 17, 2000 10:06:52 am" To: David Malone Date: Thu, 17 Aug 2000 17:38:22 -0700 (PDT) Cc: Karl Pielorz , hackers@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL68 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG David Malone writes: > > I'm writing a program under FreeBSD 3.X that has been forced into having to > > make a number of rename() calls that must be completed atomically (i.e. all > > together) without the process being interrupted, or any other process being > > allowed to run... > > If all the files exist below one directory you could swap the > directories with two renames, but that won't be atomic either. I > think your best bet would be rethink what you want to do. It could still work as long as at startup you check for any half-completed operation and finish it, e.g.: mkdir mydir.new copy/modify files in mydir.new mv mydir mydir.old mv mydir.new mydir Then on startup (e.g., after a crash), if "mydir" doesn't exist, simply "mv mydir.new mydir; rm -rf mydir.old" before proceeding. -Archie ___________________________________________________________________________ Archie Cobbs * Whistle Communications, Inc. * http://www.whistle.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message