public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Schleef <ds@schleef.org>
To: Padraig Brady <Padraig@AnteFacto.com>
Cc: William Stearns <wstearns@pobox.com>,
	ML-linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: [OFFTOPIC] Hardlink utility - reclaim drive space
Date: Mon, 5 Mar 2001 14:08:18 -0800	[thread overview]
Message-ID: <20010305140818.A31372@stm.lbl.gov> (raw)
In-Reply-To: <Pine.LNX.4.30.0102191626090.29121-100000@sparrow.websense.net> <3AA3E63E.80101@AnteFacto.com>
In-Reply-To: <3AA3E63E.80101@AnteFacto.com>; from Padraig@AnteFacto.com on Mon, Mar 05, 2001 at 07:17:18PM +0000

[-- Attachment #1: Type: text/plain, Size: 373 bytes --]

On Mon, Mar 05, 2001 at 07:17:18PM +0000, Padraig Brady wrote:
> Hmm.. useful until you actually want to modify a linked file,
> but then your modifying the file in all "merged" trees.

Use emacs, because you can configure it to do something
appropriate with linked files.  But for those of us addicted
to vi, the attached wrapper script is pretty cool, too.





dave...


[-- Attachment #2: cow-wrapper --]
[-- Type: text/plain, Size: 707 bytes --]

#!/bin/bash
#
# copy-on-write wrapper for hard linked files
# Copyright 2000 David A. Schleef <ds@schleef.org>
#
# Please send me any improvments you make to this script.  I just
# wrote it as a quick and dirty hack.


linkedfiles=

for each in $*
do
	case $each in
	-*)
		# ignore
		;;
	*)
		if [ -f "$each" ];then
			nlinks=$(stat $each|grep Links|sed 's/.*Links: \(.*\)\{1\}/\1/')
			if [ $nlinks -gt 1 ];then
				#echo unlinking $each
				linkedfiles="$linkedfiles $each"
				mv $each $each.orig
				cp $each.orig $each
			fi
		fi
		;;
	esac
done

/usr/bin/vim $*

for each in $linkedfiles
do
	if cmp $each $each.orig &>/dev/null
	then
		#echo relinking $each
		rm $each
		mv $each.orig $each
	fi
done


  parent reply	other threads:[~2001-03-05 22:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-02 19:03 [OFFTOPIC] Hardlink utility - reclaim drive space William Stearns
2001-03-05 19:17 ` Padraig Brady
2001-03-05 19:19   ` Jeremy Jackson
2001-03-06 13:57     ` Padraig Brady
2001-03-05 22:08   ` David Schleef [this message]
2001-03-07 14:52 ` David Woodhouse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010305140818.A31372@stm.lbl.gov \
    --to=ds@schleef.org \
    --cc=Padraig@AnteFacto.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wstearns@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox