diff --git a/demo/ecma119_tree.c b/demo/ecma119_tree.c index deb206f..a232f76 100644 --- a/demo/ecma119_tree.c +++ b/demo/ecma119_tree.c @@ -12,6 +12,7 @@ #include "filesrc.h" #include "node.h" #include +#include #include #include #include @@ -41,7 +42,7 @@ static void print_dir(Ecma119Node *dir, int level) { int i; - char sp[level * 2 + 1]; + char *sp = alloca(level * 2 + 1); for (i = 0; i < level * 2; i += 2) { sp[i] = '|'; diff --git a/demo/iso.c b/demo/iso.c index edc1d01..4c30dd1 100644 --- a/demo/iso.c +++ b/demo/iso.c @@ -55,6 +55,7 @@ int main(int argc, char **argv) 0, /* joliet */ 0, /* omit_version_numbers */ 0, /* allow_deep_paths */ + 0, /* allow_longer_paths */ 0, /* max_37_char_filenames */ 0, /* no_force_dots */ 0, /* allow_lowercase */ diff --git a/demo/iso_grow.c b/demo/iso_grow.c index 094a8ec..9ff6215 100644 --- a/demo/iso_grow.c +++ b/demo/iso_grow.c @@ -38,6 +38,7 @@ int main(int argc, char **argv) 0, /* joliet */ 0, /* omit_version_numbers */ 0, /* allow_deep_paths */ + 0, /* allow_longer_paths */ 0, /* max_37_char_filenames */ 0, /* no_force_dots */ 0, /* allow_lowercase */ diff --git a/demo/iso_modify.c b/demo/iso_modify.c index e055f5d..27f4a22 100644 --- a/demo/iso_modify.c +++ b/demo/iso_modify.c @@ -33,6 +33,7 @@ int main(int argc, char **argv) 0, /* joliet */ 0, /* omit_version_numbers */ 0, /* allow_deep_paths */ + 0, /* allow_longer_paths */ 0, /* max_37_char_filenames */ 0, /* no_force_dots */ 0, /* allow_lowercase */ diff --git a/demo/iso_ms.c b/demo/iso_ms.c index 00e9b0c..1bc80d9 100644 --- a/demo/iso_ms.c +++ b/demo/iso_ms.c @@ -33,6 +33,7 @@ int main(int argc, char **argv) 0, /* joliet */ 0, /* omit_version_numbers */ 0, /* allow_deep_paths */ + 0, /* allow_longer_paths */ 0, /* max_37_char_filenames */ 0, /* no_force_dots */ 0, /* allow_lowercase */ diff --git a/src/ecma119.c b/src/ecma119.c index dfb388c..a62ff5e 100644 --- a/src/ecma119.c +++ b/src/ecma119.c @@ -847,6 +847,7 @@ int ecma119_image_new(IsoImage *src, Ecma119WriteOpts *opts, Ecma119Image **img) target->omit_version_numbers = opts->omit_version_numbers | opts->max_37_char_filenames; target->allow_deep_paths = opts->allow_deep_paths; + target->allow_longer_paths = opts->allow_longer_paths; target->max_37_char_filenames = opts->max_37_char_filenames; target->no_force_dots = opts->no_force_dots; target->allow_lowercase = opts->allow_lowercase; diff --git a/src/ecma119.h b/src/ecma119.h index 7d13fdb..5467e34 100644 --- a/src/ecma119.h +++ b/src/ecma119.h @@ -39,6 +39,7 @@ struct ecma119_image /* relaxed constraints */ unsigned int omit_version_numbers :1; unsigned int allow_deep_paths :1; + unsigned int allow_longer_paths :1; unsigned int max_37_char_filenames :1; unsigned int no_force_dots :1; unsigned int allow_lowercase :1; diff --git a/src/ecma119_tree.c b/src/ecma119_tree.c index 9999447..933c0ba 100644 --- a/src/ecma119_tree.c +++ b/src/ecma119_tree.c @@ -296,11 +296,17 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree, return ret; } max_path = pathlen + 1 + (iso_name ? strlen(iso_name) : 0); - if (!image->rockridge && !image->allow_deep_paths) { - if ((iso->type == LIBISO_DIR && depth > 8) || max_path > 255) { + if (!image->rockridge) { + if ((iso->type == LIBISO_DIR && depth > 8) && !image->allow_deep_paths) { iso_msg_note(image->image->messenger, LIBISO_FILE_IGNORED, - "File \"%s\" can't be added, because depth > 8 " - "or path length over 255", iso->name); + "File \"%s\" can't be added, because directory depth " + "is greater than 8.", iso->name); + free(iso_name); + return 0; + } else if (max_path > 255 && !image->allow_longer_paths) { + iso_msg_note(image->image->messenger, LIBISO_FILE_IGNORED, + "File \"%s\" can't be added, because path length " + "is greater than 255 characters", iso->name); free(iso_name); return 0; } diff --git a/src/libisofs.h b/src/libisofs.h index b6f8a53..75033cb 100644 --- a/src/libisofs.h +++ b/src/libisofs.h @@ -100,13 +100,57 @@ typedef struct unsigned int rockridge :1; unsigned int joliet :1; - /* relaxed constraints */ + /* + * Relaxed constraints. Setting any of these to 1 break the specifications, + * but it is supposed to work on most moderns systems. Use with caution. + */ + + /** + * Omit the version number (";1") at the end of the ISO-9660 identifiers. + * Version numbers are usually not used. + */ unsigned int omit_version_numbers :1; + + /** + * Allow ISO-9660 directory hierarchy to be deeper than 8 levels. + */ unsigned int allow_deep_paths :1; + + /** + * Allow path in the ISO-9660 tree to have more than 255 characters. + */ + unsigned int allow_longer_paths :1; + + /** + * Allow a single file or directory hierarchy to have up to 37 characters. + * This is larger than the 31 characters allowed by ISO level 2, and the + * extra space is taken from the version number, so this also forces + * omit_version_numbers. + */ unsigned int max_37_char_filenames :1; + + /** + * ISO-9660 forces filenames to have a ".", that separates file name from + * extension. libisofs adds it if original filename doesn't has one. Set + * this to 1 to prevent this behavior + */ unsigned int no_force_dots :1; + + /** + * Allow lowercase characters in ISO-9660 filenames. By default, only + * uppercase characters, numbers and a few other characters are allowed. + */ unsigned int allow_lowercase :1; + + /** + * Allow all ASCII characters to be appear on an ISO-9660 filename. Note + * that "/" and "\0" characters are never allowed, even in RR names. + */ unsigned int allow_full_ascii :1; + + /** + * Allow paths in the Joliet tree to have more than 240 characters. + */ unsigned int joliet_longer_paths :1; /**< If files should be sorted based on their weight. */