~ubuntu-branches/ubuntu/dapper/linux-ntfs/dapper

« back to all changes in this revision

Viewing changes to libntfs/compress.c

  • Committer: Bazaar Package Importer
  • Author(s): David Martínez Moreno
  • Date: 2005-11-08 20:20:23 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20051108202023-dpn4lutm8o0div8g
Tags: 1.12.1-1
* New upstream release (closes: #332930):
  - Fixed lots of memory leaks in the tools.
  - ntfsmount now uses the new API, and it has several fixes.
  - Support journals which have been modified by chkdsk.
  - New API for creating hard links, index handling, high-level creation and
    deletion of files and directories.
  - New utility ntfscmp (make extra) which compares two NTFS volumes and
    tell the differences. It's used for development, debugging, testing, etc.
  - Added robustness to several tools.
  - ntfsclone: fix saving by sectors during --rescue.
  - ntfsmount: Add 'locale' option and change interface to 'ntfsmount device
    mount_point'.
  - Fixed problem with kernel 2.4 and mkntfs.
  - Change ALL utilities to display the libntfs version they are running on.
    This should make debugging easier in the case that people are running
    mismatched utilities/library.
* This new release fixes problems with libfuse 2.4.0 (closes: #336357).
* Fixed a lot of typos in the manpages, kindly submitted by A Costa. Thanks!
  (closes: #336143, #336144, #336145, #336147, #336148).
* Fixed a couple of typos by me.
* debian/control: The SONAME of libntfs was bumped. Created new package
  (libntfs8) and removed the old one.
* debian/copyright: Updated the FSF postal address.
* Added debian/ntfsprogs.links in order to ship mkfs.ntfs and
  mount.ntfs-fuse.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * compress.c - Compressed attribute handling code.  Part of the Linux-NTFS
3
3
 *              project.
4
4
 *
5
 
 * Copyright (c) 2004 Anton Altaparmakov
 
5
 * Copyright (c) 2004-2005 Anton Altaparmakov
 
6
 * Copyright (c)      2005 Yura Pakhuchiy
6
7
 *
7
8
 * This program/include file is free software; you can redistribute it and/or
8
9
 * modify it under the terms of the GNU General Public License as published
22
23
 
23
24
#include "config.h"
24
25
 
 
26
#ifdef HAVE_STDIO_H
25
27
#include <stdio.h>
 
28
#endif
 
29
#ifdef HAVE_STRING_H
26
30
#include <string.h>
 
31
#endif
 
32
#ifdef HAVE_STDLIB_H
27
33
#include <stdlib.h>
 
34
#endif
 
35
#ifdef HAVE_ERRNO_H
28
36
#include <errno.h>
 
37
#endif
29
38
 
30
39
#include "attrib.h"
31
40
#include "debug.h"
84
93
        u8 tag;                 /* Current tag. */
85
94
        int token;              /* Loop counter for the eight tokens in tag. */
86
95
 
87
 
        Dprintf("Entering, cb_size = 0x%x.\n", cb_size);
 
96
        Dprintf("Entering, cb_size = 0x%x.\n", (unsigned)cb_size);
88
97
do_next_sb:
89
98
        Dprintf("Beginning sub-block at offset = 0x%x in the cb.\n",
90
99
                        cb - cb_start);
253
262
                runlist_element *rl, VCN cb_start_vcn, int cb_clusters)
254
263
{
255
264
        /*
256
 
         * The simplest case:  the run starting at @cb_start_vcn contains
 
265
         * The simplest case: the run starting at @cb_start_vcn contains
257
266
         * @cb_clusters clusters which are all not sparse, thus the cb is not
258
267
         * compressed.
259
268
         */
260
 
        if (rl->length - (cb_start_vcn - rl->vcn) >= cb_clusters)
261
 
                return FALSE;
 
269
restart:
262
270
        cb_clusters -= rl->length - (cb_start_vcn - rl->vcn);
263
 
        do {
 
271
        while (cb_clusters > 0) {
264
272
                /* Go to the next run. */
265
273
                rl++;
266
274
                /* Map the next runlist fragment if it is not mapped. */
267
275
                if (rl->lcn < LCN_HOLE || !rl->length) {
 
276
                        cb_start_vcn = rl->vcn;
268
277
                        rl = ntfs_attr_find_vcn(na, rl->vcn);
269
278
                        if (!rl || rl->lcn < LCN_HOLE || !rl->length)
270
279
                                return TRUE;
 
280
                        /*
 
281
                         * If the runs were merged need to deal with the
 
282
                         * resulting partial run so simply restart.
 
283
                         */
 
284
                        if (rl->vcn < cb_start_vcn)
 
285
                                goto restart;
271
286
                }
272
287
                /* If the current run is sparse, the cb is compressed. */
273
288
                if (rl->lcn == LCN_HOLE)
276
291
                if (rl->length >= cb_clusters)
277
292
                        return FALSE;
278
293
                cb_clusters -= rl->length;
279
 
        } while (cb_clusters > 0);
 
294
        };
280
295
        /* All cb_clusters were not sparse thus the cb is not compressed. */
281
296
        return FALSE;
282
297
}