Linux filesystem development
 help / color / mirror / Atom feed
* Zero-clearing all zero-clearable bytes.
@ 2008-11-22  3:36 Tetsuo Handa
  2008-11-22 17:44 ` Andreas Dilger
  2008-11-23  4:27 ` Phillip Lougher
  0 siblings, 2 replies; 9+ messages in thread
From: Tetsuo Handa @ 2008-11-22  3:36 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: linux-kernel

Hello.

I often create a Live CD.
When creating a Live CD, loopback mounted ext3 image files are used.
These image files are then compressed so that the ISO image will fit within
a CD-R's capacity (i.e. 700MB).

Compressing whole image files includes compressing deleted/unused bytes within
a block. This means that non-zero bytes in deleted/unused blocks affect
compression ratio.

I'm using the below program to improve compression ratio.

----------
#define _FILE_OFFSET_BITS 64
#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

int main(int argc, char *argv[]) {
    int fd;
    static char buffer[4096];
    memset(buffer, 0, sizeof(buffer));
    snprintf(buffer, sizeof(buffer) - 1, "%s/XXXXXX", argc > 1 ? argv[1] : "");
    if ((fd = mkstemp(buffer)) != EOF) {
        unlink(buffer);
        memset(buffer, 255, sizeof(buffer));
        while (write(fd, buffer, sizeof(buffer)) > 0);
        sync();
        close(fd);
    }
    return 0;
}
----------

But this program cannot clear some bytes within a block for file data (e.g.
offset from 1 to 511 of a data block used by a file with only 1 byte data)
and blocks for directory entries.

Any suggestions?

Regards.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-11-25 10:59 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-22  3:36 Zero-clearing all zero-clearable bytes Tetsuo Handa
2008-11-22 17:44 ` Andreas Dilger
2008-11-23  0:15   ` Tetsuo Handa
2008-11-23  3:05     ` Phillip Lougher
2008-11-23  4:27 ` Phillip Lougher
2008-11-23  5:03   ` Tetsuo Handa
2008-11-23 11:25     ` Henrique de Moraes Holschuh
2008-11-24 14:56       ` Martin Steigerwald
2008-11-25 10:59         ` Tetsuo Handa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox