[prev in list] [next in list] [prev in thread] [next in thread] 

List:       klik-devel
Subject:    [klik-devel] [klikclient commit] r1682 -
From:       codesite-noreply () google ! com
Date:       2008-08-29 14:37:08
Message-ID: 0015175ce10e2b84fc04559a3019 () google ! com
[Download RAW message or body]

Author: cristian.debian
Date: Fri Aug 29 07:36:20 2008
New Revision: 1682

Added:
    branches/cristian/fusioniso/fusioniso/src/fusioniso.h
Modified:
    branches/cristian/fusioniso/fusioniso/src/Makefile.am
    branches/cristian/fusioniso/fusioniso/src/fusioniso.c
    branches/cristian/fusioniso/fusioniso/src/fusioniso_fs.c
    branches/cristian/fusioniso/fusioniso/src/fusioniso_fs.h
    branches/cristian/fusioniso/fusioniso/src/fusioniso_isofs.c
    branches/cristian/fusioniso/fusioniso/src/fusioniso_isofs.h

Log:
WARNING: maintain_mtab functions are temporary disabled.

Delete all global variables from src/*.c files and move them to a new  
struct in
src/fusioniso.h. This struct is initialized in main() and passed to  
fuse_main()
call. The new fs_init() function make data availables to all fuse functions
through fuse_get_context()->private_data.
Required merge isofs_real_preinit() and isofs_real_init() into new
isofs_init(), and changes to isofs_check_rr() and isofs_read_raw_block()
prototypes.
This is the right way to use fuse "private_data", and this way umview can  
mount
different images at the same time.


Modified: branches/cristian/fusioniso/fusioniso/src/Makefile.am
==============================================================================
--- branches/cristian/fusioniso/fusioniso/src/Makefile.am	(original)
+++ branches/cristian/fusioniso/fusioniso/src/Makefile.am	Fri Aug 29  
07:36:20 2008
@@ -16,7 +16,7 @@
  bin_PROGRAMS = fusioniso
  mod_LTLIBRARIES = umfuse_fusioniso.la

-noinst_HEADERS = fusioniso_fs.h fusioniso_isofs.h fusioniso_debug.h
+noinst_HEADERS = fusioniso.h fusioniso_fs.h fusioniso_isofs.h  
fusioniso_debug.h

  fusioniso_SOURCES = $(COMMONSOURCES)
  fusioniso_LDFLAGS = $(GLIB2_LIBS) $(FUSE_LIBS) -lz -lpthread

Modified: branches/cristian/fusioniso/fusioniso/src/fusioniso.c
==============================================================================
--- branches/cristian/fusioniso/fusioniso/src/fusioniso.c	(original)
+++ branches/cristian/fusioniso/fusioniso/src/fusioniso.c	Fri Aug 29  
07:36:20 2008
@@ -50,12 +50,9 @@
  #include <langinfo.h>
  #include <sys/param.h>
  #include <sys/types.h>
-#include <fuse.h>

-#include "fusioniso_fs.h" // fs_real_*
-#include "fusioniso_isofs.h" // isofs_real_preinit and isofs_real_init
  #include "fusioniso_debug.h"
-
+#include "fusioniso.h"

  #ifdef __GNUC__
  # define UNUSED(x) x __attribute__((unused))
@@ -63,28 +60,6 @@
  # define UNUSED(x) x
  #endif

-typedef struct fuse_file_info struct_file_info;
-
-static char *imagefile = NULL;
-static int image_fd = -1;
-
-int maintain_mount_point;
-int maintain_mtab;
-
-char *extern_iocharset;                                               //  
specify iocharset for Joliet filesystem
-char *extern_mount_point = NULL;                                      //  
mounting point
-bool extern_union_mounting;                                           //  
if true, we want to union-mount the data
-sandbox_type extern_sandbox_mounting;                                 //  
in case we want to sandbox the application
-char* extern_redirect_path;                                           //  
~$HOME directory
-int   extern_size_redirect_path;                                      //  
Size of the ~$HOME directory
-char* extern_sandbox_path;                                            //  
Directory where to redirect write (sandboxing)
-int   extern_size_sandbox_path;                                       //  
Size of the directory where to redirect write
-char* extern_exclude_list[32];                                        //  
We want to exclude some directories in case of sandboxing
-int   extern_exclude_length[32];                                      //  
Size of each directory to exclude (exclude list)
-int   extern_list_max;                                                //  
Number of directories (exclude list)
-char* extern_base_root;
-int   extern_base_root_length;
-bool  extern_glibc;                                                   //  
If true, change the loader on the fly

  char* normalize_name(const char* fname)
  {
@@ -94,6 +69,7 @@
      return abs_fname;
  }

+#if 0
  int check_mount_point()
  {
      struct stat st;
@@ -266,6 +242,7 @@
      free(mtab_path);
      return 0;
  }
+#endif

  static int fs_getattr(const char *path, struct stat *stbuf)
  {
@@ -400,6 +377,7 @@
      return 0;
  }

+#if 0
  static void* fs_init()
  {
      int rc;
@@ -419,6 +397,7 @@
      if (maintain_mtab) del_mtab_record();
      return;
  }
+#endif

  static int fs_opendir(const char *path, struct fuse_file_info *UNUSED(fi))
  {
@@ -436,6 +415,14 @@
      return fs_real_statfs(path, stbuf);
  }

+
+static void *fs_init(struct fuse_conn_info *conn)
+{
+	struct fuse_context *mycontext=fuse_get_context();
+	return mycontext->private_data;
+}
+
+
  static struct fuse_operations fs_oper = {
      .getattr        = fs_getattr,
      .readlink       = fs_readlink,
@@ -443,7 +430,7 @@
      .read           = fs_read,
      .flush          = fs_flush,
      .init           = fs_init,
-    .destroy        = fs_destroy,
+    //.destroy        = fs_destroy,
      .opendir        = fs_opendir,
      .readdir        = fs_readdir,
      .statfs         = fs_statfs,
@@ -456,7 +443,7 @@
      .read		= fs_read,
      .flush		= fs_flush,
      .init		= fs_init,
-    .destroy		= fs_destroy,
+    //.destroy		= fs_destroy,
      .opendir		= fs_opendir,
      .readdir		= fs_readdir,
      .statfs		= fs_statfs,
@@ -507,19 +494,31 @@

  int main(int argc, char *argv[])
  {
-    char *env;
-    int i,j;
-    char* pw_dir = NULL;                                              //  
Home directory
-    struct passwd* passwd = NULL;
-    setlocale(LC_ALL, "");                                            //  
set current locale for proper iocharset
+    int i, j, rc;
+    char c, *imagefile, *env, *pw_dir=NULL;
+    struct passwd* passwd=NULL;
+    fusioniso_data *data;
+    isofs_inode *root_inode;
+
+    setlocale(LC_ALL, "");  // set current locale for proper iocharset
+
+    data = malloc(sizeof(fusioniso_data));
+    if (!data) {
+        FSWARNING("can\'t malloc: %s",strerror(errno));
+	exit(EXIT_FAILURE);
+    }

      // defaults
-    maintain_mount_point = 0;
-    maintain_mtab = 1;
-    extern_iocharset = NULL;
-    extern_union_mounting = false;
-    extern_sandbox_mounting = sandbox_none;
-    extern_glibc = false;
+    data->maintain_mountpoint=0;
+    data->maintain_mtab=1;
+    data->iocharset=NULL;
+    data->union_mounting=false;
+    data->sandbox_mounting=sandbox_none;
+    data->glibc=false;
+    data->lookup_table          = g_hash_table_new(g_str_hash,  
g_str_equal);
+    data->real_lookup_table     = g_hash_table_new(g_str_hash,  
g_str_equal);
+    data->removed_lookup_table  = g_hash_table_new(g_str_hash,  
g_str_equal);
+    data->negative_lookup_table = g_hash_table_new(g_str_hash,  
g_str_equal);

      // Home directory
      passwd = getpwuid(getuid());
@@ -528,13 +527,12 @@
          pw_dir = strdup(passwd->pw_dir);
      }

-    char c;
      while ((c = getopt(argc, argv, "+npuht:gc:b:B:d:")) > 0)
      {
          switch (c)
          {
              case 'g':
-                extern_glibc = true;
+                data->glibc = true;
                  break;
  #ifdef _DEBUG
              case 't':
@@ -544,15 +542,15 @@
                  break;
  #endif
              case 'n':
-                maintain_mtab = 0;
+                data->maintain_mtab = 0;
                  break;

              case 'p':
-                maintain_mount_point = 1;
+                data->maintain_mountpoint = 1;
                  break;

              case 'c':
-                if (optarg) extern_iocharset=optarg;
+                if (optarg) data->iocharset=optarg;
                  break;

              case 'h':
@@ -561,52 +559,52 @@
                  break;

              case 'u':
-                extern_union_mounting = true;
+                data->union_mounting = true;
                  break;

              case 'b':
-                extern_union_mounting = true;
-                extern_sandbox_mounting = sandbox_home;
+                data->union_mounting = true;
+                data->sandbox_mounting = sandbox_home;
                  if (optarg)
                  {
-                    extern_sandbox_path = optarg;
-                    extern_size_sandbox_path = strlen(extern_sandbox_path);
+                    data->sandbox_path = optarg;
+                    data->sandbox_path_size = strlen(data->sandbox_path);
                      if (pw_dir != NULL)
                      {
-                        extern_size_redirect_path = strlen(pw_dir);
-                        extern_redirect_path =  
malloc(extern_size_redirect_path+1);
-                        strcpy(extern_redirect_path, pw_dir);
+                        data->redirect_path_size = strlen(pw_dir);
+                        data->redirect_path =  
malloc(data->redirect_path_size+1);
+                        strcpy(data->redirect_path, pw_dir);
                      }
                  }
                  break;

              case 'd':
-                extern_union_mounting = true;
-                extern_sandbox_mounting = sandbox_portable;
+                data->union_mounting = true;
+                data->sandbox_mounting = sandbox_portable;
                  if (optarg)
                  {
-                    extern_sandbox_path=optarg;
-                    extern_size_sandbox_path = strlen(extern_sandbox_path);
+                    data->sandbox_path=optarg;
+                    data->sandbox_path_size = strlen(data->sandbox_path);
                      if (pw_dir != NULL)
                      {
-                        extern_size_redirect_path = strlen(pw_dir);
-                        extern_redirect_path =  
malloc(extern_size_redirect_path+3);
-                        strcpy(extern_redirect_path, pw_dir);
-                        strcat(extern_redirect_path,  "/.");
+                        data->redirect_path_size = strlen(pw_dir);
+                        data->redirect_path =  
malloc(data->redirect_path_size+3);
+                        strcpy(data->redirect_path, pw_dir);
+                        strcat(data->redirect_path,  "/.");
                      }
                  }
                  break;

              case 'B':
-                extern_union_mounting = true;
-                extern_sandbox_mounting = sandbox_data;
+                data->union_mounting = true;
+                data->sandbox_mounting = sandbox_data;
                  if (optarg)
                  {
-                    extern_sandbox_path=optarg;
-                    extern_size_sandbox_path = strlen(extern_sandbox_path);
-                    extern_redirect_path = malloc(2);
-                    extern_size_redirect_path = 1;
-                    strcpy(extern_redirect_path, "/");
+                    data->sandbox_path=optarg;
+                    data->sandbox_path_size = strlen(data->sandbox_path);
+                    data->redirect_path = malloc(2);
+                    data->redirect_path_size = 1;
+                    strcpy(data->redirect_path, "/");
                  }
                  break;
              case '?':
@@ -624,15 +622,7 @@
      }

      imagefile = normalize_name(argv[optind]);
-
-    image_fd = open(imagefile, O_RDONLY);
-    if (image_fd == -1)
-    {
-	FSWARNING("cannot open image file \"%s\"",imagefile);
-        exit(EXIT_FAILURE);
-    }
-
-    extern_mount_point = normalize_name(argv[optind + 1]);
+    data->mountpoint = normalize_name(argv[optind + 1]);

      // with space for possible -o use_ino arguments
      char **nargv = (char **) malloc((argc + 2) * sizeof(char *));
@@ -675,18 +665,19 @@
          nargc++;
      }

-    if (!extern_iocharset)
+    if (!data->iocharset)
      {
          char *nlcharset = nl_langinfo(CODESET);
          if (nlcharset)
          {
-            extern_iocharset = (char *) malloc(strlen(nlcharset) + 9);
-            strcpy(extern_iocharset, nlcharset);
-            strcat(extern_iocharset, "//IGNORE");
+            data->iocharset = (char *) malloc(strlen(nlcharset) + 9);
+            strcpy(data->iocharset, nlcharset);
+            strcat(data->iocharset, "//IGNORE");
          }
-        if (!extern_iocharset) extern_iocharset="UTF-8//IGNORE";
+        if (!data->iocharset) data->iocharset="UTF-8//IGNORE";
      }

+#if 0
      int rc;
      if (maintain_mount_point)
      {
@@ -702,35 +693,50 @@
              exit(EXIT_FAILURE);
          }
      }
+#endif

      // will exit in case of failure
-    rc = isofs_real_preinit(imagefile, image_fd);
+    rc=isofs_init(imagefile,&data->isofs);
+    if (rc<0)
+        exit(EXIT_FAILURE);
+
+    root_inode=(isofs_inode *) malloc(sizeof(isofs_inode));
+    if (!root_inode) {
+        FSWARNING("can\'t malloc: %s",strerror(errno));
+	exit(EXIT_FAILURE);
+    }
+
+    memset(root_inode,0,sizeof(isofs_inode));
+    root_inode->record=data->isofs->root;
+    root_inode->st_ino=1;
+    g_hash_table_insert(data->lookup_table,(char*) "/",root_inode);
+    data->isofs->last_ino=2;

      // We get a list of directories or files
      env = getenv("FAKECHROOT_EXCLUDE_PATH");
      if (env)
      {
-        for (extern_list_max=0,i=0; extern_list_max<32;)
+        for (data->exclude_list_max=0,i=0; data->exclude_list_max<32; )
          {
              for (j=i; env[j]!=':'&&env[j]!='\0'; j++);
-            extern_exclude_list[extern_list_max] = malloc(j-i+2);
-            memset(extern_exclude_list[extern_list_max], '\0', j-i+2);
-            strncpy(extern_exclude_list[extern_list_max], &(env[i]), j-i);
-            extern_exclude_length[extern_list_max] =  
strlen(extern_exclude_list[extern_list_max]);
-            extern_list_max++;
+            data->exclude_list[data->exclude_list_max] = malloc(j-i+2);
+            memset(data->exclude_list[data->exclude_list_max], '\0',  
j-i+2);
+            strncpy(data->exclude_list[data->exclude_list_max], &(env[i]),  
j-i);
+            data->exclude_list_size[data->exclude_list_max] =  
strlen(data->exclude_list[data->exclude_list_max]);
+            data->exclude_list_max++;
              if (env[j] != ':') break;
              i=j+1;
          }
      }

      // We don't want to loop into ourself
-    extern_base_root = getenv("FAKECHROOT_BASE_ROOT");
-    if (extern_base_root == NULL) {
-        extern_base_root = (char*)malloc(10);
-        strcpy(extern_base_root, "/tmp/klik");
+    data->base_root = getenv("FAKECHROOT_BASE_ROOT");
+    if (data->base_root == NULL) {
+        data->base_root = (char*)malloc(10);
+        strcpy(data->base_root, "/tmp/klik");
      }
-    extern_base_root_length = strlen(extern_base_root);
+    data->base_root_size = strlen(data->base_root);

-    if (extern_union_mounting) return fuse_main(nargc, nargv,  
&fs_oper_union, NULL);
-    return fuse_main(nargc, nargv, &fs_oper, NULL);
+    if (data->union_mounting) return fuse_main(nargc, nargv,  
&fs_oper_union, data);
+    return fuse_main(nargc, nargv, &fs_oper, data);
  }

Added: branches/cristian/fusioniso/fusioniso/src/fusioniso.h
==============================================================================
--- (empty file)
+++ branches/cristian/fusioniso/fusioniso/src/fusioniso.h	Fri Aug 29  
07:36:20 2008
@@ -0,0 +1,84 @@
+/*
+ *  
-----------------------------------------------------------------------------
+ *
+ *   Copyright (C) 2008 by Cristian Greco <cgreco at cs.unibo.it>
+ *
+ *  
-----------------------------------------------------------------------------
+ *
+ *   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.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the
+ *   Free Software Foundation, Inc.,
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ *  
-----------------------------------------------------------------------------
+ */
+
+#ifndef _FUSIONISO_H_
+#define _FUSIONISO_H_
+
+#include <fuse.h>
+#include <glib.h>
+
+#include "fusioniso_fs.h"
+#include "fusioniso_isofs.h"
+
+#define true 1
+#define false 0
+
+typedef enum sandboxing { sandbox_none, sandbox_home, sandbox_portable,  
sandbox_data } sandbox_type;
+
+typedef struct _fusioniso_data {
+	int maintain_mountpoint;
+	int maintain_mtab;
+
+	char *iocharset;                  /* specify iocharset for Joliet  
filesystem */
+	char *mountpoint;                 /* mount point */
+	int union_mounting;               /* if true, union-mount data over  
filesystem */
+	sandbox_type sandbox_mounting;    /* options for application sandboxing */
+
+	char *redirect_path;              /* redirect write operations from this  
path ... */
+	int redirect_path_size;
+
+	char *sandbox_path;               /* ... to this sandbox path */
+	int sandbox_path_size;
+
+	char *exclude_list[32];           /* exclude some paths in case of  
sandboxing */
+	int exclude_list_size[32];
+	int exclude_list_max;
+
+	char *base_root;
+	int base_root_size;
+
+	int glibc;                        /* if true, change the loader on the  
fly */
+
+	isofs_context *isofs;             /* iso image mounted */
+
+	/* files hash tables  */
+	GHashTable *lookup_table;
+	GHashTable *removed_lookup_table;
+	GHashTable *real_lookup_table;
+	GHashTable *negative_lookup_table;
+} fusioniso_data;
+
+
+static inline fusioniso_data *fusioniso_get_data(void)
+{
+	return (fusioniso_data *) fuse_get_context()->private_data;
+}
+
+static inline isofs_context *isofs_get_context(void)
+{
+	return (isofs_context *) fusioniso_get_data()->isofs;
+}
+
+#endif /* _FUSIONISO_H_  */

Modified: branches/cristian/fusioniso/fusioniso/src/fusioniso_fs.c
==============================================================================
--- branches/cristian/fusioniso/fusioniso/src/fusioniso_fs.c	(original)
+++ branches/cristian/fusioniso/fusioniso/src/fusioniso_fs.c	Fri Aug 29  
07:36:20 2008
@@ -86,37 +86,15 @@
  #include <fcntl.h>
  #include <dirent.h>
  #include <libgen.h>
-#include <glib.h>

  #ifdef HAVE_SETXATTR
  #include <sys/xattr.h>
  #endif

-
-#include "fusioniso_fs.h"
-#include "fusioniso_isofs.h" // isofs_real_*
  #include "fusioniso_debug.h"
+#include "fusioniso.h"
+

-extern char *extern_mount_point;
-extern bool extern_union_mounting;
-extern sandbox_type extern_sandbox_mounting;
-extern char* extern_redirect_path;
-extern int   extern_size_redirect_path;
-extern char* extern_sandbox_path;
-extern int   extern_size_sandbox_path;
-extern char* extern_exclude_list[];
-extern int   extern_exclude_length[];
-extern int   extern_list_max;
-extern char* extern_base_root;
-extern int   extern_base_root_length;
-extern bool  extern_glibc;
-
-isofs_context extern_context;
-
-GHashTable *lookup_table;
-GHashTable *removed_lookup_table;
-GHashTable *real_lookup_table;
-GHashTable *negative_lookup_table;
  static char *negative_value = "not exists";
  static char *removed_value = "removed";

@@ -148,6 +126,8 @@
      struct stat v_stbuf;
      gchar **parts;
      int retval,i;
+    fusioniso_data *data=fusioniso_get_data();
+
      FSDEBUG("path=%s",p_path);

      strcpy(v_path, p_path);
@@ -158,10 +138,10 @@
          if (!retval && S_ISDIR(v_stbuf.st_mode)) return;
      }

-    FSDEBUG("%s -> %s",v_path,&(v_path[extern_size_sandbox_path]));
-    parts = g_strsplit(&(v_path[extern_size_sandbox_path]), "/", -1);
-    strcpy(source, extern_redirect_path);
-    strcpy(dest, extern_sandbox_path);
+    FSDEBUG("%s -> %s",v_path,&(v_path[data->sandbox_path_size]));
+    parts = g_strsplit(&(v_path[data->sandbox_path_size]), "/", -1);
+    strcpy(source, data->redirect_path);
+    strcpy(dest, data->sandbox_path);
      for (i=0; i<local_g_strv_length(parts)-p_value; i++)
      {
          strcat(source, "/");
@@ -187,7 +167,10 @@
      char buffer[FS_MAXPATH];
      FILE *file_in, *file_out;
      struct stat v_stbuf;
-    int retval, number;
+    int retval;
+    size_t number;
+    fusioniso_data *data=fusioniso_get_data();
+
      FSDEBUG("p_path=%s p_newpath=%s",p_path,p_newpath);

      retval = stat(p_path, &v_stbuf);
@@ -199,7 +182,7 @@

      fs_path_mkdir(p_newpath, 1);
      file_in = fopen(p_path, "r");
-    if (file_in==NULL && extern_sandbox_mounting!=sandbox_data) return;
+    if (file_in==NULL && data->sandbox_mounting!=sandbox_data) return;
      file_out = fopen(p_newpath, "w");
      if (file_out == NULL)
      {
@@ -228,20 +211,21 @@
  int fs_home(const char *p_path, char **p_newpath)
  {
      int i, v_size = strlen(p_path);
+    fusioniso_data *data=fusioniso_get_data();

-    if (extern_sandbox_mounting==sandbox_none ||  
v_size<extern_size_redirect_path)
+    if (data->sandbox_mounting==sandbox_none ||  
v_size<data->redirect_path_size)
      {
          *p_newpath = (char*)p_path;
          return 1;
      }

      // We try to find if we need direct access to a file
-    for (i=0; i<extern_list_max; i++)
+    for (i=0; i<data->exclude_list_max; i++)
      {
-        if (extern_exclude_length[i]>v_size ||
-             
p_path[extern_exclude_length[i]-1]!=(extern_exclude_list[i])[extern_exclude_length[i]-1]  
||
-             
strncmp(extern_exclude_list[i],p_path,extern_exclude_length[i])!=0)  
continue;
-        if (extern_exclude_length[i]==v_size ||  
p_path[extern_exclude_length[i]]=='/')
+        if (data->exclude_list_size[i]>v_size ||
+             
p_path[data->exclude_list_size[i]-1]!=(data->exclude_list[i])[data->exclude_list_size[i]-1]  
||
+             
strncmp(data->exclude_list[i],p_path,data->exclude_list_size[i])!=0)  
continue;
+        if (data->exclude_list_size[i]==v_size ||  
p_path[data->exclude_list_size[i]]=='/')
          {
              *p_newpath = (char*)p_path;
              return 1;
@@ -249,33 +233,33 @@
      }

      // -B support
-    if (extern_sandbox_mounting==sandbox_data &&
-        extern_size_redirect_path==1 &&
+    if (data->sandbox_mounting==sandbox_data &&
+        data->redirect_path_size==1 &&
          p_path[0]=='/')
      {
-        strcpy(*p_newpath, extern_sandbox_path);
+        strcpy(*p_newpath, data->sandbox_path);
          strcat(*p_newpath, p_path);
          return 0;
      }

      // -d support
-    if (extern_sandbox_mounting==sandbox_portable &&
-        p_path[extern_size_redirect_path-2]=='/' &&
-        p_path[extern_size_redirect_path-1]=='.' &&
-        !strncmp(p_path,extern_redirect_path,extern_size_redirect_path))
+    if (data->sandbox_mounting==sandbox_portable &&
+        p_path[data->redirect_path_size-2]=='/' &&
+        p_path[data->redirect_path_size-1]=='.' &&
+        !strncmp(p_path,data->redirect_path,data->redirect_path_size))
      {
-        strcpy(*p_newpath, extern_sandbox_path);
-        strcat(*p_newpath, &(p_path[extern_size_redirect_path]));
+        strcpy(*p_newpath, data->sandbox_path);
+        strcat(*p_newpath, &(p_path[data->redirect_path_size]));
          return 0;
      }

      // -b support
-    if (extern_sandbox_mounting==sandbox_home &&
-        (v_size==extern_size_redirect_path ||  
p_path[extern_size_redirect_path]=='/') &&
-        !strncmp(p_path,extern_redirect_path,extern_size_redirect_path))
+    if (data->sandbox_mounting==sandbox_home &&
+        (v_size==data->redirect_path_size ||  
p_path[data->redirect_path_size]=='/') &&
+        !strncmp(p_path,data->redirect_path,data->redirect_path_size))
      {
-        strcpy(*p_newpath, extern_sandbox_path);
-        strcat(*p_newpath, &(p_path[extern_size_redirect_path]));
+        strcpy(*p_newpath, data->sandbox_path);
+        strcat(*p_newpath, &(p_path[data->redirect_path_size]));
          return 0;
      }

@@ -332,12 +316,17 @@
   */
  isofs_inode* fs_lookup(const char *p_path)
  {
+    fusioniso_data *data=fusioniso_get_data();
+
      if (p_path[0] == '\0') return NULL;
-    isofs_inode* inode = g_hash_table_lookup(lookup_table, p_path);
+
+    isofs_inode* inode = g_hash_table_lookup(data->lookup_table, p_path);
      if (inode != NULL) return inode;
-    if (g_hash_table_lookup(negative_lookup_table, p_path)) return NULL;
-    if (extern_union_mounting && g_hash_table_lookup(real_lookup_table,  
p_path)) return NULL;
-    //printf("start search for [%s]\n", p_path);
+
+    if (g_hash_table_lookup(data->negative_lookup_table, p_path)) return  
NULL;
+    if (data->union_mounting &&  
g_hash_table_lookup(data->real_lookup_table, p_path)) return NULL;
+
+    //FSDEBUG("start search for [%s]",p_path);
      gchar **parts = g_strsplit(p_path, "/", -1);
      guint parts_len = local_g_strv_length(parts);
      int partno = 1;
@@ -348,13 +337,13 @@
      {
          rpath1 = g_strconcat(rpath1, "/", part, NULL);
          //printf("looking for [%s] in [%s]...\n", rpath1, rpath);
-        if (extern_union_mounting &&  
g_hash_table_lookup(real_lookup_table, rpath1)) return NULL;
-        inode = g_hash_table_lookup(lookup_table, rpath1);
+        if (data->union_mounting &&  
g_hash_table_lookup(data->real_lookup_table, rpath1)) return NULL;
+        inode = g_hash_table_lookup(data->lookup_table, rpath1);
          if (inode == NULL)
          {
              //          printf("trying to load %s...\n", rpath);
              int rc = fs_real_readdir(0, rpath, NULL, NULL);
-            if (!extern_union_mounting && rc)
+            if (!data->union_mounting && rc)
              {
                  FSDEBUG("lookup: error %d from  
readdir: %s",rc,strerror(-rc));
                  g_strfreev(parts);
@@ -369,16 +358,16 @@
      }
      g_strfreev(parts);
      g_free(rpath);
-    inode = g_hash_table_lookup(lookup_table, p_path);
+    inode = g_hash_table_lookup(data->lookup_table, p_path);
      if (inode == NULL)
      {
          struct stat v_stbuf;
-        if (extern_union_mounting && stat(p_path,&v_stbuf)!=0)
+        if (data->union_mounting && stat(p_path,&v_stbuf)!=0)
          {
-            g_hash_table_insert(negative_lookup_table, g_strdup(p_path),  
negative_value);
+            g_hash_table_insert(data->negative_lookup_table,  
g_strdup(p_path), negative_value);
              return NULL;
          }
-        if (!extern_union_mounting)  
g_hash_table_insert(negative_lookup_table, g_strdup(p_path),  
negative_value);
+        if (!data->union_mounting)  
g_hash_table_insert(data->negative_lookup_table, g_strdup(p_path),  
negative_value);
          return NULL;
      }
      return inode;
@@ -388,7 +377,10 @@
  {
      char ppath[FS_MAXPATH];
      char *newpath=ppath;
+    fusioniso_data *data=fusioniso_get_data();
+
      FSDEBUG("path=%s", path);
+
      isofs_inode *inode = fs_lookup(path);
      if (inode==NULL)
      {
@@ -400,7 +392,7 @@
              return 0;
          }

-        if (extern_union_mounting && lstat(path,&v_stbuf)==0)
+        if (data->union_mounting && lstat(path,&v_stbuf)==0)
          {
              if (!S_ISDIR(v_stbuf.st_mode)) return -ENOENT;
              return 0;
@@ -429,6 +421,8 @@
      int retval1, retval2;
      DIR *v_dir;
      char *buf = NULL;
+    fusioniso_data *data=fusioniso_get_data();
+
      if (path[0] == '\0')
      {
          FSDEBUG("attempt to read empty path name");
@@ -436,10 +430,11 @@
      }

      FSDEBUG("path=%s flag=%d",path,real);
+
      isofs_inode *current_inode = fs_lookup(path);
      isofs_inode *inode2 = NULL;

-    if (!extern_union_mounting && current_inode==NULL)
+    if (!data->union_mounting && current_inode==NULL)
      {
          FSDEBUG("know nothing about %s",path);
          return -ENOENT;
@@ -451,16 +446,16 @@
          if (real && retval2!=1) goto out_readdir;
          if (!real && retval2!=1)
          {
-            g_hash_table_insert(real_lookup_table, g_strdup(path), "real");
+            g_hash_table_insert(data->real_lookup_table,  
g_strdup(path), "real");
              return 0;
          }
-        if (extern_union_mounting)
+        if (data->union_mounting)
          {
              retval1 = stat(path, &v_stbuf);
              if (real && retval1==0) goto out_readdir;
              if (!real && retval1==0)
              {
-                g_hash_table_insert(real_lookup_table,  
g_strdup(path), "real");
+                g_hash_table_insert(data->real_lookup_table,  
g_strdup(path), "real");
                  return 0;
              }
          }
@@ -478,7 +473,7 @@
      size_t current_size = isonum_733(current->size);

      int block = isonum_733(current->extent);
-    buf = (char *) malloc(extern_context.data_size);
+    buf = (char *) malloc(data->isofs->data_size);
      if (!buf)
      {
          FSDEBUG("can\'t malloc: %s",strerror(errno));
@@ -494,12 +489,12 @@

      while (total_size <= current_size - sizeof(struct  
iso_directory_record))
      {
-        rc = isofs_read_raw_block(block, buf);
+        rc = isofs_read_raw_block(block, buf, data->isofs);
          if (rc < 0)
          {
              return rc;
          }
-        if (rc != extern_context.data_size)
+        if (rc != data->isofs->data_size)
          {
              // can`t be allowed
              FSDEBUG("can`t read whole block, read only %d bytes,  
block %d",rc,block);
@@ -510,11 +505,11 @@

          if (boff > 0)
          {
-            total_size += (extern_context.data_size - boff);
+            total_size += (data->isofs->data_size - boff);
              boff = 0;
          }

-        while (boff + sizeof(struct iso_directory_record) <=  
extern_context.data_size &&
+        while (boff + sizeof(struct iso_directory_record) <=  
data->isofs->data_size &&
              total_size <= current_size - sizeof(struct  
iso_directory_record))
          {

@@ -529,7 +524,7 @@
              if (record_length == 0)
              {
                  // possible end of directory or end of block
-                total_size += (extern_context.data_size - boff);
+                total_size += (data->isofs->data_size - boff);
                  boff = 0;
                  break;
              }
@@ -542,7 +537,7 @@
                      // (this is much possible it was my fault and  
misunderstanding -- dmiceman)
                      // but we need to try next block to be sure
                      /// TODO this is not clear: what to do if next block  
not contain next directory?
-                    total_size += (extern_context.data_size - boff);
+                    total_size += (data->isofs->data_size - boff);
                      boff = 0;
                      break;
                  }
@@ -562,8 +557,7 @@
              if (sa_len < 0)
              {
                  // probably something wrong with name_len
-                FSDEBUG("wrong name_len in directory entry: %d,  
record_length %d",
-                    name_len, record_length);
+                FSDEBUG("wrong name_len in directory entry: %d,  
record_length %d",name_len,record_length);
                  free(buf);
                  return -EIO;
              }
@@ -583,8 +577,8 @@
                  return -ENOMEM;
              }
              memset(inode, 0, sizeof(isofs_inode));
-            inode->st_ino = extern_context.last_ino;
-            extern_context.last_ino++;
+            inode->st_ino = data->isofs->last_ino;
+            data->isofs->last_ino++;

              struct iso_directory_record *n_rec =
                  (struct iso_directory_record *) malloc (sizeof(struct  
iso_directory_record));
@@ -596,12 +590,12 @@
              memcpy(n_rec, record, sizeof(struct iso_directory_record));
              inode->record = n_rec;

-            if (extern_context.susp || path[1] == '\0')               //  
if susp is known to be present or this is a root dir ("/")
+            if (data->isofs->susp || path[1] == '\0')               // if  
susp is known to be present or this is a root dir ("/")
              {
                  /*                printf("sa offset %d, sa_len %d\n",
                                                                           
sizeof(struct iso_directory_record) + name_len + pad_len, sa_len);*/
                  rc = isofs_parse_sa(inode,
-                    ((char *) record) + sizeof(struct  
iso_directory_record) + name_len + pad_len + extern_context.susp_skip,
+                    ((char *) record) + sizeof(struct  
iso_directory_record) + name_len + pad_len + data->isofs->susp_skip,
                      sa_len);
                  if (rc<0)
                  {
@@ -677,7 +671,7 @@
                  strcat(absolute_entry, "/");
              }
              strcat(absolute_entry, entry);
-            if (g_hash_table_lookup(lookup_table, absolute_entry))
+            if (g_hash_table_lookup(data->lookup_table, absolute_entry))
              {
                  // already in lookup cache
                  isofs_free_inode(inode);
@@ -685,7 +679,7 @@
              else
              {
                  FSDEBUG("REGISTER [%s] IN LOOKUP_TABLE",absolute_entry);
-                g_hash_table_insert(lookup_table,  
g_strdup(absolute_entry), inode);
+                g_hash_table_insert(data->lookup_table,  
g_strdup(absolute_entry), inode);
              }

              free(entry);
@@ -700,7 +694,7 @@
          block++;
      }

-    out_readdir:
+out_readdir:
      if (retval2!=1 && real)
      {
          v_dir = opendir(newpath);
@@ -728,7 +722,7 @@
          }
      }

-    if (real && extern_union_mounting)
+    if (real && data->union_mounting)
      {
          // Read the real path
          v_dir = opendir(path);
@@ -754,7 +748,7 @@
                  {
                      memset(&v_stbuf, '\0', sizeof(struct stat));
                      if (filler && !lstat(v_chemin,&v_stbuf))
-                    if (g_hash_table_lookup(removed_lookup_table,v_chemin)  
== NULL)
+                    if  
(g_hash_table_lookup(data->removed_lookup_table,v_chemin) == NULL)
                      {
                          filler(filler_buf, v_dirent->d_name, &v_stbuf, 0);
                          FSDEBUG("FILLER #2 [%s]",v_dirent->d_name);
@@ -774,36 +768,38 @@
      char ppath[FS_MAXPATH], target[FS_MAXPATH];
      char *newpath=ppath;
      int i, j;
+    fusioniso_data *data=fusioniso_get_data();

      FSDEBUG("path=%s",path);
+
      isofs_inode *inode = fs_lookup(path);
      if (inode == NULL)
      {
-        if (extern_glibc && strcmp(path,"/lib/ld-linux.so.2")==0)
+        if (data->glibc && strcmp(path,"/lib/ld-linux.so.2")==0)
          {
              if (lstat("/lib/ld-klik2.so.2",stbuf) == 0) return 0;
              return -ENOENT;
          }

          // we forbid access to the location where all mount points are  
located
-        if (extern_union_mounting)
+        if (data->union_mounting)
          {
-            for (i=0,j=0; i<extern_base_root_length && path[j]!='\0';) {
-                if (extern_base_root[i] != path[j]) break;
+            for (i=0,j=0; i<data->base_root_size && path[j]!='\0';) {
+                if (data->base_root[i] != path[j]) break;
                  if (path[j] == '/') for (;path[j]=='/';j++);
                  else j++;
                  i++;
-                }
-            if (extern_base_root[i] == '\0') return -ENOENT;
+            }
+            if (data->base_root[i] == '\0') return -ENOENT;
          }

          if (fs_home_stat(path,&newpath,stbuf) == 0) return 0;
-        if (extern_union_mounting && lstat(path,stbuf)==0)
+        if (data->union_mounting && lstat(path,stbuf)==0)
          {
              int retval;

              // If a file was previously removed, we need to take care
-            if (g_hash_table_lookup(removed_lookup_table, path))
+            if (g_hash_table_lookup(data->removed_lookup_table, path))
              {
                  FSDEBUG("LOOKUP removed_lookup_table -> %s",path);
                  return -ENOENT;
@@ -814,7 +810,7 @@
              if (retval != -1)
              {
                  target[retval] = '\0';
-                stbuf->st_size += strlen(extern_mount_point);
+                stbuf->st_size += strlen(data->mountpoint);
              }

              return 0;
@@ -840,14 +836,17 @@
      char ppath[FS_MAXPATH];
      char *newpath=ppath;
      int retval;
+    fusioniso_data *data=fusioniso_get_data();
+
      FSDEBUG("path=%s",path);
+
      isofs_inode *inode = fs_lookup(path);
      if (inode == NULL)
      {
          struct stat v_stbuf;

          // Use our own loader
-        if (extern_glibc && strcmp(path,"/lib/ld-linux.so.2")==0)
+        if (data->glibc && strcmp(path,"/lib/ld-linux.so.2")==0)
          {
              retval = readlink("/lib/ld-klik2.so.2", target, size-1);
              if (retval == -1) return -errno;
@@ -861,9 +860,9 @@
              retval = readlink(newpath, target, size-1);
              if (retval == -1) return -errno;
              target[retval] = '\0';
-            strcpy(newpath, extern_sandbox_path);
+            strcpy(newpath, data->sandbox_path);
              strcat(newpath, target);
-            if (extern_sandbox_mounting!=sandbox_none &&  
stat(newpath,&v_stbuf)==0)
+            if (data->sandbox_mounting!=sandbox_none &&  
stat(newpath,&v_stbuf)==0)
              {
                  strcpy(target, newpath);
                  return 0;
@@ -871,7 +870,7 @@
              return 0;
          }

-        if (extern_union_mounting && lstat(path,&v_stbuf)==0)
+        if (data->union_mounting && lstat(path,&v_stbuf)==0)
          {
              if (!S_ISLNK(v_stbuf.st_mode)) return -EINVAL;
              retval = readlink(path, target, size-1);
@@ -879,7 +878,7 @@
              target[retval] = '\0';
              if (lstat(target,&v_stbuf)==-1 && fs_lookup(target))
              {
-                sprintf(ppath,"%s%s", extern_mount_point, target);
+                sprintf(ppath,"%s%s", data->mountpoint, target);
                  strcpy(target, ppath);
              }
              return 0;
@@ -903,7 +902,10 @@
  {
      char ppath[FS_MAXPATH];
      char *newpath=ppath;
+    fusioniso_data *data=fusioniso_get_data();
+
      FSDEBUG("path=%s",path);
+
      isofs_inode *inode = fs_lookup(path);
      if (inode == NULL)
      {
@@ -915,7 +917,7 @@
              return 0;
          }

-        if (extern_union_mounting && stat(path,&v_stbuf)==0)
+        if (data->union_mounting && stat(path,&v_stbuf)==0)
          {
              if (!S_ISREG(v_stbuf.st_mode)) return -EINVAL;
              return 0;
@@ -941,15 +943,19 @@
  {
      char ppath[FS_MAXPATH];
      char *newpath=ppath;
+    fusioniso_data *data=fusioniso_get_data();
+
      FSDEBUG("path=%s",path);
+
      isofs_inode *inode = fs_lookup(path);
      if (inode == NULL)
      {
          struct stat v_stbuf;
-        int v_file, v_count;
+        int v_file;
+	ssize_t v_count;

          // Use our own loader
-        if (extern_glibc && strcmp(path,"/lib/ld-linux.so.2")==0)
+        if (data->glibc && strcmp(path,"/lib/ld-linux.so.2")==0)
          {
              v_file = open("/lib/ld-klik2.so.2", O_RDONLY);
              if (v_file == -1) return -EACCES;
@@ -967,14 +973,14 @@
              lseek(v_file, offset, SEEK_SET);
              v_count = read(v_file, out_buf, size);
              close(v_file);
-            if (extern_glibc && offset==0 && v_count>18 && out_buf[0]==127  
&& memcmp(&(out_buf[1]), "ELF",3)==0)
+            if (data->glibc && offset==0 && v_count>18 && out_buf[0]==127  
&& memcmp(&(out_buf[1]), "ELF",3)==0)
              {
                  fs_rewrite_loader(out_buf, v_count);
              }
              return v_count;
          }

-        if (extern_union_mounting && stat(path,&v_stbuf)==0)
+        if (data->union_mounting && stat(path,&v_stbuf)==0)
          {
              if (!S_ISREG(v_stbuf.st_mode)) return -EINVAL;
              v_file = open(path, O_RDONLY);
@@ -982,7 +988,7 @@
              lseek(v_file, offset, SEEK_SET);
              v_count = read(v_file, out_buf, size);
              close(v_file);
-            if (extern_glibc && offset==0 && v_count>18 && out_buf[0]==127  
&& memcmp(&(out_buf[1]), "ELF",3)==0)
+            if (data->glibc && offset==0 && v_count>18 && out_buf[0]==127  
&& memcmp(&(out_buf[1]), "ELF",3)==0)
              {
                  fs_rewrite_loader(out_buf, v_count);
              }
@@ -1011,7 +1017,7 @@
  	if (v_count<0)
  		return -EINVAL;

-        if (extern_glibc && offset==0 && v_count>18 && out_buf[0]==127 &&  
memcmp(&(out_buf[1]), "ELF",3)==0)
+        if (data->glibc && offset==0 && v_count>18 && out_buf[0]==127 &&  
memcmp(&(out_buf[1]), "ELF",3)==0)
          {
              fs_rewrite_loader(out_buf, v_count);
          }
@@ -1034,14 +1040,14 @@
          return 0;
      }

-    int start = offset / extern_context.data_size;
-    int end = (offset + size) / extern_context.data_size;
-    int shift = offset % extern_context.data_size;
+    int start = offset / data->isofs->data_size;
+    int end = (offset + size) / data->isofs->data_size;
+    int shift = offset % data->isofs->data_size;
      int block = start_block + start;
      //     printf("read: path %s, size %d, offset %d, fsize %d, start %d,  
end %d, shift %d\n",
      //         path, size, (int) offset, fsize, start, end, shift);

-    char *buf = (char *) malloc(extern_context.data_size);
+    char *buf = (char *) malloc(data->isofs->data_size);
      if (!buf)
      {
          FSDEBUG("can\'t malloc: %s",strerror(errno));
@@ -1055,7 +1061,7 @@

      for (i=start; i<=end; i++)
      {
-        int len = isofs_read_raw_block(block, buf);
+        int len = isofs_read_raw_block(block, buf, data->isofs);
          if (len < 0)
          {
              free(buf);
@@ -1070,7 +1076,7 @@

          total_size += len;

-        memcpy(out_buf + count * extern_context.data_size, buf + shift,  
len - shift);
+        memcpy(out_buf + count * data->isofs->data_size, buf + shift, len  
- shift);

          count++;
          shift = 0;
@@ -1079,7 +1085,7 @@
      }

      free(buf);
-    if (extern_glibc && total_size>18 && offset==0 && out_buf[0]==127 &&  
memcmp(&(out_buf[1]), "ELF",3)==0)
+    if (data->glibc && total_size>18 && offset==0 && out_buf[0]==127 &&  
memcmp(&(out_buf[1]), "ELF",3)==0)
      {
          fs_rewrite_loader(out_buf, total_size);
      }
@@ -1090,14 +1096,17 @@
  {
      char ppath[FS_MAXPATH];
      char *newpath=ppath;
+    fusioniso_data *data=fusioniso_get_data();
+
      FSDEBUG("path=%s",path);
+
      isofs_inode *inode=NULL;
-    if (extern_glibc && strcmp(path,"/lib/ld-linux.so.2")==0) return  
statfs("/lib/ld-klik2.so.2", stbuf);
-    if (extern_union_mounting) inode=fs_lookup(path);
-    if (!extern_union_mounting || inode)
+    if (data->glibc && strcmp(path,"/lib/ld-linux.so.2")==0) return  
statfs("/lib/ld-klik2.so.2", stbuf);
+    if (data->union_mounting) inode=fs_lookup(path);
+    if (!data->union_mounting || inode)
      {
          stbuf->f_type = ISOFS_SUPER_MAGIC;
-        stbuf->f_bsize = extern_context.data_size;                // or  
PAGE_CACHE_SIZE?
+        stbuf->f_bsize = data->isofs->data_size;                // or  
PAGE_CACHE_SIZE?
          stbuf->f_blocks = 0;                                      // while  
it is possible to calculate this, i see no reasons to do so
          stbuf->f_bfree = 0;
          stbuf->f_bavail = 0;
@@ -1122,7 +1131,10 @@
      struct stat v_stbuf;
      int v_file, v_count, retval;
      char *newpath=ppath;
+    fusioniso_data *data=fusioniso_get_data();
+
      FSDEBUG("path=%s (%d octets, %d offset)",path,size,(int)offset);
+
      isofs_inode *inode = fs_lookup(path);
      if (inode)
      {
@@ -1143,7 +1155,7 @@
          return size;
      }

-    if (extern_union_mounting && stat(path,&v_stbuf)==0)
+    if (data->union_mounting && stat(path,&v_stbuf)==0)
      {
          if (!S_ISREG(v_stbuf.st_mode)) return -EINVAL;
          v_file = open(path, O_RDWR|O_APPEND);
@@ -1161,10 +1173,13 @@
      char ppath[2*FS_MAXPATH];
      char *newpath=ppath;
      struct stat v_stbuf;
+    fusioniso_data *data=fusioniso_get_data();
+
      FSDEBUG("path=%s mode=%d",path,amode);
+
      isofs_inode *inode = fs_lookup(path);
      if (inode) return 0;
-    if (extern_sandbox_mounting==sandbox_data && (amode&W_OK)) return 0;
+    if (data->sandbox_mounting==sandbox_data && (amode&W_OK)) return 0;
      if (fs_home_stat(path,&newpath,&v_stbuf) == 0)
      {
          if (access(newpath,amode) == 0) return 0;
@@ -1198,7 +1213,10 @@
      char *newpath=ppath;
      struct stat v_stbuf;
      int retval;
+    fusioniso_data *data=fusioniso_get_data();
+
      FSDEBUG("path=%s",path);
+
      isofs_inode *inode = fs_lookup(path);
      if (inode)
      {
@@ -1216,7 +1234,7 @@
              if (lstat(path,&v_stbuf) == 0)
              {
                  FSDEBUG("INSERT removed_lookup_table -> %s",path);
-                g_hash_table_insert(removed_lookup_table, g_strdup(path),  
removed_value);
+                g_hash_table_insert(data->removed_lookup_table,  
g_strdup(path), removed_value);
                  return 0;
              }
              return retval;
@@ -1227,7 +1245,7 @@
              if (lstat(path,&v_stbuf) == 0)
              {
                  FSDEBUG("INSERT removed_lookup_table -> %s",path);
-                g_hash_table_insert(removed_lookup_table, g_strdup(path),  
removed_value);
+                g_hash_table_insert(data->removed_lookup_table,  
g_strdup(path), removed_value);
                  return 0;
              }
      }
@@ -1242,7 +1260,10 @@
      char *newpath=ppath;
      struct stat v_stbuf;
      int retval, errno2;
+    fusioniso_data *data=fusioniso_get_data();
+
      FSDEBUG("path=%s",path);
+
      isofs_inode *inode = fs_lookup(path);
      if (inode)
      {
@@ -1261,7 +1282,7 @@
              if (lstat(path,&v_stbuf) == 0)
              {
                  FSDEBUG("INSERT removed_lookup_table -> %s",path);
-                g_hash_table_insert(removed_lookup_table, g_strdup(path),  
removed_value);
+                g_hash_table_insert(data->removed_lookup_table,  
g_strdup(path), removed_value);
                  return 0;
              }
              if (retval == 0) return 0;
@@ -1272,7 +1293,7 @@
              if (lstat(path,&v_stbuf) == 0)
              {
                  FSDEBUG("INSERT removed_lookup_table -> %s",path);
-                g_hash_table_insert(removed_lookup_table, g_strdup(path),  
removed_value);
+                g_hash_table_insert(data->removed_lookup_table,  
g_strdup(path), removed_value);
                  return 0;
              }
      }
@@ -1333,7 +1354,10 @@
      char *path1=ppath1;
      char *path2=ppath2;
      int retval;
+    fusioniso_data *data=fusioniso_get_data();
+
      FSDEBUG("oldpath=%s -> newpath=%s",oldpath,newpath);
+
      isofs_inode *inode = fs_lookup(oldpath);
      if (inode)
      {
@@ -1354,7 +1378,7 @@
              }
              else fs_file_dup(oldpath,path1);
              FSDEBUG("INSERT removed_lookup_table -> %s",oldpath);
-            g_hash_table_insert(removed_lookup_table, g_strdup(oldpath),  
removed_value);
+            g_hash_table_insert(data->removed_lookup_table,  
g_strdup(oldpath), removed_value);
          }
          fs_path_mkdir(path2, 1);


Modified: branches/cristian/fusioniso/fusioniso/src/fusioniso_fs.h
==============================================================================
--- branches/cristian/fusioniso/fusioniso/src/fusioniso_fs.h	(original)
+++ branches/cristian/fusioniso/fusioniso/src/fusioniso_fs.h	Fri Aug 29  
07:36:20 2008
@@ -39,11 +39,6 @@

  typedef int u32; // needed on kubuntu 7.04 ... (???)

-typedef int bool;
-#define true 1
-#define false 0
-
-typedef enum sandboxing { sandbox_none, sandbox_home, sandbox_portable,  
sandbox_data } sandbox_type;

  typedef int (*fs_dir_fill_t) (void *buf, const char *name, const struct  
stat *stat, off_t off);


Modified: branches/cristian/fusioniso/fusioniso/src/fusioniso_isofs.c
==============================================================================
--- branches/cristian/fusioniso/fusioniso/src/fusioniso_isofs.c	(original)
+++ branches/cristian/fusioniso/fusioniso/src/fusioniso_isofs.c	Fri Aug 29  
07:36:20 2008
@@ -58,24 +58,15 @@
  #include <utime.h>
  #include <iconv.h>
  #include <pthread.h>
-#include <glib.h>
  #include <zlib.h>

  #include <linux/rock.h>

-#include "fusioniso_isofs.h"
  #include "fusioniso_debug.h"
+#include "fusioniso.h"

  static pthread_mutex_t fd_mutex = PTHREAD_MUTEX_INITIALIZER;

-extern char* extern_iocharset;
-extern isofs_context extern_context;
-extern GHashTable *lookup_table;
-extern GHashTable *real_lookup_table;
-extern GHashTable *removed_lookup_table;
-extern GHashTable *negative_lookup_table;
-
-
  static char* dstr(char* str, const char* src, int len)
  {
      int i;
@@ -103,17 +94,17 @@
   *         0 if not found,
   *         -1 on error
   */
-static int isofs_check_rr(struct iso_directory_record *root_record)
+static int isofs_check_rr(struct iso_directory_record *root_record,  
isofs_context *isofs)
  {
      int extent = isonum_733(root_record->extent);
-    char *buf = (char *) malloc(extern_context.data_size);            //  
can we use "standard" 2048 there?
+    char *buf = (char *) malloc(isofs->data_size);            // can we  
use "standard" 2048 there?
      if (!buf)
      {
          FSWARNING("can\'t malloc: %s",strerror(errno));
          return -1;
      }

-    int rc = isofs_read_raw_block(extent, buf);
+    int rc = isofs_read_raw_block(extent, buf, isofs);
      if (rc < 0)
      {
          free(buf);
@@ -125,7 +116,6 @@
      size_t name_len = isonum_711(record->name_len);
      size_t pad_len = ((name_len & 1) ? 0 : 1);                        //  
padding byte if name_len is even
      size_t sa_len = record_length - name_len - sizeof(struct  
iso_directory_record) - pad_len;
-
      if (record_length < sizeof(struct iso_directory_record))
      {
          FSWARNING("directory record length too small: %d",record_length);
@@ -249,7 +239,8 @@
   */
  static int isofs_parse_zisofs_header(isofs_inode *inode)
  {
-    char *buf = (char *) malloc(extern_context.block_size);
+    isofs_context *isofs=isofs_get_context();
+    char *buf = (char *) malloc(isofs->block_size);
      if (!buf)
      {
          FSWARNING("can\'t malloc: %s",strerror(errno));
@@ -257,7 +248,7 @@
      }

      int block_num = isonum_733(inode->record->extent);
-    int len = isofs_read_raw_block(block_num, buf);
+    int len = isofs_read_raw_block(block_num, buf, isofs);
      if (len < 0)
      {
          free(buf);
@@ -303,8 +294,8 @@
      while (block_table_left)
      {
          size_t block_table_chunk =
-            (block_table_left < (int)extern_context.data_size -  
block_table_shift ?
-            block_table_left : extern_context.data_size -  
block_table_shift);
+            (block_table_left < (int)isofs->data_size - block_table_shift ?
+            block_table_left : isofs->data_size - block_table_shift);

          /*        printf("isofs_parse_sa: block_table_size: %d,  
block_table_left: %d, block_table_total %d, block_table_shift %d,  
block_table_chunk %d\n",
                                      block_table_size, block_table_left,  
block_table_total, block_table_shift, block_table_chunk);*/
@@ -317,7 +308,7 @@

          // read next block
          block_num += 1;
-        len = isofs_read_raw_block(block_num, buf);
+        len = isofs_read_raw_block(block_num, buf, isofs);
          if (len < 0)
          {
              free(buf);
@@ -342,28 +333,47 @@
      return 1;
  }

-int isofs_real_preinit(char* imagefile, int fd)
+
+/**
+ *
+ * @return 0 on success,
+ *         -1 on error
+ */
+int isofs_init(char* imagefile, isofs_context **isofs)
  {
-    memset(& extern_context, 0, sizeof(isofs_context));
+    int i, rc, vd_type, vd_num=0;
+    struct iso_volume_descriptor *vd;
+    ssize_t size;
+    char *vd_id, buf[129];
+    isofs_context *new;

-    extern_context.imagefile = imagefile;
-    extern_context.fd = fd;
+    new=(isofs_context *) malloc(sizeof(isofs_context));
+    if (!new) {
+        FSWARNING("can\'t malloc: %s",strerror(errno));
+        return -1;
+    }
+    memset(new,0,sizeof(isofs_context));
+
+    new->imagefile=imagefile;
+    new->fd=open(imagefile,O_RDONLY);
+    if (new->fd<0) {
+	FSWARNING("cannot open image file \"%s\"",imagefile);
+	return -1;
+    }

      // trying to read all volume descriptors
-    struct iso_volume_descriptor *vd =
-        (struct iso_volume_descriptor *) malloc(sizeof(struct  
iso_volume_descriptor));
+    vd=(struct iso_volume_descriptor *) malloc(sizeof(struct  
iso_volume_descriptor));
      if (!vd)
      {
          FSWARNING("can\'t malloc: %s",strerror(errno));
          return -1;
      }
-    int vd_num = 0;

      // defaults for iso
-    extern_context.block_size = 2048;
-    extern_context.data_size = 2048;
-    extern_context.block_offset = 0;
-    extern_context.file_offset = 0;
+    new->block_size = 2048;
+    new->data_size = 2048;
+    new->block_offset = 0;
+    new->file_offset = 0;

      enum
      {
@@ -375,28 +385,30 @@
          IDOFF_NRG = 2048 * 16 + 307200,
      };
      int iso_offsets[] = {IDOFF_ISO_2048, IDOFF_MODE2_2336,  
IDOFF_MODE2_2352_RAW, IDOFF_NRG};
+
      // try to find CD001 identifier
-    int i;
      for (i = 0; i < 4; i++)
      {
-        if (lseek(fd, iso_offsets[i], SEEK_SET) == -1)
+        if (lseek(new->fd, iso_offsets[i], SEEK_SET) == -1)
          {
              FSWARNING("can\'t lseek() to next possible data start  
position; is it really supported file? : %s",strerror(errno));
              return -1;
          }
-        ssize_t size = read(fd, vd, sizeof(struct iso_volume_descriptor));
+
+        size = read(new->fd, vd, sizeof(struct iso_volume_descriptor));
          if (size != sizeof(struct iso_volume_descriptor))
          {
              FSWARNING("only %d bytes read from position %d, %d required;  
is it really supported file?",
                  size, iso_offsets[i], sizeof(struct  
iso_volume_descriptor));
              return -1;
          }
-        char *vd_id = (char *) vd->id;
+
+	vd_id = (char *) vd->id;
          if (strncmp("CD001", vd_id, 5) == 0)
          {
              // found CD001!
              // fill context with information about block size and block  
offsets
-            extern_context.id_offset = iso_offsets[i];
+            new->id_offset = iso_offsets[i];
              switch (iso_offsets[i])
              {
                  case IDOFF_ISO_2048:
@@ -404,14 +416,14 @@
                      // use defaults
                      break;
                  case IDOFF_MODE2_2352_RAW:
-                    extern_context.block_size = 2352;
+                    new->block_size = 2352;
                      break;
                  case IDOFF_MODE2_2336:
-                    extern_context.block_size = 2336;
-                    extern_context.block_offset = 16;
+                    new->block_size = 2336;
+                    new->block_offset = 16;
                      break;
                  case IDOFF_NRG:
-                    extern_context.file_offset = 307200;
+                    new->file_offset = 307200;
                      break;
                  default:
                      break;
@@ -420,31 +432,32 @@
          }
          else if (strncmp("CD001", vd_id+16, 5) == 0)
          {
-            extern_context.id_offset = iso_offsets[i] + 16;
-            extern_context.block_size = 2352;
-            extern_context.block_offset = 16;
+            new->id_offset = iso_offsets[i] + 16;
+            new->block_size = 2352;
+            new->block_offset = 16;
              break;
          }
          else if (strncmp("CD001", vd_id+24, 5) == 0)
          {
-            extern_context.id_offset = iso_offsets[i] + 24;
-            extern_context.block_size = 2352;
-            extern_context.block_offset = 24;
+            new->id_offset = iso_offsets[i] + 24;
+            new->block_size = 2352;
+            new->block_offset = 24;
              break;
          }
      }

      FSDEBUG("CD001 found at %d, block_size %d, block_offset %d,  
data_size %d",
-                    extern_context.id_offset, extern_context.block_size,  
extern_context.block_offset, extern_context.data_size);
+                    new->id_offset, new->block_size, new->block_offset,  
new->data_size);
      while (1)
      {
-        if (lseek(fd, extern_context.block_size * (16 + vd_num) +
-            extern_context.block_offset + extern_context.file_offset,  
SEEK_SET) == -1)
+        if (lseek(new->fd, new->block_size * (16 + vd_num) +
+	            new->block_offset + new->file_offset, SEEK_SET) == -1)
          {
              FSWARNING("can\'t lseek() to next volume  
descriptor: %s",strerror(errno));
              return -1;
          }
-        ssize_t size = read(fd, vd, sizeof(struct iso_volume_descriptor));
+
+        size = read(new->fd, vd, sizeof(struct iso_volume_descriptor));
          if (size != sizeof(struct iso_volume_descriptor))
          {
              FSWARNING("only %d bytes read from volume descriptor %d, %d  
required",
@@ -452,7 +465,7 @@
              return -1;
          }

-        int vd_type = isonum_711((unsigned char *)vd->type);
+        vd_type = isonum_711((unsigned char *)vd->type);
          FSDEBUG("found volume descriptor type %d,  
vd_num %d",vd_type,vd_num);

          if (strncmp("CD001", vd->id, 5) != 0)
@@ -475,32 +488,32 @@
              {
                  case ISO_VD_PRIMARY:
                      // check if this is only primary descriptor found
-                    if (extern_context.pd.type[0])
+                    if (new->pd.type[0])
                      {
                          FSDEBUG("init: primary volume descriptor already  
found, skipping..");
                      }
                      else
                      {
-                        memcpy(& extern_context.pd, vd, sizeof(struct  
iso_volume_descriptor));
-                        extern_context.root = (struct iso_directory_record  
*)& extern_context.pd.root_directory_record;
-                        extern_context.data_size =  
isonum_723(extern_context.pd.logical_block_size);
+                        memcpy(&new->pd, vd, sizeof(struct  
iso_volume_descriptor));
+                        new->root = (struct iso_directory_record *)  
&new->pd.root_directory_record;
+                        new->data_size =  
isonum_723(new->pd.logical_block_size);

-                        if (!extern_context.block_size)
+                        if (!new->block_size)
                          {
-                            FSDEBUG("wrong block data size %d, using  
default 2048",extern_context.data_size);
-                            extern_context.data_size = 2048;
+                            FSDEBUG("wrong block data size %d, using  
default 2048",new->data_size);
+                            new->data_size = 2048;
                          }
-
-                        if (extern_context.block_size != 2048)
+#if 0
+                        if (new->block_size != 2048)
                          {
                              // report unusual data block size
                              // later
-                            // printf("Data block size: %d\n",  
extern_context.block_size);
+                            // FSDEBUG("Data block  
size: %d",new->block_size);
                          }
-
-                        int rc = isofs_check_rr(extern_context.root);
+#endif
+                        rc = isofs_check_rr(new->root,new);
  			if (rc) {
-                            extern_context.pd_have_rr = 1;
+                            new->pd_have_rr = 1;
  			} else if (rc<0) {
  			    return -1;
                          }
@@ -510,16 +523,15 @@
                  case ISO_VD_SUPPLEMENTARY:
                  {
                      struct iso_supplementary_descriptor *sd = (struct  
iso_supplementary_descriptor *) vd;
+		    int have_rr, joliet_level=0;

-                    if (!extern_context.pd.type[0])
+                    if (!new->pd.type[0])
                      {
                          FSWARNING("supplementary volume descriptor found,  
but no primary descriptor!");
                          return -1;
                      }
                      else
                      {
-                        int joliet_level = 0;
-
                          if (sd->escape[0] == 0x25 && sd->escape[1] == 0x2f)
                          {
                              switch (sd->escape[2])
@@ -536,29 +548,29 @@
                              }
                          }

-                        int have_rr = isofs_check_rr((struct  
iso_directory_record *) sd->root_directory_record);
+                        have_rr = isofs_check_rr((struct  
iso_directory_record *) sd->root_directory_record,new);
  			if (have_rr<0)
  				return -1;

                          // switch to SVD only if it contain RRIP or if PVD  
have no RRIP
                          // in other words, prefer VD with RRIP
                          if ((joliet_level && have_rr) ||
-                            (have_rr && !extern_context.pd_have_rr) ||
-                            (joliet_level && !extern_context.pd_have_rr))
+                            (have_rr && !new->pd_have_rr) ||
+                            (joliet_level && !new->pd_have_rr))
                          {

-                            extern_context.joliet_level = joliet_level;
-                            memcpy(& extern_context.sd, vd, sizeof(struct  
iso_volume_descriptor));
-                            extern_context.supplementary = 1;
+                            new->joliet_level = joliet_level;
+                            memcpy(&new->sd, vd, sizeof(struct  
iso_volume_descriptor));
+                            new->supplementary = 1;

-                            extern_context.root = (struct  
iso_directory_record *) extern_context.sd.root_directory_record;
+                            new->root = (struct iso_directory_record *)  
new->sd.root_directory_record;

                              FSDEBUG("switching to supplementary  
descriptor %d, joliet_level %d, have_rr %d",
-                                   vd_num, extern_context.joliet_level,  
have_rr);
+                                   vd_num, joliet_level, have_rr);
                          }
                          else
                          {
-                            extern_context.joliet_level = 0;
+                            new->joliet_level = 0;
                              FSDEBUG("found supplementary descriptor %d,  
flags %d",
                                     vd_num, isonum_711((unsigned char  
*)sd->flags));
                          }
@@ -567,7 +579,7 @@
                  break;

                  case 0:
-                    // boot record, not intresting..
+                    // boot record, not interesting..
                      break;

                  case ISO_VD_END:
@@ -576,70 +588,46 @@
                      break;

                  default:
-                    FSDEBUG("unsupported volume descriptor type %d,  
vd_num %d",
-                        vd_type, vd_num);
+                    FSDEBUG("unsupported volume descriptor type %d,  
vd_num %d",vd_type,vd_num);
                      break;
              }
          }

          vd_num += 1;
      }
-    out:

-    if (!extern_context.pd.type[0])
+out:
+    if (!new->pd.type[0])
      {
          FSWARNING("primary volume descriptor not found! exiting..");
          return -1;
      }

-    extern_context.susp = 0;
-    extern_context.susp_skip = 0;
+    new->susp = 0;
+    new->susp_skip = 0;

-    lookup_table = g_hash_table_new(g_str_hash, g_str_equal);
-    real_lookup_table = g_hash_table_new(g_str_hash, g_str_equal);
-    removed_lookup_table = g_hash_table_new(g_str_hash, g_str_equal);
-    negative_lookup_table = g_hash_table_new(g_str_hash, g_str_equal);

-    isofs_inode *inode = (isofs_inode *) malloc(sizeof(isofs_inode));
-    if (inode == NULL)
-    {
-        FSWARNING("can\'t malloc: %s",strerror(errno));
-        return -1;
-    }
-    memset(inode, 0, sizeof(isofs_inode));
-    inode->record = extern_context.root;
-    extern_context.last_ino++;                                        //  
set to 1
-    inode->st_ino = extern_context.last_ino;
-    extern_context.last_ino++;
-
-    g_hash_table_insert(lookup_table, (char*)"/", inode);
-
-    return 0;
-}
-
-void* isofs_real_init()
-{
-    if (extern_context.file_offset == 307200)
+    if (new->file_offset == 307200)
      {
          FSDEBUG("NRG image found");
      }
-    else if (extern_context.block_size == 2048)
+    else if (new->block_size == 2048)
      {
          FSDEBUG("ISO9660 image found");
      }
-    else if (extern_context.block_size == 2352 &&  
extern_context.block_offset == 0)
+    else if (new->block_size == 2352 && new->block_offset == 0)
      {
          FSDEBUG("MODE2 RAW BIN image found");
      }
-    else if (extern_context.block_size == 2352 &&  
extern_context.block_offset == 16)
+    else if (new->block_size == 2352 && new->block_offset == 16)
      {
          FSDEBUG("MODE1 BIN image found (or CCD MODE1 image, or MDF  
image)");
      }
-    else if (extern_context.block_size == 2352 &&  
extern_context.block_offset == 24)
+    else if (new->block_size == 2352 && new->block_offset == 24)
      {
          FSDEBUG("MODE2 BIN image found (or CCD MODE2 image)");
      }
-    else if (extern_context.block_size == 2336 &&  
extern_context.block_offset == 16)
+    else if (new->block_size == 2336 && new->block_offset == 16)
      {
          FSDEBUG("MODE2/2336 BIN image found");
      }
@@ -648,29 +636,28 @@
          FSDEBUG("UNKNOWN image found; probably will not work");
      }

-    if (extern_context.block_size != 2048)
+    if (new->block_size != 2048)
      {
          // report unusual data block size
-        FSDEBUG("Data block size: %d",extern_context.block_size);
+        FSDEBUG("Data block size: %d",new->block_size);
      }

-    char buf[129];
+    FSDEBUG("System Identifier                 : %s",     dstr(buf,  
new->pd.system_id,             32));
+    FSDEBUG("Volume Identifier                 : %.32s",  dstr(buf,  
new->pd.volume_id,             32));
+    FSDEBUG("Volume Set Identifier             : %.128s", dstr(buf,  
new->pd.volume_set_id,         128));
+    FSDEBUG("Publisher Identifier              : %.128s", dstr(buf,  
new->pd.publisher_id,          128));
+    FSDEBUG("Data Preparer Identifier          : %.128s", dstr(buf,  
new->pd.preparer_id,           128));
+    FSDEBUG("Application Identifier            : %.128s", dstr(buf,  
new->pd.application_id,        128));
+    FSDEBUG("Copyright File Identifier         : %.37s",  dstr(buf,  
new->pd.copyright_file_id,     37));
+    FSDEBUG("Abstract File Identifier          : %.37s",  dstr(buf,  
new->pd.abstract_file_id,      37));
+    FSDEBUG("Bibliographic File Identifier     : %.37s",  dstr(buf,  
new->pd.bibliographic_file_id, 37));
+    FSDEBUG("Volume Creation Date and Time     : %.17s",  dstr(buf,  
new->pd.creation_date,         17));
+    FSDEBUG("Volume Modification Date and Time : %.17s",  dstr(buf,  
new->pd.modification_date,     17));
+    FSDEBUG("Volume Expiration Date and Time   : %.17s",  dstr(buf,  
new->pd.expiration_date,       17));
+    FSDEBUG("Volume Effective Date and Time    : %.17s",  dstr(buf,  
new->pd.effective_date,        17));

-    FSDEBUG("System Identifier                 : %s", dstr(buf,  
extern_context.pd.system_id, 32));
-    FSDEBUG("Volume Identifier                 : %.32s", dstr(buf,  
extern_context.pd.volume_id, 32));
-    FSDEBUG("Volume Set Identifier             : %.128s", dstr(buf,  
extern_context.pd.volume_set_id, 128));
-    FSDEBUG("Publisher Identifier              : %.128s", dstr(buf,  
extern_context.pd.publisher_id, 128));
-    FSDEBUG("Data Preparer Identifier          : %.128s", dstr(buf,  
extern_context.pd.preparer_id, 128));
-    FSDEBUG("Application Identifier            : %.128s", dstr(buf,  
extern_context.pd.application_id, 128));
-    FSDEBUG("Copyright File Identifier         : %.37s", dstr(buf,  
extern_context.pd.copyright_file_id, 37));
-    FSDEBUG("Abstract File Identifier          : %.37s", dstr(buf,  
extern_context.pd.abstract_file_id, 37));
-    FSDEBUG("Bibliographic File Identifier     : %.37s", dstr(buf,  
extern_context.pd.bibliographic_file_id, 37));
-    FSDEBUG("Volume Creation Date and Time     : %.17s", dstr(buf,  
extern_context.pd.creation_date, 17));
-    FSDEBUG("Volume Modification Date and Time : %.17s", dstr(buf,  
extern_context.pd.modification_date, 17));
-    FSDEBUG("Volume Expiration Date and Time   : %.17s", dstr(buf,  
extern_context.pd.expiration_date, 17));
-    FSDEBUG("Volume Effective Date and Time    : %.17s", dstr(buf,  
extern_context.pd.effective_date, 17));
-
-    return (void*) &extern_context;
+    *isofs=new;
+    return 0;
  }


@@ -680,28 +667,28 @@
   * @return >=0 on read success (number of bytes read)
   *         -1 on error
   */
-int isofs_read_raw_block(int block, char *buf)
+int isofs_read_raw_block(int block, char *buf, isofs_context *isofs)
  {
-    off_t off = block * extern_context.block_size +  
extern_context.block_offset + extern_context.file_offset;
+    off_t off = block * isofs->block_size + isofs->block_offset +  
isofs->file_offset;
      if (pthread_mutex_lock(& fd_mutex))
      {
          //int err = errno;
          FSWARNING("can\'t lock fd_mutex: %s",strerror(errno));
          return -1;
      }
-    if (lseek(extern_context.fd, off, SEEK_SET) == -1)
+    if (lseek(isofs->fd, off, SEEK_SET) == -1)
      {
          FSWARNING("can\'t lseek: %s",strerror(errno));
          pthread_mutex_unlock(& fd_mutex);
          return -1;
      }
-    size_t len = read(extern_context.fd, buf, extern_context.data_size);
-    if (len != extern_context.data_size)
+    ssize_t len = read(isofs->fd, buf, isofs->data_size);
+    if (len != isofs->data_size)
      {
          FSDEBUG("can\'t read full block, (%d on %d bytes from  
offset %d): %s",
-            len, extern_context.data_size, (int)off, strerror(errno));
+            len, isofs->data_size, (int)off, strerror(errno));
          // fprintf(stderr, "isofs_read_raw_block: huh? reading zeros  
beyond file end? someone want to save a penny?\n");
-        memset(buf + len, 0, extern_context.data_size - len);
+        memset(buf + len, 0, isofs->data_size - len);
          // pthread_mutex_unlock(& fd_mutex);
          // return -EIO;
      }
@@ -718,6 +705,7 @@
   */
  int isofs_direntry2stat(struct stat *st, isofs_inode *inode)
  {
+    isofs_context *isofs=isofs_get_context();
      struct iso_directory_record *record = inode->record;

      // fill st_ino from block number where file start
@@ -736,8 +724,8 @@
          st->st_size = isonum_733(record->size);
      }

-    st->st_blocks = st->st_size / extern_context.data_size;           //  
should not be to meaningful even for zisofs compression
-    st->st_blksize = extern_context.data_size;
+    st->st_blocks = st->st_size / isofs->data_size;           // should  
not be to meaningful even for zisofs compression
+    st->st_blksize = isofs->data_size;
      st->st_nlink = 1;                                                 //  
always, even if rrip PX entry found

      if (inode->PX)                                                    //  
rrip PX entry found and in effect
@@ -789,7 +777,8 @@
   */
  char *isofs_fix_entry(char *entry, size_t len)
  {
-    if (!extern_context.joliet_level)                                 //  
iso9660 names
+    fusioniso_data *data=fusioniso_get_data();
+    if (!data->isofs->joliet_level)                                   //  
iso9660 names
      {
          char *sep2 = index(entry, ';');                               //  
find SEPARATOR2
          if (sep2)                                                     //  
remove remaining part
@@ -825,7 +814,7 @@
      else
      {
          // initialize iconv descriptor
-        iconv_t cd = iconv_open(extern_iocharset, "UCS-2BE");
+        iconv_t cd = iconv_open(data->iocharset, "UCS-2BE");
          if (cd < 0)
          {
              FSWARNING("iconv error: %s",strerror(errno));
@@ -893,6 +882,7 @@
      int cont_offset = 0;
      int cont_size = 0;
      int remaining = sa_len;
+    isofs_context *isofs=isofs_get_context();

      while (remaining > 4)                                             //  
susp 4.
      {
@@ -916,13 +906,13 @@
                      // incorrect SP entry
                      FSWARNING("incorrect SP entry: sue_len %d,  
sue_version %d, magic %c%c",
                          sue_len, sue_version, sue->u.SP.magic[0],  
sue->u.SP.magic[1]);
-                    extern_context.susp = 0;
+                    isofs->susp = 0;
                      return -1;
                  }
                  else
                  {
-                    extern_context.susp = 1;
-                    extern_context.susp_skip = sue->u.SP.skip;
+                    isofs->susp = 1;
+                    isofs->susp_skip = sue->u.SP.skip;
                  }
                  //FSDEBUG("SP entry, skip %d",sue->u.SP.skip);
                  break;
@@ -951,7 +941,7 @@
                              cont_block, cont_offset, cont_size);
                          cont_block = 0;                               //  
do not process it
                      }
-                    else if (cont_offset + cont_size >  
(int)extern_context.data_size)
+                    else if (cont_offset + cont_size >  
(int)isofs->data_size)
                      {
                          // something wrong with continuation area offset  
and/or size
                          FSDEBUG("wrong continuation area: extent %d,  
cont_offset %d, cont_size %d",
@@ -1310,13 +1300,13 @@
                      inode->cl_block = cl_block;

                      // read block pointed by CL record and process first  
directory entry
-                    char *buf = (char *) malloc(extern_context.data_size);
+                    char *buf = (char *) malloc(isofs->data_size);
                      if (!buf)
                      {
                          FSWARNING("can\'t malloc: %s",strerror(errno));
                          return -1;
                      }
-                    int rc = isofs_read_raw_block(inode->cl_block, buf);
+                    int rc = isofs_read_raw_block(inode->cl_block, buf,  
isofs);
                      if (rc < 0)
                      {
                          free(buf);
@@ -1376,7 +1366,7 @@
                      rc = isofs_parse_sa(inode,
                          ((char *) record) +
                          sizeof(struct iso_directory_record) +
-                        name_len + pad_len + extern_context.susp_skip,
+                        name_len + pad_len + isofs->susp_skip,
                          sa_len);
                      if (rc<0)
                      {
@@ -1555,13 +1545,13 @@
      // process continuation area if found
      if (cont_block)
      {
-        char *buf = (char *) malloc(extern_context.data_size);
+        char *buf = (char *) malloc(isofs->data_size);
          if (!buf)
          {
              FSWARNING("can\'t malloc: %s",strerror(errno));
              return -1;
          }
-        int rc = isofs_read_raw_block(cont_block, buf);
+        int rc = isofs_read_raw_block(cont_block, buf, isofs);
          if (rc < 0)
          {
              free(buf);
@@ -1598,6 +1588,7 @@
      // PATCH #1 -- Ryan Thomas 2007-06-13
      if ((offset+size ) % zf_block_size==0) zf_end--;
      int shift = offset % zf_block_size;
+    isofs_context *isofs=isofs_get_context();

      //     printf("zf_start %d, zf_end %d, size %d, offset %d, shift %d\n",
      //         zf_start, zf_end, size, (int) offset, shift);
@@ -1623,7 +1614,7 @@
      size_t total_size = 0;
      size_t size_left = size;

-    int base_offset = isonum_733(inode->record->extent) *  
extern_context.data_size;
+    int base_offset = isonum_733(inode->record->extent) * isofs->data_size;

      int i;
      for (i = zf_start; i <= zf_end; i++)
@@ -1663,7 +1654,7 @@
                  free(ubuf);
                  return -1;
              }
-            if (lseek(extern_context.fd, image_off, SEEK_SET) == -1)
+            if (lseek(isofs->fd, image_off, SEEK_SET) == -1)
              {
                  FSWARNING("can\'t lseek: %s",strerror(errno));
                  pthread_mutex_unlock(& fd_mutex);
@@ -1671,7 +1662,7 @@
                  free(ubuf);
                  return -1;
              }
-            size_t len = read(extern_context.fd, cbuf, block_size);
+            ssize_t len = read(isofs->fd, cbuf, block_size);
              if ((int)len != block_size)
              {
                  FSWARNING("can\'t read full block, errno %d, message %s",

Modified: branches/cristian/fusioniso/fusioniso/src/fusioniso_isofs.h
==============================================================================
--- branches/cristian/fusioniso/fusioniso/src/fusioniso_isofs.h	(original)
+++ branches/cristian/fusioniso/fusioniso/src/fusioniso_isofs.h	Fri Aug 29  
07:36:20 2008
@@ -141,9 +141,9 @@
  #endif
  }

-int isofs_real_preinit(char* imagefile, int fd);
-void* isofs_real_init();
-int isofs_read_raw_block(int block, char *buf);
+
+int isofs_init(char* imagefile, isofs_context **isofs);
+int isofs_read_raw_block(int block, char *buf, isofs_context *isofs);
  int isofs_direntry2stat(struct stat *st, isofs_inode *inode);
  char *isofs_fix_entry(char *entry, size_t len);
  int isofs_parse_sa(isofs_inode *inode, char *sa, size_t sa_len);
_______________________________________________
klik-devel mailing list
klik-devel@kde.org
https://mail.kde.org/mailman/listinfo/klik-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic