[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Libcdio-devel] [RFC] New API iso9660_statv2_t as API/ABI compatible

From: Thomas Schmitt
Subject: Re: [Libcdio-devel] [RFC] New API iso9660_statv2_t as API/ABI compatible way to read files >= 4 GiB
Date: Mon, 09 Jul 2018 18:17:37 +0200


Pete's adaption of example/extract.c was already prepared for unaligned
extents. My proposal inherited this.

With others, the bad habit of writing full blocks and finally calling
ftruncate(3) caused dependence on size-aligned extents:

Considering a bet on seamlessly stored big data files, Pete Batard wrote:

> My biggest issue here is that, unless we store our extent LSNs somewhere, we
> have no means of reporting to users that our assumption was wrong, which is
> a big NO_NO.

The reader from ISO directory records, _iso9660_dir_to_statbuf(), knows
the start and size of the previous extent. So it could check whether the
current extent fits seamlessly.
E.g. after:

    p_stat->extent_lsn[p_stat->num_extents] = from_733 (p_iso9660_dir->extent);
    p_stat->extent_size[p_stat->num_extents] = from_733 (p_iso9660_dir->size);
    p_stat->total_size += p_stat->extent_size[p_stat->num_extents];

it could do:

    if (p_stat->extent_lsn[p_stat->num_extents - 1]
        + p_stat->extent_size[p_stat->num_extents - 1] / ISO_BLOCKSIZE)
        != p_stat->extent_lsn[p_stat->num_extents]
        p_stat->extent_size[p_stat->num_extents - 1] % ISO_BLOCKSIZE) {

      /* >>> Gap detected <<< */;


(The second ||-case might be unnecessary, because we really do not
 expect extents to overlap. Whatever. It makes clear what is meant.)

If gaps are found, it could either bail out with error message, or it
could mark the stat buffer by a new flag member. Another flag could
indicate whether ISO_MAX_MULTIEXTENT was exceeded.

Without any extents array above test would have to be based on .lsn
and .total_size :

    lsn_t extent_lsn;


    extent_lsn = from_733 (p_iso9660_dir->extent);

    /* Still with previous .total_size */
    if (p_stat->lsn + p_stat->total_size / ISO_BLOCKSIZE != extent_lsn
        || p_stat->total_size % ISO_BLOCKSIZE) {

      /* >>> Gap detected <<< */;


    /* Only now update .total_size */
    p_stat->total_size += from_733 (p_iso9660_dir->size);

I consider to implement something like this in my proposal. Just to bear
cool info.

Have a nice day :)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]