#!/usr/bin/perl

# the .pvfsdir files have a unique identifier ( the inode of 
# the .pvfsdir file) in them. The mgr uses that unique id to keep track of 
# multiple pvfs file systems on one metadata server

# SUGGESTED USAGE: 
# find /path/to/pvfs_metadata_dir -name .pvfsdir -exec fix_pvfsdir {} \;

use File::Temp;
use File::Copy;


open (pvfsdir, $ARGV[0]) or die "could not open $ARGV[0]";
($fh, $filename) = mkstemp("pvfsdirXXXXXX");

$inode = (stat($ARGV[0]))[1];
$done=0;

while(<pvfsdir>) {
	if ( $done == 0) {
		s/[0-9].*/$inode/;
		$done=1;
	}
	print $fh $_;
}

move($filename, $ARGV[0]);
