Begin RR support. Symlinks and Special files added to low level tree.
This commit is contained in:
parent
b8aa48038b
commit
ca1385cce1
@ -10,6 +10,7 @@
|
|||||||
#include "ecma119_tree.h"
|
#include "ecma119_tree.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "filesrc.h"
|
#include "filesrc.h"
|
||||||
|
#include "node.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@ -19,72 +20,81 @@
|
|||||||
static void
|
static void
|
||||||
print_permissions(mode_t mode)
|
print_permissions(mode_t mode)
|
||||||
{
|
{
|
||||||
char perm[10];
|
char perm[10];
|
||||||
|
|
||||||
//TODO suid, sticky...
|
//TODO suid, sticky...
|
||||||
|
|
||||||
perm[9] = '\0';
|
perm[9] = '\0';
|
||||||
perm[8] = mode & S_IXOTH ? 'x' : '-';
|
perm[8] = mode & S_IXOTH ? 'x' : '-';
|
||||||
perm[7] = mode & S_IWOTH ? 'w' : '-';
|
perm[7] = mode & S_IWOTH ? 'w' : '-';
|
||||||
perm[6] = mode & S_IROTH ? 'r' : '-';
|
perm[6] = mode & S_IROTH ? 'r' : '-';
|
||||||
perm[5] = mode & S_IXGRP ? 'x' : '-';
|
perm[5] = mode & S_IXGRP ? 'x' : '-';
|
||||||
perm[4] = mode & S_IWGRP ? 'w' : '-';
|
perm[4] = mode & S_IWGRP ? 'w' : '-';
|
||||||
perm[3] = mode & S_IRGRP ? 'r' : '-';
|
perm[3] = mode & S_IRGRP ? 'r' : '-';
|
||||||
perm[2] = mode & S_IXUSR ? 'x' : '-';
|
perm[2] = mode & S_IXUSR ? 'x' : '-';
|
||||||
perm[1] = mode & S_IWUSR ? 'w' : '-';
|
perm[1] = mode & S_IWUSR ? 'w' : '-';
|
||||||
perm[0] = mode & S_IRUSR ? 'r' : '-';
|
perm[0] = mode & S_IRUSR ? 'r' : '-';
|
||||||
printf("[%s]",perm);
|
printf("[%s]",perm);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_dir(Ecma119Node *dir, int level)
|
print_dir(Ecma119Node *dir, int level)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char sp[level * 2 + 1];
|
char sp[level * 2 + 1];
|
||||||
|
|
||||||
for (i = 0; i < level * 2; i += 2) {
|
for (i = 0; i < level * 2; i += 2) {
|
||||||
sp[i] = '|';
|
sp[i] = '|';
|
||||||
sp[i+1] = ' ';
|
sp[i+1] = ' ';
|
||||||
}
|
}
|
||||||
|
|
||||||
sp[level * 2-1] = '-';
|
sp[level * 2-1] = '-';
|
||||||
sp[level * 2] = '\0';
|
sp[level * 2] = '\0';
|
||||||
|
|
||||||
for (i = 0; i < dir->info.dir.nchildren; i++) {
|
for (i = 0; i < dir->info.dir.nchildren; i++) {
|
||||||
Ecma119Node *child = dir->info.dir.children[i];
|
Ecma119Node *child = dir->info.dir.children[i];
|
||||||
|
|
||||||
if (child->type == ECMA119_DIR) {
|
if (child->type == ECMA119_DIR) {
|
||||||
printf("%s+[D] ", sp);
|
printf("%s+[D] ", sp);
|
||||||
print_permissions(iso_node_get_permissions(child->node));
|
print_permissions(iso_node_get_permissions(child->node));
|
||||||
printf(" %s\n", child->iso_name);
|
printf(" %s\n", child->iso_name);
|
||||||
print_dir(child, level+1);
|
print_dir(child, level+1);
|
||||||
} else if (child->type == ECMA119_FILE) {
|
} else if (child->type == ECMA119_FILE) {
|
||||||
printf("%s-[F] ", sp);
|
printf("%s-[F] ", sp);
|
||||||
print_permissions(iso_node_get_permissions(child->node));
|
print_permissions(iso_node_get_permissions(child->node));
|
||||||
printf(" %s {%p}\n", child->iso_name, (void*)child->info.file);
|
printf(" %s {%p}\n", child->iso_name, (void*)child->info.file);
|
||||||
} else {
|
} else if (child->type == ECMA119_SYMLINK) {
|
||||||
printf("%s-[????] ", sp);
|
printf("%s-[L] ", sp);
|
||||||
}
|
print_permissions(iso_node_get_permissions(child->node));
|
||||||
}
|
printf(" %s -> %s\n", child->iso_name,
|
||||||
|
((IsoSymlink*)child->node)->dest);
|
||||||
|
} else if (child->type == ECMA119_SPECIAL) {
|
||||||
|
printf("%s-[S] ", sp);
|
||||||
|
print_permissions(iso_node_get_permissions(child->node));
|
||||||
|
printf(" %s\n", child->iso_name);
|
||||||
|
} else {
|
||||||
|
printf("%s-[????] ", sp);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
IsoImage *image;
|
IsoImage *image;
|
||||||
Ecma119Image *ecma119;
|
Ecma119Image *ecma119;
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
printf ("You need to specify a valid path\n");
|
printf ("You need to specify a valid path\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = iso_image_new("volume_id", &image);
|
result = iso_image_new("volume_id", &image);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
printf ("Error creating image\n");
|
printf ("Error creating image\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
iso_image_set_msgs_severities(image, "NEVER", "ALL", "");
|
iso_image_set_msgs_severities(image, "NEVER", "ALL", "");
|
||||||
|
|
||||||
result = iso_tree_add_dir_rec(image, iso_image_get_root(image), argv[1]);
|
result = iso_tree_add_dir_rec(image, iso_image_get_root(image), argv[1]);
|
||||||
if (result < 0) {
|
if (result < 0) {
|
||||||
@ -95,7 +105,9 @@ int main(int argc, char **argv)
|
|||||||
ecma119 = calloc(1, sizeof(Ecma119Image));
|
ecma119 = calloc(1, sizeof(Ecma119Image));
|
||||||
iso_rbtree_new(iso_file_src_cmp, &(ecma119->files));
|
iso_rbtree_new(iso_file_src_cmp, &(ecma119->files));
|
||||||
ecma119->iso_level = 1;
|
ecma119->iso_level = 1;
|
||||||
|
ecma119->rockridge = 1;
|
||||||
ecma119->image = image;
|
ecma119->image = image;
|
||||||
|
ecma119->input_charset = strdup("UTF-8");
|
||||||
|
|
||||||
/* create low level tree */
|
/* create low level tree */
|
||||||
result = ecma119_tree_create(ecma119);
|
result = ecma119_tree_create(ecma119);
|
||||||
@ -105,10 +117,10 @@ int main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
printf("================= ECMA-119 TREE =================\n");
|
printf("================= ECMA-119 TREE =================\n");
|
||||||
print_dir(ecma119->root, 0);
|
print_dir(ecma119->root, 0);
|
||||||
printf("\n\n");
|
printf("\n\n");
|
||||||
|
|
||||||
ecma119_node_free(ecma119->root);
|
ecma119_node_free(ecma119->root);
|
||||||
iso_image_unref(image);
|
iso_image_unref(image);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -630,6 +630,7 @@ int ecma119_image_new(IsoImage *src, Ecma119WriteOpts *opts,
|
|||||||
iso_image_ref(src);
|
iso_image_ref(src);
|
||||||
|
|
||||||
target->iso_level = opts->level;
|
target->iso_level = opts->level;
|
||||||
|
target->rockridge = 1; //TODO
|
||||||
target->omit_version_numbers = opts->omit_version_numbers;
|
target->omit_version_numbers = opts->omit_version_numbers;
|
||||||
target->sort_files = opts->sort_files;
|
target->sort_files = opts->sort_files;
|
||||||
|
|
||||||
|
@ -29,6 +29,9 @@ struct ecma119_image {
|
|||||||
|
|
||||||
unsigned int iso_level:2;
|
unsigned int iso_level:2;
|
||||||
|
|
||||||
|
/* extensions */
|
||||||
|
unsigned int rockridge:1;
|
||||||
|
|
||||||
/* relaxed constraints */
|
/* relaxed constraints */
|
||||||
unsigned int omit_version_numbers:1;
|
unsigned int omit_version_numbers:1;
|
||||||
|
|
||||||
|
@ -151,6 +151,39 @@ int create_file(Ecma119Image *img, IsoFile *iso, Ecma119Node **node)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new ECMA-119 node representing a symbolic link from a iso symlink
|
||||||
|
* node.
|
||||||
|
*/
|
||||||
|
static
|
||||||
|
int create_symlink(Ecma119Image *img, IsoSymlink *iso, Ecma119Node **node)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = create_ecma119_node(img, (IsoNode*)iso, node);
|
||||||
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
(*node)->type = ECMA119_SYMLINK;
|
||||||
|
return ISO_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new ECMA-119 node representing a special file.
|
||||||
|
*/
|
||||||
|
static
|
||||||
|
int create_special(Ecma119Image *img, IsoSpecial *iso, Ecma119Node **node)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = create_ecma119_node(img, (IsoNode*)iso, node);
|
||||||
|
if (ret < 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
(*node)->type = ECMA119_SPECIAL;
|
||||||
|
return ISO_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
void ecma119_node_free(Ecma119Node *node)
|
void ecma119_node_free(Ecma119Node *node)
|
||||||
{
|
{
|
||||||
if (node == NULL) {
|
if (node == NULL) {
|
||||||
@ -165,7 +198,6 @@ void ecma119_node_free(Ecma119Node *node)
|
|||||||
}
|
}
|
||||||
free(node->iso_name);
|
free(node->iso_name);
|
||||||
iso_node_unref(node->node);
|
iso_node_unref(node->node);
|
||||||
//TODO? free(node->name);
|
|
||||||
free(node);
|
free(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,7 +229,7 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
max_path = pathlen + 1 + (iso_name ? strlen(iso_name) : 0);
|
max_path = pathlen + 1 + (iso_name ? strlen(iso_name) : 0);
|
||||||
if (1) { //TODO !rockridge && !relaxed_paths
|
if (!image->rockridge) { //TODO !rockridge && !relaxed_paths
|
||||||
if (depth > 8 || max_path > 255) {
|
if (depth > 8 || max_path > 255) {
|
||||||
iso_msg_note(image->image, LIBISO_FILE_IGNORED,
|
iso_msg_note(image->image, LIBISO_FILE_IGNORED,
|
||||||
"File \"%s\" can't be added, because depth > 8 "
|
"File \"%s\" can't be added, because depth > 8 "
|
||||||
@ -212,18 +244,26 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree,
|
|||||||
ret = create_file(image, (IsoFile*)iso, &node);
|
ret = create_file(image, (IsoFile*)iso, &node);
|
||||||
break;
|
break;
|
||||||
case LIBISO_SYMLINK:
|
case LIBISO_SYMLINK:
|
||||||
//TODO only supported with RR
|
if (image->rockridge) {
|
||||||
iso_msg_note(image->image, LIBISO_FILE_IGNORED, "File \"%s\" ignored. "
|
ret = create_symlink(image, (IsoSymlink*)iso, &node);
|
||||||
"Symlinks need RockRidge extensions.", iso->name);
|
} else {
|
||||||
free(iso_name);
|
/* symlinks are only supported when RR is enabled */
|
||||||
return 0;
|
iso_msg_note(image->image, LIBISO_FILE_IGNORED, "File \"%s\" "
|
||||||
|
"ignored. Symlinks need RockRidge extensions.",
|
||||||
|
iso->name);
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case LIBISO_SPECIAL:
|
case LIBISO_SPECIAL:
|
||||||
iso_msg_note(image->image, LIBISO_FILE_IGNORED, "File \"%s\" ignored. "
|
if (image->rockridge) {
|
||||||
"Special files need RockRidge extensions.", iso->name);
|
ret = create_special(image, (IsoSpecial*)iso, &node);
|
||||||
//TODO only supported with RR
|
} else {
|
||||||
free(iso_name);
|
/* symlinks are only supported when RR is enabled */
|
||||||
return 0;
|
iso_msg_note(image->image, LIBISO_FILE_IGNORED, "File \"%s\" "
|
||||||
|
"ignored. Special files need RockRidge extensions.",
|
||||||
|
iso->name);
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case LIBISO_BOOT:
|
case LIBISO_BOOT:
|
||||||
//TODO
|
//TODO
|
||||||
|
@ -14,7 +14,10 @@
|
|||||||
|
|
||||||
enum ecma119_node_type {
|
enum ecma119_node_type {
|
||||||
ECMA119_FILE,
|
ECMA119_FILE,
|
||||||
ECMA119_DIR
|
ECMA119_DIR,
|
||||||
|
ECMA119_SYMLINK,
|
||||||
|
ECMA119_SPECIAL,
|
||||||
|
ECMA119_PLACEHOLDER
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user