From owner-freebsd-chat Mon Jun 5 6:21:59 2000 Delivered-To: freebsd-chat@freebsd.org Received: from happy.checkpoint.com (happy.checkpoint.com [199.203.156.41]) by hub.freebsd.org (Postfix) with ESMTP id 4AD5237BC46 for ; Mon, 5 Jun 2000 06:21:49 -0700 (PDT) (envelope-from mellon@pobox.com) Received: (from mellon@localhost) by happy.checkpoint.com (8.9.3/8.9.3) id QAA32505; Mon, 5 Jun 2000 16:20:25 +0300 (IDT) (envelope-from mellon@pobox.com) Date: Mon, 5 Jun 2000 16:20:25 +0300 From: Anatoly Vorobey To: Charon Cc: chat@freebsd.org Subject: Re: Undelete in Unix (Was: Re: Why encourage stupid people to use *BSD) Message-ID: <20000605162025.A32447@happy.checkpoint.com> References: <3939F26A.A405DD4A@mail.ptd.net> <20000605081334.C25970@ecto.greenpeas.org> <001501bfceee$34cb9a00$858c8c96@win2000.cc.ceid.upatras.gr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i In-Reply-To: <001501bfceee$34cb9a00$858c8c96@win2000.cc.ceid.upatras.gr>; from charon@sabotage.gr on Mon, Jun 05, 2000 at 04:01:46PM +0300 Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Mon, Jun 05, 2000 at 04:01:46PM +0300, Charon wrote: > > > Out of the ether, Giorgos Keramidas spewed forth the following bitstream: > > > So, I'm also very interested to know how they had implemented > > > such a feature. Anybody with more knowledge on the topic? > > > > alias rm 'mv $* ~/.dustbin' > > Oh, I know. I know. > I had thought of this, but then I thought of a setup where /usr is > mounted from a different filesystem that the root filesystem, and > this alias is executed by the superuser. I suppose one way to do it would be to replace rm by the following scheme: - every filesystem holds a .dustbin directory at the root of the filesystem; - the .dustbin directory includes symlinks of the kind .dustbin/originaldir-originalname --> .dustbin/43265 and hardlinks of .dustbin/43265 to the file with inode 43265. - alias rm newrm - newrm, before unlink'ing a file, backsteps the current directory until it finds the mount point of the filesystem. It can do this by using statfs for instance, and comparing fs id's in it. When it finds the mount point, it goes into .dustbin in it and plants both the hardlink to the file being deleted (if it's not yet there), and the symlink which preserves the current name being deleted and directory. - undelete dirname/filename finds the mount point of fs dirname is supposed to reside in, goes into .dustbin, searches for the symlink, retrieves the hardlink, and hardlinks the original name in the original dir to it, and deletes the symlink. When there are no more dustbin symlinks left pointing at this hardlink, it deletes the dustbin hardlink. This is just something which occurred to me as I read this thread today, I never actually tried it. -- Anatoly Vorobey, mellon@pobox.com http://pobox.com/~mellon/ "Angels can fly because they take themselves lightly" - G.K.Chesterton To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-chat" in the body of the message