lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 23 Nov 2008 03:05:47 +0000
From:	Phillip Lougher <phillip@...gher.demon.co.uk>
To:	Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
CC:	adilger@....com, linux-fsdevel@...r.kernel.org,
	linux-kernel@...r.kernel.org
Subject: Re: Zero-clearing all zero-clearable bytes.

Tetsuo Handa wrote:
> Hello.
> 
> Andreas Dilger wrote:
>> Why would you fill the buffer with 0xff instead of 0?
>> In fact no such program is needed, just "dd if=/dev/zero of=/{fs}/tmp"
>> and then delete the file.
>>
> To avoid that the /{fs}/tmp is created as a sparse file.
> 

Most filesystems will not create a sparse file if zero-byte filled 
blocks are written.  To create a sparse file you normally have to seek 
beyond the file end and then write blocks, leaving a hole in-between the 
positions.

The information from stat can tell you if a file has been stored 
sparsely, because the blocks used count will be less than the file size 
suggests.

For example:

$ dd if=/dev/zero of=small-file bs=512 count=16
16+0 records in
16+0 records out
8192 bytes (8.2 kB) copied, 0.000187744 seconds, 43.6 MB/s
phillip@...an:/tmp$ stat small-file
   File: `small-file'
   Size: 8192            Blocks: 16         IO Block: 4096   regular file
Device: 801h/2049d      Inode: 847831      Links: 1

The zero filled file uses 16 blocks (16 * 512 bytes = 8K), and so we 
know it isn't sparsely stored.

You can get dd to seek a number of blocks into the output file before 
writing, this will create a sparse file...

$ dd if=/dev/zero of=small-file bs=512 count=16 seek=16
16+0 records in
16+0 records out
8192 bytes (8.2 kB) copied, 0.000212609 seconds, 38.5 MB/s
phillip@...an:/tmp$ stat small-file
   File: `small-file'
   Size: 16384           Blocks: 16         IO Block: 4096   regular file
Device: 801h/2049d      Inode: 847831      Links: 1

A 16K file is only using 16 blocks, and so 8K is stored sparsely.

Phillip
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ