Re: [PATCH, RFC] btrfs-progs: require mkfs -f force option to overwrite filesystem or partition table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Feb 26, 2013 at 08:39:52AM +0900, Tsutomu Itoh wrote:
> >This means that it is now required to change all occurrences of
> >"mkfs.btrfs" to "mkfs.btrfs -f" everywhere. Can't we first establish a
> 
> I also think so.
> It means -f is not significant to me, I think.
> (Most of my test scripts fails without -f. So I'll always type "mkfs.btrfs -f")
> 
> Therefore I want you to revert commit:2a2d8e1962e8b6cda7b0a7584f6d2fb95d442cb6.
>   btrfs-progs: require mkfs -f force option to overwrite filesystem or partition table

I personally don't want to see it reverted, but also very much understand the
pain to tweak all existing test scripts that rely on direct success of plain
mkfs. To resolve this I'm going to use the attached script, that intsalls
itself in place of mkfs.btrfs and act's as we were used to. This is intended to
help developers and is not for the end user.

david

first use: mkfs.btrfs.wrapper install

---
$ cat mkfs.btrfs.wrapper
#!/bin/sh

if [ $# = 1 -a $1 = 'install' ]; then
	echo "Install mode"
	mkfs=`type -p mkfs.btrfs`
	if [ $? != 0 ]; then
		echo "Cannot find mkfs.btrfs"
		exit 1
	fi
	if file $mkfs | grep -q 'ELF .* executable'; then
		echo "Moving original mkfs to ${mkfs}.real"
		mv $mkfs ${mkfs}.real
		echo "Copying myself to $mkfs"
		cp $0 $mkfs
		chmod 755 $mkfs
		echo "Have a nice day"
		exit 0
	else
		echo "$mkfs is not a binary, will not overwrite"
		exit 1
	fi
fi

mkfs=`type -p mkfs.btrfs.real`
if [ $? != 0 ]; then
	echo "Cannot find mkfs.btrfs.real, install the wrapper properly"
	exit 1
fi
force=

if grep -q 'Use the -f option to force overwrite' $mkfs; then
	force='-f'
fi

$mkfs $force "$@"
---
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux