libcdio-devel
[Top][All Lists]
Advanced

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

Re: [Libcdio-devel] [PATCH] Fix extract.c sample for LFS


From: Rocky Bernstein
Subject: Re: [Libcdio-devel] [PATCH] Fix extract.c sample for LFS
Date: Tue, 24 Jan 2012 20:16:20 -0500

On Tue, Jan 24, 2012 at 1:04 PM, Pete Batard <address@hidden> wrote:

> Without this patch, the extract.c sample will fail on 32 bit machines when
> extracting a file that is larger than 2 GB (EFBIG in fwrite = file too
> large).
>

This makes sense. Keep improving! And thanks again.


>
> This is due from _FILE_OFFSET_BITS not being picked up due to config.h
> being missing (NB: udffile.c does include config.h already so doesn't need
> a fix).
>
> You'll see that I also added an info message to notify users about missing
> LFS. Maybe this is something that would be better added to udf_open()?
>
> The expectation is that most people dealing with UDF will require LFS
> support, so a cdio_info/cdio_warn in udf_open(), if LFS is not detected may
> help non LFS libcdio users troubleshoot LFS related issues more easily.
>
> With this patch and the previous one, UDF extraction on Linux 32 bit
> should be sorted. I'll probably send a couple more patches, that aren't
> critical for libcdio operations, and then move to MinGW fixes (where the
> bad surprise is that, rather astonishingly, the current version of MinGW32
> has NO transparent support for LFS whatsoever).
>
> Regards,
>
> /Pete
>
> From 15dbcac9a29d69d11ece44c1d0ea4fe24341cdc5 Mon Sep 17 00:00:00 2001
> From: Pete Batard <address@hidden>
> Date: Tue, 24 Jan 2012 17:05:21 +0000
> Subject: [PATCH] Fix extract.c sample for LFS
>
> * also add user warning if LFS is not detected
> * also elaborate on write error, as they may be relevant for LFS
> ---
>  example/extract.c |   16 ++++++++++++++--
>  1 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/example/extract.c b/example/extract.c
> index 913634d..6b5e03a 100644
> --- a/example/extract.c
> +++ b/example/extract.c
> @@ -20,6 +20,13 @@
>    TODO: timestamp preservation, file permissions, Unicode
>  */
>
> +/* To handle files > 2 GB, we may need the Large File Support settings
> +   defined in config.h. Comes first, as stdio.h depends on it. */
> +#ifdef HAVE_CONFIG_H
> +# include "config.h"
> +# define __CDIO_CONFIG_H__ 1
> +#endif
> +
>  #include <stdio.h>
>  #include <string.h>
>  #include <malloc.h>
> @@ -100,7 +107,7 @@ static int udf_extract_files(udf_t *p_udf,
> udf_dirent_t *p_udf_dirent, const cha
>         }
>         fwrite(buf, (size_t)MIN(i_file_length, i_read), 1, fd);
>         if (ferror(fd)) {
> -          fprintf(stderr, "  Error writing file\n");
> +          fprintf(stderr, "  Error writing file: %s\n", strerror(errno));
>           goto out;
>         }
>         i_file_length -= i_read;
> @@ -174,7 +181,7 @@ static int iso_extract_files(iso9660_t* p_iso, const
> char *psz_path)
>         }
>         fwrite(buf, (size_t)MIN(i_file_length, ISO_BLOCKSIZE), 1, fd);
>         if (ferror(fd)) {
> -          fprintf(stderr, "  Error writing file\n");
> +          fprintf(stderr, "  Error writing file: %s\n", strerror(errno));
>           goto out;
>         }
>         i_file_length -= ISO_BLOCKSIZE;
> @@ -208,6 +215,11 @@ int main(int argc, char** argv)
>     fprintf(stderr, "Usage: extract <iso_image> <extraction_dir>\n");
>     return 1;
>   }
> +
> +  /* Warn if LFS doesn't appear to be enabled */
> +  if (sizeof(off_t) < 8) {
> +    fprintf(stderr, "INFO: Large File Support not detected (required for
> files >2GB)\n");
> +  }
>
>   psz_extract_dir = argv[2];
>   if (_mkdir(psz_extract_dir) == 0) {
> --
> 1.7.8.msysgit.0
>
>
>


reply via email to

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