Commit d2f90e9d authored by Dominique Dumont's avatar Dominique Dumont

Import Upstream version 0.6.6

parent d3bf4bb0
......@@ -5,9 +5,8 @@ Copyright (C) 2007-2008 Vreixo Formoso, Mario Danic, Thomas Schmitt
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
......
......@@ -16,6 +16,7 @@ libisofs_libisofs_la_SOURCES = \
libisofs/node.c \
libisofs/tree.h \
libisofs/tree.c \
libisofs/find.c \
libisofs/image.h \
libisofs/image.c \
libisofs/fsource.h \
......@@ -28,6 +29,9 @@ libisofs_libisofs_la_SOURCES = \
libisofs/libiso_msgs.c \
libisofs/stream.h \
libisofs/stream.c \
libisofs/filter.h \
libisofs/filter.c \
libisofs/filters/xor_encrypt.c \
libisofs/util.h \
libisofs/util.c \
libisofs/util_rbtree.c \
......@@ -51,6 +55,8 @@ libisofs_libisofs_la_SOURCES = \
libisofs/iso1999.h \
libisofs/iso1999.c \
libisofs/data_source.c
libisofs_libisofs_la_LIBADD= \
$(THREAD_LIBS)
libinclude_HEADERS = \
libisofs/libisofs.h
......@@ -62,6 +68,7 @@ noinst_PROGRAMS = \
demo/cat \
demo/catbuffer \
demo/tree \
demo/find \
demo/ecma119tree \
demo/iso \
demo/isoread \
......@@ -86,6 +93,10 @@ demo_tree_CPPFLAGS = -Ilibisofs
demo_tree_LDADD = $(libisofs_libisofs_la_OBJECTS) $(THREAD_LIBS)
demo_tree_SOURCES = demo/tree.c
demo_find_CPPFLAGS = -Ilibisofs
demo_find_LDADD = $(libisofs_libisofs_la_OBJECTS) $(THREAD_LIBS)
demo_find_SOURCES = demo/find.c
demo_ecma119tree_CPPFLAGS = -Ilibisofs
demo_ecma119tree_LDADD = $(libisofs_libisofs_la_OBJECTS) $(THREAD_LIBS)
demo_ecma119tree_SOURCES = demo/ecma119_tree.c
......
This diff is collapsed.
== Sun Apr 27 2008 ==
Libisofs v0.6.4
===============
- Extended information: iso_node_add_xinfo()
- New node iteration: iso_dir_find_children()
- Custom image file content via iso_tree_add_new_file()
- Missing feature added to map a disk file to an
arbitrary image file path via iso_tree_add_new_node()
- Obtain image path of a node object via iso_tree_get_node_path()
- Various bugfixes
== Fri Feb 22 2008 ==
Libisofs v0.6.2.1
......
......@@ -9,7 +9,6 @@ TODO
#00004 (libisofs.h) -> Add a get_mime_type() function.
#00005 (node.c) -> optimize iso_dir_iter_take.
#00006 (libisofs.h) -> define more replace values when adding a node to a dir
#00007 (libisofs.h) -> expose iso_tree_add_new_file
#00008 (data_dource.c) -> guard against partial reads
#00009 (ecma119_tree.c/h) -> add true support for harlinks and inode numbers
#00010 (buffer.c) -> optimize ring buffer
......
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.61 for libisofs 0.6.2.1.
# Generated by GNU Autoconf 2.61 for libisofs 0.6.6.
#
# Report bugs to <http://libburnia-project.org>.
#
......@@ -728,8 +728,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='libisofs'
PACKAGE_TARNAME='libisofs'
PACKAGE_VERSION='0.6.2.1'
PACKAGE_STRING='libisofs 0.6.2.1'
PACKAGE_VERSION='0.6.6'
PACKAGE_STRING='libisofs 0.6.6'
PACKAGE_BUGREPORT='http://libburnia-project.org'
ac_default_prefix=/usr/local
......@@ -1413,7 +1413,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures libisofs 0.6.2.1 to adapt to many kinds of systems.
\`configure' configures libisofs 0.6.6 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
......@@ -1484,7 +1484,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of libisofs 0.6.2.1:";;
short | recursive ) echo "Configuration of libisofs 0.6.6:";;
esac
cat <<\_ACEOF
......@@ -1591,7 +1591,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
libisofs configure 0.6.2.1
libisofs configure 0.6.6
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
......@@ -1605,7 +1605,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by libisofs $as_me 0.6.2.1, which was
It was created by libisofs $as_me 0.6.6, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
......@@ -2424,7 +2424,7 @@ fi
# Define the identity of the package.
PACKAGE='libisofs'
VERSION='0.6.2.1'
VERSION='0.6.6'
cat >>confdefs.h <<_ACEOF
......@@ -2574,7 +2574,7 @@ am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
LIBISOFS_MAJOR_VERSION=0
LIBISOFS_MINOR_VERSION=6
LIBISOFS_MICRO_VERSION=2.1
LIBISOFS_MICRO_VERSION=6
LIBISOFS_VERSION=$LIBISOFS_MAJOR_VERSION.$LIBISOFS_MINOR_VERSION.$LIBISOFS_MICRO_VERSION
......@@ -2584,9 +2584,9 @@ LIBISOFS_VERSION=$LIBISOFS_MAJOR_VERSION.$LIBISOFS_MINOR_VERSION.$LIBISOFS_MICRO
LT_RELEASE=$LIBISOFS_MAJOR_VERSION.$LIBISOFS_MINOR_VERSION
# SONAME = 6 - 0 = 6 . Library name = libisofs.6.0.0
LT_CURRENT=6
LT_CURRENT=7
LT_REVISION=0
LT_AGE=0
LT_AGE=1
LT_CURRENT_MINUS_AGE=`expr $LT_CURRENT - $LT_AGE`
......@@ -21954,7 +21954,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by libisofs $as_me 0.6.2.1, which was
This file was extended by libisofs $as_me 0.6.6, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
......@@ -22001,7 +22001,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
libisofs config.status 0.6.2.1
libisofs config.status 0.6.6
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
......
AC_INIT([libisofs], [0.6.2.1], [http://libburnia-project.org])
AC_INIT([libisofs], [0.6.6], [http://libburnia-project.org])
AC_PREREQ([2.50])
dnl AC_CONFIG_HEADER([config.h])
......@@ -44,7 +44,7 @@ dnl If LIBISOFS_*_VERSION changes, be sure to change AC_INIT above to match.
dnl
LIBISOFS_MAJOR_VERSION=0
LIBISOFS_MINOR_VERSION=6
LIBISOFS_MICRO_VERSION=2.1
LIBISOFS_MICRO_VERSION=6
LIBISOFS_VERSION=$LIBISOFS_MAJOR_VERSION.$LIBISOFS_MINOR_VERSION.$LIBISOFS_MICRO_VERSION
AC_SUBST(LIBISOFS_MAJOR_VERSION)
......@@ -55,9 +55,9 @@ AC_SUBST(LIBISOFS_VERSION)
dnl Libtool versioning
LT_RELEASE=$LIBISOFS_MAJOR_VERSION.$LIBISOFS_MINOR_VERSION
# SONAME = 6 - 0 = 6 . Library name = libisofs.6.0.0
LT_CURRENT=6
LT_CURRENT=7
LT_REVISION=0
LT_AGE=0
LT_AGE=1
LT_CURRENT_MINUS_AGE=`expr $LT_CURRENT - $LT_AGE`
AC_SUBST(LT_RELEASE)
......
/*
* Little program that import a directory, find matching nodes and prints the
* resulting iso tree.
*/
#include "libisofs.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
static void
print_dir(IsoDir *dir)
{
IsoDirIter *iter;
IsoNode *node;
IsoFindCondition *cond, *c1, *c2;
c1 = iso_new_find_conditions_name("*a*");
c2 = iso_new_find_conditions_mode(S_IFREG);
cond = iso_new_find_conditions_and(c1, c2);
iso_dir_find_children(dir, cond, &iter);
while (iso_dir_iter_next(iter, &node) == 1) {
char *path = iso_tree_get_node_path(node);
printf(" %s\n", path);
free(path);
}
iso_dir_iter_free(iter);
}
int main(int argc, char **argv)
{
int result;
IsoImage *image;
if (argc != 2) {
printf ("You need to specify a valid path\n");
return 1;
}
iso_init();
iso_set_msgs_severities("NEVER", "ALL", "");
result = iso_image_new("volume_id", &image);
if (result < 0) {
printf ("Error creating image\n");
return 1;
}
result = iso_tree_add_dir_rec(image, iso_image_get_root(image), argv[1]);
if (result < 0) {
printf ("Error adding directory %d\n", result);
return 1;
}
print_dir(iso_image_get_root(image));
iso_image_unref(image);
iso_finish();
return 0;
}
......@@ -52,12 +52,13 @@ int default_create_file(IsoNodeBuilder *builder, IsoImage *image,
if (ret < 0) {
return ret;
}
/* take a ref to the src, as stream has taken our ref */
iso_file_source_ref(src);
name = iso_file_source_get_name(src);
ret = iso_node_new_file(name, stream, &node);
if (ret < 0) {
/* the stream has taken our ref to src, so we need to add one */
iso_file_source_ref(src);
iso_stream_unref(stream);
free(name);
return ret;
......
......@@ -34,8 +34,7 @@ struct Iso_Node_Builder
* In that case, if the implementation can't do the conversion, it
* should fail propertly.
*
* On sucess, the ref. to src will be owned by file, so you musn't
* unref it.
* Note that the src is never unref, so you need to free it.
*
* @return
* 1 on success, < 0 on error
......
......@@ -57,7 +57,7 @@ int ds_open(IsoDataSource *src)
data = (struct file_data_src*) src->data;
if (data->fd != -1) {
return ISO_FILE_ALREADY_OPENNED;
return ISO_FILE_ALREADY_OPENED;
}
fd = open(data->path, O_RDONLY);
......@@ -81,7 +81,7 @@ int ds_close(IsoDataSource *src)
data = (struct file_data_src*) src->data;
if (data->fd == -1) {
return ISO_FILE_NOT_OPENNED;
return ISO_FILE_NOT_OPENED;
}
/* close can fail if fd is not valid, but that should never happen */
......@@ -102,7 +102,7 @@ static int ds_read_block(IsoDataSource *src, uint32_t lba, uint8_t *buffer)
data = (struct file_data_src*) src->data;
if (data->fd == -1) {
return ISO_FILE_NOT_OPENNED;
return ISO_FILE_NOT_OPENED;
}
/* goes to requested block */
......
......@@ -538,7 +538,7 @@ int catalog_open(IsoStream *stream)
data = stream->data;
if (data->offset != -1) {
return ISO_FILE_ALREADY_OPENNED;
return ISO_FILE_ALREADY_OPENED;
}
memset(data->buffer, 0, BLOCK_SIZE);
......@@ -563,7 +563,7 @@ int catalog_close(IsoStream *stream)
data = stream->data;
if (data->offset == -1) {
return ISO_FILE_NOT_OPENNED;
return ISO_FILE_NOT_OPENED;
}
data->offset = -1;
return ISO_SUCCESS;
......@@ -589,7 +589,7 @@ int catalog_read(IsoStream *stream, void *buf, size_t count)
data = stream->data;
if (data->offset == -1) {
return ISO_FILE_NOT_OPENNED;
return ISO_FILE_NOT_OPENED;
}
len = MIN(count, BLOCK_SIZE - data->offset);
......@@ -617,12 +617,6 @@ void catalog_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id,
*ino_id = 0;
}
static
char *catalog_get_name(IsoStream *stream)
{
return strdup("El-Torito Boot Catalog");
}
static
void catalog_free(IsoStream *stream)
{
......@@ -630,13 +624,14 @@ void catalog_free(IsoStream *stream)
}
IsoStreamIface catalog_stream_class = {
0,
"boot",
catalog_open,
catalog_close,
catalog_get_size,
catalog_read,
catalog_is_repeatable,
catalog_get_id,
catalog_get_name,
catalog_free
};
......
......@@ -15,6 +15,7 @@
#include <stdlib.h>
#include <string.h>
#include <limits.h>
int iso_file_src_cmp(const void *n1, const void *n2)
{
......@@ -243,7 +244,7 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
Ecma119Image *t;
IsoFileSrc *file;
IsoFileSrc **filelist;
char *name;
char name[PATH_MAX];
char buffer[BLOCK_SIZE];
if (writer == NULL) {
......@@ -266,15 +267,15 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
uint32_t nblocks = DIV_UP(iso_file_src_get_size(file), BLOCK_SIZE);
res = filesrc_open(file);
iso_stream_get_file_name(file->stream, name);
if (res < 0) {
/*
* UPS, very ugly error, the best we can do is just to write
* 0's to image
*/
name = iso_stream_get_name(file->stream);
iso_report_errfile(name, ISO_FILE_CANT_WRITE, 0, 0);
res = iso_msg_submit(t->image->id, ISO_FILE_CANT_WRITE, res,
"File \"%s\" can't be opened. Filling with 0s.", name);
free(name);
if (res < 0) {
return res; /* aborted due to error severity */
}
......@@ -288,11 +289,10 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
}
continue;
} else if (res > 1) {
name = iso_stream_get_name(file->stream);
iso_report_errfile(name, ISO_FILE_CANT_WRITE, 0, 0);
res = iso_msg_submit(t->image->id, ISO_FILE_CANT_WRITE, 0,
"Size of file \"%s\" has changed. It will be %s", name,
(res == 2 ? "truncated" : "padded with 0's"));
free(name);
if (res < 0) {
filesrc_close(file);
return res; /* aborted due to error severity */
......@@ -300,9 +300,7 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
}
#ifdef LIBISOFS_VERBOSE_DEBUG
else {
name = iso_stream_get_name(file->stream);
iso_msg_debug(t->image->id, "Writing file %s", name);
free(name);
}
#endif
......@@ -326,7 +324,7 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
if (b < nblocks) {
/* premature end of file, due to error or eof */
char *name = iso_stream_get_name(file->stream);
iso_report_errfile(name, ISO_FILE_CANT_WRITE, 0, 0);
if (res < 0) {
/* error */
res = iso_msg_submit(t->image->id, ISO_FILE_CANT_WRITE, res,
......@@ -336,7 +334,6 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
res = iso_msg_submit(t->image->id, ISO_FILE_CANT_WRITE, 0,
"Premature end of file %s.", name);
}
free(name);
if (res < 0) {
return res; /* aborted due error severity */
......
/*
* Copyright (c) 2008 Vreixo Formoso
*
* This file is part of the libisofs project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. See COPYING file for details.
*/
#include "libisofs.h"
#include "filter.h"
#include "node.h"
void iso_filter_ref(FilterContext *filter)
{
++filter->refcount;
}
void iso_filter_unref(FilterContext *filter)
{
if (--filter->refcount == 0) {
filter->free(filter);
free(filter);
}
}
int iso_file_add_filter(IsoFile *file, FilterContext *filter, int flag)
{
int ret;
IsoStream *original, *filtered;
if (file == NULL || filter == NULL) {
return ISO_NULL_POINTER;
}
original = file->stream;
if (!iso_stream_is_repeatable(original)) {
/* TODO use custom error */
return ISO_WRONG_ARG_VALUE;
}
ret = filter->get_filter(filter, original, &filtered);
if (ret < 0) {
return ret;
}
iso_stream_unref(original);
file->stream = filtered;
return ISO_SUCCESS;
}
/*
* Copyright (c) 2008 Vreixo Formoso
*
* This file is part of the libisofs project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. See COPYING file for details.
*/
#ifndef LIBISO_FILTER_H_
#define LIBISO_FILTER_H_
/*
* Definitions of filters.
*/
/* dev_id for stream identification */
#define XOR_ENCRYPT_DEV_ID 1
typedef struct filter_context FilterContext;
struct filter_context {
int version; /* reserved for future usage, set to 0 */
int refcount;
/** filter specific shared data */
void *data;
/**
* Factory method to create a filtered stream from another stream.
*
* @param original
* The original stream to be filtered. If the filter needs a ref to
* it (most cases), it should take a ref to it with iso_stream_ref().
* @param filtered
* Will be filled with the filtered IsoStream (reference belongs to
* caller).
* @return
* 1 on success, < 0 on error
*/
int (*get_filter)(FilterContext *filter, IsoStream *original,
IsoStream **filtered);
/**
* Free implementation specific data. Should never be called by user.
* Use iso_filter_unref() instead.
*/
void (*free)(FilterContext *filter);
};
/**
*
* @param flag
* Reserved for future usage, pass always 0 for now.
* TODO in a future a different value can mean filter caching, where
* the filter is applied once and the filtered file is stored in a temp
* dir. This prevent filter to be applied several times.
*/
int iso_file_add_filter(IsoFile *file, FilterContext *filter, int flag);
void iso_filter_ref(FilterContext *filter);
void iso_filter_unref(FilterContext *filter);
#endif /*LIBISO_FILTER_H_*/
/*
* Copyright (c) 2008 Vreixo Formoso
*
* This file is part of the libisofs project; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation. See COPYING file for details.
*/
#include "../libisofs.h"
#include "../filter.h"
#include "../fsource.h"
/*
* A simple Filter implementation for example purposes. It encrypts a file
* by XORing each byte by a given key.
*/
static ino_t xor_ino_id = 0;
typedef struct
{
IsoStream *orig;
uint8_t key;
ino_t id;
} XorEncryptStreamData;
static
int xor_encrypt_stream_open(IsoStream *stream)
{
XorEncryptStreamData *data;
if (stream == NULL) {
return ISO_NULL_POINTER;
}
data = (XorEncryptStreamData*)stream->data;
return iso_stream_open(data->orig);
}
static
int xor_encrypt_stream_close(IsoStream *stream)
{
XorEncryptStreamData *data;
if (stream == NULL) {
return ISO_NULL_POINTER;
}
data = stream->data;
return iso_stream_close(data->orig);
}
static
off_t xor_encrypt_stream_get_size(IsoStream *stream)
{
XorEncryptStreamData *data;
if (stream == NULL) {
return ISO_NULL_POINTER;
}
data = stream->data;
return iso_stream_get_size(data->orig);
}
static
int xor_encrypt_stream_read(IsoStream *stream, void *buf, size_t count)
{
int ret, len;
XorEncryptStreamData *data;
uint8_t *buffer = buf;
if (stream == NULL) {
return ISO_NULL_POINTER;
}
data = stream->data;
ret = iso_stream_read(data->orig, buf, count);
if (ret < 0) {
return ret;
}
/* xor */
for (len = 0; len < ret; ++len) {
buffer[len] = buffer[len] ^ data->key;
}
return ret;
}
static
int xor_encrypt_stream_is_repeatable(IsoStream *stream)
{
/* the filter can't be created if underlying stream is not repeatable */
return 1;
}
static
void xor_encrypt_stream_get_id(IsoStream *stream, unsigned int *fs_id,
dev_t *dev_id, ino_t *ino_id)
{
XorEncryptStreamData *data = stream->data;
*fs_id = ISO_FILTER_FS_ID;
*dev_id = XOR_ENCRYPT_DEV_ID;
*ino_id = data->id;
}
static
void xor_encrypt_stream_free(IsoStream *stream)
{
XorEncryptStreamData *data = stream->data;
iso_stream_unref(data->orig);
free(data);
}
IsoStreamIface xor_encrypt_stream_class = {
0,
"xorf",
xor_encrypt_stream_open,
xor_encrypt_stream_close,
xor_encrypt_stream_get_size,
xor_encrypt_stream_read,
xor_encrypt_stream_is_repeatable,
xor_encrypt_stream_get_id,
xor_encrypt_stream_free
};
static
void xor_encrypt_filter_free(FilterContext *filter)
{
free(filter->data);
}
static
int xor_encrypt_filter_get_filter(FilterContext *filter, IsoStream *original,
IsoStream **filtered)
{
IsoStream *str;
XorEncryptStreamData *data;
if (filter == NULL || original == NULL || filtered == NULL) {
return ISO_NULL_POINTER;
}
str = malloc(sizeof(IsoStream));
if (str == NULL) {
return ISO_OUT_OF_MEM;
}
data = malloc(sizeof(XorEncryptStreamData));
if (str == NULL) {
free(str);
return ISO_OUT_OF_MEM;
}
/* fill data */
data->key = *((uint8_t*)filter->data);
data->id = xor_ino_id++;
/* get reference to the source */
data->orig = original;
iso_stream_ref(original);
str->refcount = 1;
str->data = data;
str->class = &xor_encrypt_stream_class;
*filtered = str;
return ISO_SUCCESS;
}
int create_xor_encrypt_filter(uint8_t key, FilterContext **filter)
{
FilterContext *f;
uint8_t *data;
f = calloc(1, sizeof(FilterContext));
if (f == NULL) {
return ISO_OUT_OF_MEM;
}
data = malloc(sizeof(uint8_t));
if (data == NULL) {
free(f);
return ISO_OUT_OF_MEM;
}
f->refcount = 1;
f->version = 0;
*data = key;
f->data = data;
f->free = xor_encrypt_filter_free;
f->get_filter = xor_encrypt_filter_get_filter;
return ISO_SUCCESS;
}
This diff is collapsed.
......@@ -474,7 +474,7 @@ int ifs_open(IsoFileSource *src)