Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755942AbYKVDhS (ORCPT ); Fri, 21 Nov 2008 22:37:18 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752391AbYKVDhE (ORCPT ); Fri, 21 Nov 2008 22:37:04 -0500 Received: from wine.ocn.ne.jp ([122.1.235.145]:59504 "EHLO smtp.wine.ocn.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751944AbYKVDhD (ORCPT ); Fri, 21 Nov 2008 22:37:03 -0500 To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org Subject: Zero-clearing all zero-clearable bytes. From: Tetsuo Handa Message-Id: <200811221236.FJE81778.LtMHOQFJFVFSOO@I-love.SAKURA.ne.jp> X-Mailer: Winbiff [Version 2.50 PL2] X-Accept-Language: ja,en Date: Sat, 22 Nov 2008 12:36:56 +0900 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1504 Lines: 50 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 #include #include #include 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. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/