Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Nov 2010 14:09:03 -0600
From:      Dan Nelson <dnelson@allantgroup.com>
To:        Matthias Apitz <guru@unixarea.de>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: how to overwrite the content of a file
Message-ID:  <20101111200903.GA57869@dan.emsphone.com>
In-Reply-To: <20101111200252.GA1350@tiny.Sisis.de>
References:  <20101111200252.GA1350@tiny.Sisis.de>

next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Nov 11), Matthias Apitz said:
> What is the best method to overwrite the blocks of a given file with bytes
> of 0x00, i.e.  not to O_TRUNC away the blocks to the freelist of the file
> system, but overwrite the old blocks?
> 
> I've checked
> 
> $ dd if=/dev/zero of=file count=4
> 
> but dd(1) opens the file with O_RDWR|O_CREAT|O_TRUNC which for sure will
> give away the old blocks and adquire new blocks.  Any idea?

conv=notrunc

(note that this will only help with ufs; zfs is always copy-on-write, so
newly-written data never overwrites the old blocks)

-- 
	Dan Nelson
	dnelson@allantgroup.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20101111200903.GA57869>