From 78708015af77363a9509abad8b139243272f01df Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Sun, 19 May 2024 18:35:40 +0200 Subject: [PATCH] Improved warning messages about symbolic links and special files in ISO 9660:1999 tree --- libisofs/ecma119.c | 12 ++++++++++++ libisofs/ecma119.h | 6 ++++++ libisofs/iso1999.c | 29 ++++++++++++++++++++++++----- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/libisofs/ecma119.c b/libisofs/ecma119.c index f1763a4..5c076a9 100644 --- a/libisofs/ecma119.c +++ b/libisofs/ecma119.c @@ -2764,6 +2764,8 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *in_opts, Ecma119Image **img) target->joliet_ucs2_failures = 0; target->joliet_symlinks = 0; target->joliet_specials = 0; + target->iso1999_symlinks = 0; + target->iso1999_specials = 0; /* If partitions get appended, then the backup GPT cannot be part of the ISO filesystem. @@ -3303,6 +3305,16 @@ int ecma119_image_new(IsoImage *src, IsoWriteOpts *in_opts, Ecma119Image **img) "Number of special files omitted from Joliet tree: %lu", target->joliet_specials); } + if (target->iso1999_symlinks > 0) { + iso_msg_submit(target->image->id, ISO_FILE_IGNORED, 0, + "Number of symbolic links omitted from ISO 9660:1999 tree: %lu", + target->iso1999_symlinks); + } + if (target->iso1999_specials > 0) { + iso_msg_submit(target->image->id, ISO_FILE_IGNORED, 0, + "Number of special files omitted from ISO 9660:1999 tree: %lu", + target->iso1999_specials); + } *img = target; return ISO_SUCCESS; diff --git a/libisofs/ecma119.h b/libisofs/ecma119.h index 88b4420..f318b22 100644 --- a/libisofs/ecma119.h +++ b/libisofs/ecma119.h @@ -933,6 +933,12 @@ struct ecma119_image unsigned long joliet_symlinks; unsigned long joliet_specials; + /* Count of symbolic links and special files which could not be represented + in ISO 9660:1999. + */ + unsigned long iso1999_symlinks; + unsigned long iso1999_specials; + }; #define BP(a,b) [(b) - (a) + 1] diff --git a/libisofs/iso1999.c b/libisofs/iso1999.c index fe40b6b..3ac324c 100644 --- a/libisofs/iso1999.c +++ b/libisofs/iso1999.c @@ -251,14 +251,33 @@ int create_tree(Ecma119Image *t, IsoNode *iso, Iso1999Node **tree, int pathlen) } break; case LIBISO_SYMLINK: - case LIBISO_SPECIAL: - { + t->iso1999_symlinks++; + if (t->iso1999_symlinks == 1) { char *ipath = iso_tree_get_node_path(iso); ret = iso_msg_submit(t->image->id, ISO_FILE_IGNORED, 0, - "Can't add %s to ISO 9660:1999 tree. This kind of files " - "can only be added to a Rock Ridget tree. Skipping.", - ipath); + "Cannot add symbolic link %s to ISO 9660:1999 tree. Skipping.", + ipath); free(ipath); + } else { + if (t->iso1999_symlinks == 2) + iso_msg_submit(t->image->id, ISO_FILE_IGNORED, 0, + "More symbolic links were omitted from ISO 9660:1999 tree."); + ret = 0; + } + break; + case LIBISO_SPECIAL: + t->iso1999_specials++; + if (t->iso1999_specials == 1) { + char *ipath = iso_tree_get_node_path(iso); + ret = iso_msg_submit(t->image->id, ISO_FILE_IGNORED, 0, + "Cannot add special file %s to ISO 9660:1999 tree. Skipping.", + ipath); + free(ipath); + } else { + if (t->iso1999_specials == 2) + iso_msg_submit(t->image->id, ISO_FILE_IGNORED, 0, + "More special files were omitted from ISO 9660:1999 tree."); + ret = 0; } break; default: