From 411524c330675c6e4c843cc5efb3522af962d5f0 Mon Sep 17 00:00:00 2001 From: Vreixo Formoso Date: Sat, 15 Dec 2007 18:29:40 +0100 Subject: [PATCH] Handling of iso directory depth restrictions on tree creation time. Note that this doesn't involve the RR reparent. It just ignore the files that break iso restrictions (see ECMA-119, 6.8.2.1). --- src/ecma119_tree.c | 42 ++++++++++++++++++++++++++++-------------- src/libiso_msgs.h | 3 +++ src/messages.h | 3 +++ 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/ecma119_tree.c b/src/ecma119_tree.c index dd8b4de..c10a1ed 100644 --- a/src/ecma119_tree.c +++ b/src/ecma119_tree.c @@ -12,12 +12,13 @@ #include "node.h" #include "util.h" #include "filesrc.h" +#include "messages.h" #include #include static -int set_iso_name(Ecma119Image *img, IsoNode *iso, Ecma119Node *node) +int get_iso_name(Ecma119Image *img, IsoNode *iso, char **name) { int ret; char *ascii_name; @@ -47,14 +48,13 @@ int set_iso_name(Ecma119Image *img, IsoNode *iso, Ecma119Node *node) iso_2_fileid(ascii_name); } } - node->iso_name = ascii_name; + *name = ascii_name; return ISO_SUCCESS; } static int create_ecma119_node(Ecma119Image *img, IsoNode *iso, Ecma119Node **node) { - int ret; Ecma119Node *ecma; ecma = calloc(1, sizeof(Ecma119Node)); @@ -62,12 +62,6 @@ int create_ecma119_node(Ecma119Image *img, IsoNode *iso, Ecma119Node **node) return ISO_MEM_ERROR; } - ret = set_iso_name(img, iso, ecma); - if (ret < 0) { - free(ecma); - return ret; - } - /* take a ref to the IsoNode */ ecma->node = iso; iso_node_ref(iso); @@ -157,10 +151,13 @@ void ecma119_node_free(Ecma119Node *node) * */ static -int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree) +int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree, + int depth, int pathlen) { int ret; Ecma119Node *node; + int max_path; + char *iso_name = NULL; if (image == NULL || iso == NULL || tree == NULL) { return ISO_NULL_POINTER; @@ -170,6 +167,21 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree) /* file will be ignored */ return 0; } + ret = get_iso_name(image, iso, &iso_name); + if (ret < 0) { + return ret; + } + max_path = pathlen + 1 + (iso_name ? strlen(iso_name) : 0); + if (1) { //TODO !rockridge && !relaxed_paths + if (depth > 8 || max_path > 255) { +// char msg[512]; +// sprintf(msg, "File %s can't be added, because depth > 8 " +// "or path length over 255\n", iso_name); +// iso_msg_note(image, LIBISO_FILE_IGNORED, msg); + free(iso_name); + return 0; + } + } switch(iso->type) { case LIBISO_FILE: @@ -198,11 +210,11 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree) pos = dir->children; while (pos) { Ecma119Node *child; - ret = create_tree(image, pos, &child); + ret = create_tree(image, pos, &child, depth + 1, max_path); if (ret < 0) { /* error */ ecma119_node_free(node); - return ret; + break; } else if (ret == ISO_SUCCESS) { /* add child to this node */ int nchildren = node->info.dir.nchildren++; @@ -218,8 +230,10 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree) return ISO_ERROR; } if (ret < 0) { + free(iso_name); return ret; } + node->iso_name = iso_name; *tree = node; return ISO_SUCCESS; } @@ -227,14 +241,14 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree) int ecma119_tree_create(Ecma119Image *img, IsoNode *iso, Ecma119Node **tree) { int ret; - ret = create_tree(img, iso, tree); + ret = create_tree(img, iso, tree, 1, 0); if (ret < 0) { return ret; } /* * TODO - * - take care about dirs whose level is over 8 + * - reparent if RR * - sort files in dir * - mangle names */ diff --git a/src/libiso_msgs.h b/src/libiso_msgs.h index d681410..a4ad5bf 100644 --- a/src/libiso_msgs.h +++ b/src/libiso_msgs.h @@ -382,6 +382,9 @@ Range "scdbackup" : 0x00020000 to 0x0002ffff ------------------------------------------------------------------------------ Range "vreixo" : 0x00030000 to 0x0003ffff + Image creation: + 0x00030100 (NOTE,MEDIUM) = File cannot be added to image (ignored) + General: 0x00031001 (SORRY,HIGH) = Cannot read file (ignored) 0x00031002 (FATAL,HIGH) = Cannot read file (operation canceled) diff --git a/src/messages.h b/src/messages.h index e93e6f3..272c33e 100644 --- a/src/messages.h +++ b/src/messages.h @@ -15,6 +15,9 @@ #include "libiso_msgs.h" +/** File cannot be added to image (ignored) */ +#define LIBISO_FILE_IGNORED 0x00030100 + /** Can't read file (ignored) */ #define LIBISO_CANT_READ_FILE 0x00031001 /** Can't read file (operation canceled) */