From b0ea568364223ff4e8bb5a6bf03f23bc7e211f36 Mon Sep 17 00:00:00 2001 From: short <> Date: Fri, 2 May 2003 18:30:44 +0000 Subject: [PATCH] First phase of multifilesystem enhancement - CORBA not yet finished but GObject Vfs already implemented --- src/client/cmdline/cmd_cd.c | 3 +- src/client/cmdline/cmd_get.c | 5 +- src/client/cmdline/cmd_info.c | 3 +- src/client/cmdline/cmd_ls.c | 3 +- src/client/cmdline/cmd_mkdir.c | 3 +- src/client/cmdline/cmd_mv.c | 3 +- src/client/cmdline/cmd_put.c | 3 +- src/client/cmdline/cmd_rm.c | 3 +- src/client/cmdline/cmd_rmdir.c | 3 +- src/client/cmdline/main.c | 38 +++- src/client/cmdline/main.h | 4 + src/libcaptive/client/Makefile.am | 5 +- src/libcaptive/client/directory.c | 14 +- src/libcaptive/client/directory.h | 2 + src/libcaptive/client/file.c | 17 +- src/libcaptive/client/file.h | 2 + src/libcaptive/client/init.c | 244 ++++----------------- src/libcaptive/client/init.h | 35 +++ src/libcaptive/client/lib.c | 4 +- src/libcaptive/client/options.c | 238 ++++++++++++++++++++ src/libcaptive/client/vfs.c | 133 +++++++++++ src/libcaptive/client/vfs.h | 43 ++++ src/libcaptive/include/captive/Makefile.am | 3 +- src/libcaptive/include/captive/client-directory.h | 8 +- src/libcaptive/include/captive/client-file.h | 10 +- src/libcaptive/include/captive/client-vfs.h | 52 +++++ src/libcaptive/include/captive/client.h | 66 ------ src/libcaptive/include/captive/options.h | 74 +++++++ src/libcaptive/include/captive/storage.h | 10 + src/libcaptive/sandbox/Makefile.am | 6 +- src/libcaptive/sandbox/sandbox.idl | 100 ++++++--- src/libcaptive/sandbox/server-Directory.c | 8 +- src/libcaptive/sandbox/server-File.c | 86 ++++++++ .../sandbox/{server-VFS.h => server-File.h} | 16 +- src/libcaptive/sandbox/server-GlibLogFunc.c | 8 +- src/libcaptive/sandbox/server-GlibLogFunc.h | 6 +- src/libcaptive/sandbox/server-VFS.c | 72 ------ src/libcaptive/sandbox/split.c | 74 +++---- src/libcaptive/storage/cdrom.c | 6 +- src/libcaptive/storage/disk.c | 8 +- src/libcaptive/storage/media.c | 16 +- 41 files changed, 949 insertions(+), 488 deletions(-) create mode 100644 src/libcaptive/client/init.h create mode 100644 src/libcaptive/client/options.c create mode 100644 src/libcaptive/client/vfs.c create mode 100644 src/libcaptive/client/vfs.h create mode 100644 src/libcaptive/include/captive/client-vfs.h delete mode 100644 src/libcaptive/include/captive/client.h create mode 100644 src/libcaptive/include/captive/options.h create mode 100644 src/libcaptive/sandbox/server-File.c rename src/libcaptive/sandbox/{server-VFS.h => server-File.h} (73%) delete mode 100644 src/libcaptive/sandbox/server-VFS.c diff --git a/src/client/cmdline/cmd_cd.c b/src/client/cmdline/cmd_cd.c index ef5b608..3eedb40 100644 --- a/src/client/cmdline/cmd_cd.c +++ b/src/client/cmdline/cmd_cd.c @@ -24,7 +24,7 @@ #include #include #include -#include "captive/client-directory.h" +#include #include #include "cmd_cd.h" /* self */ @@ -131,6 +131,7 @@ const gchar *targetdir=cmdline_path_from_cwd(cmd_argv[0]); if (!errvfsresult_to_gerr(errp,captive_directory_new_open( &captive_directory_object, /* captive_directory_object_return */ + cmdline_captive_vfs_object, /* captive_vfs_object */ targetdir))) { /* pathname */ err_cleanup(errp); g_set_error(errp,CMDLINE_CMD_CD_ERROR,CMDLINE_CMD_CD_ERROR_CANNOT_OPEN_DIRECTORY, diff --git a/src/client/cmdline/cmd_get.c b/src/client/cmdline/cmd_get.c index a99e37c..18ae8c6 100644 --- a/src/client/cmdline/cmd_get.c +++ b/src/client/cmdline/cmd_get.c @@ -22,11 +22,11 @@ #include #include #include -#include "captive/client-file.h" +#include #include #include #include -#include "captive/macros.h" +#include #include "cmd_get.h" /* self */ #include "cmd_cd.h" /* for cmdline_path_from_cwd() */ @@ -92,6 +92,7 @@ char *s; if (!errvfsresult_to_gerr(errp,captive_file_new_open( &captive_file_object, /* captive_file_object_return */ + cmdline_captive_vfs_object, /* captive_vfs_object */ sourcefile, /* pathname */ GNOME_VFS_OPEN_READ))) { /* mode */ err_cleanup(errp); diff --git a/src/client/cmdline/cmd_info.c b/src/client/cmdline/cmd_info.c index b8dee5e..0d5edea 100644 --- a/src/client/cmdline/cmd_info.c +++ b/src/client/cmdline/cmd_info.c @@ -24,7 +24,7 @@ #include #include #include -#include "captive/client-file.h" +#include #include "cmd_info.h" /* self */ #include "cmd_cd.h" /* for cmdline_path_from_cwd() */ @@ -61,6 +61,7 @@ const gchar *filepath; if (!errvfsresult_to_gerr(errp,captive_file_new_open( &captive_file_object, /* captive_file_object_return */ + cmdline_captive_vfs_object, /* captive_vfs_object */ filepath, /* pathname */ GNOME_VFS_OPEN_READ))) { /* mode */ err_cleanup(errp); diff --git a/src/client/cmdline/cmd_ls.c b/src/client/cmdline/cmd_ls.c index 38cde4c..c1a5fda 100644 --- a/src/client/cmdline/cmd_ls.c +++ b/src/client/cmdline/cmd_ls.c @@ -24,7 +24,7 @@ #include #include #include -#include "captive/client-directory.h" +#include #include "cmd_ls.h" /* self */ #include "cmd_cd.h" /* for cmdline_path_from_cwd() */ @@ -62,6 +62,7 @@ const gchar *targetdir; if (!errvfsresult_to_gerr(errp,captive_directory_new_open( &captive_directory_object, /* captive_directory_object_return */ + cmdline_captive_vfs_object, /* captive_vfs_object */ targetdir))) { /* pathname */ err_cleanup(errp); g_set_error(errp,CMDLINE_CMD_LS_ERROR,CMDLINE_CMD_LS_ERROR_CANNOT_OPEN_DIRECTORY, diff --git a/src/client/cmdline/cmd_mkdir.c b/src/client/cmdline/cmd_mkdir.c index a6ff1fd..caacacb 100644 --- a/src/client/cmdline/cmd_mkdir.c +++ b/src/client/cmdline/cmd_mkdir.c @@ -22,7 +22,7 @@ #include #include #include -#include "captive/client-directory.h" +#include #include "cmd_mkdir.h" /* self */ #include "cmd_cd.h" /* for cmdline_path_from_cwd() */ @@ -58,6 +58,7 @@ const gchar *targetdir; if (!errvfsresult_to_gerr(errp,captive_directory_new_make( &captive_directory_object, /* captive_directory_object_return */ + cmdline_captive_vfs_object, /* captive_vfs_object */ targetdir, /* pathname */ perms))) { /* perms */ err_cleanup(errp); diff --git a/src/client/cmdline/cmd_mv.c b/src/client/cmdline/cmd_mv.c index 942f859..a86b414 100644 --- a/src/client/cmdline/cmd_mv.c +++ b/src/client/cmdline/cmd_mv.c @@ -22,7 +22,7 @@ #include #include #include -#include "captive/client-file.h" +#include #include "cmd_mv.h" /* self */ #include "cmd_cd.h" /* for cmdline_path_from_cwd() */ @@ -58,6 +58,7 @@ const gchar *sourcefile,*targetfile; if (!errvfsresult_to_gerr(errp,captive_file_new_open( &captive_file_object, /* captive_file_object_return */ + cmdline_captive_vfs_object, /* captive_vfs_object */ sourcefile, /* pathname */ GNOME_VFS_OPEN_NONE))) { /* mode */ err_cleanup(errp); diff --git a/src/client/cmdline/cmd_put.c b/src/client/cmdline/cmd_put.c index d6564f0..5bedd9b 100644 --- a/src/client/cmdline/cmd_put.c +++ b/src/client/cmdline/cmd_put.c @@ -22,7 +22,7 @@ #include #include #include -#include "captive/client-file.h" +#include #include #include #include @@ -90,6 +90,7 @@ gchar *sourcefile_basename; if (!errvfsresult_to_gerr(errp,captive_file_new_create( &captive_file_object, /* captive_file_object_return */ + cmdline_captive_vfs_object, /* captive_vfs_object */ targetfile, /* pathname */ GNOME_VFS_OPEN_WRITE, /* mode */ FALSE, /* exclusive */ diff --git a/src/client/cmdline/cmd_rm.c b/src/client/cmdline/cmd_rm.c index 0c3de67..a8737f0 100644 --- a/src/client/cmdline/cmd_rm.c +++ b/src/client/cmdline/cmd_rm.c @@ -22,7 +22,7 @@ #include #include #include -#include "captive/client-file.h" +#include #include "cmd_rm.h" /* self */ #include "cmd_cd.h" /* for cmdline_path_from_cwd() */ @@ -57,6 +57,7 @@ const gchar *targetfile; if (!errvfsresult_to_gerr(errp,captive_file_new_open( &captive_file_object, /* captive_file_object_return */ + cmdline_captive_vfs_object, /* captive_vfs_object */ targetfile, /* pathname */ GNOME_VFS_OPEN_NONE))) { /* mode */ err_cleanup(errp); diff --git a/src/client/cmdline/cmd_rmdir.c b/src/client/cmdline/cmd_rmdir.c index 06d4339..73c482a 100644 --- a/src/client/cmdline/cmd_rmdir.c +++ b/src/client/cmdline/cmd_rmdir.c @@ -22,7 +22,7 @@ #include #include #include -#include "captive/client-directory.h" +#include #include "cmd_rmdir.h" /* self */ #include "cmd_cd.h" /* for cmdline_path_from_cwd() */ @@ -57,6 +57,7 @@ const gchar *targetdir; if (!errvfsresult_to_gerr(errp,captive_directory_new_open( &captive_directory_object, /* captive_directory_object_return */ + cmdline_captive_vfs_object, /* captive_vfs_object */ targetdir))) { /* pathname */ err_cleanup(errp); g_set_error(errp,CMDLINE_CMD_RMDIR_ERROR,CMDLINE_CMD_RMDIR_ERROR_CANNOT_CREATE_REMOVAL_DIRECTORY, diff --git a/src/client/cmdline/main.c b/src/client/cmdline/main.c index cdd94b3..32e7945 100644 --- a/src/client/cmdline/main.c +++ b/src/client/cmdline/main.c @@ -28,7 +28,7 @@ #include #include -#include /* for captive_init() */ +#include #include "main.h" /* self */ #include "cmd_shell.h" @@ -46,6 +46,9 @@ #include "cmd_help.h" +CaptiveVfsObject *cmdline_captive_vfs_object; + + GQuark cmdline_main_error_quark(void) { GQuark r=0; @@ -199,12 +202,19 @@ const char **cmd_argv,**csp; int cmd_argc; GError *gerr=NULL; const char *cmd_cd_root_args[]={"/",NULL}; +struct captive_options options; /* Initialize the i18n stuff */ setlocale(LC_ALL,""); bindtextdomain(PACKAGE,LOCALEDIR); textdomain(PACKAGE); + /* Initialize GObject subsystem of GLib. */ + g_type_init(); + + captive_options_init(&options); + captive_options=&options; /* for parsing by 'CAPTIVE_POPT_INCLUDE' */ + context=poptGetContext( PACKAGE, /* name */ argc,(/*en-const*/const char **)argv, /* argc,argv */ @@ -229,19 +239,31 @@ const char *cmd_cd_root_args[]={"/",NULL}; for (csp=cmd_argv,cmd_argc=0;csp && *csp;csp++) cmd_argc++; - if (TRUE!=captive_init(NULL, /* captive_args; already parsed above */ - ( /* image_iochannel */ - !cmd_argc ? NULL : g_io_channel_new_file( /* FIXME: g_io_channel_new_file() is NOT 64-bit compliant! */ - cmd_argv[0], /* filename */ - (captive_option_rwmode==CAPTIVE_OPTION_RWMODE_RW ? "r+" : "r"), /* mode */ - NULL)))) /* error */ - g_error(_("captive_init image_iochannel FAIL")); + captive_options=NULL; /* already parsed by 'CAPTIVE_POPT_INCLUDE' */ + + /* image_iochannel */ + if (cmd_argc) { + g_assert(options.image_iochannel==NULL); + if (!(options.image_iochannel=g_io_channel_new_file( + cmd_argv[0], /* filename */ + (options.rwmode==CAPTIVE_OPTION_RWMODE_RW ? "r+" : "r"), /* mode */ + NULL))) { /* error */ + g_error(_("image_iochannel open failed")); + return EXIT_FAILURE; + } + } if (cmd_argc>0) { /* image file */ cmd_argc--; cmd_argv++; } + if (GNOME_VFS_OK!=captive_vfs_new(&cmdline_captive_vfs_object,&options)) { + g_error(_("captive_vfs_new() failed")); + return EXIT_FAILURE; + } + captive_options_free(&options); + cmd_cd(cmd_cd_root_args,&gerr); if (gerr) { err_cleanup(&gerr); diff --git a/src/client/cmdline/main.h b/src/client/cmdline/main.h index 224b6f4..138f531 100644 --- a/src/client/cmdline/main.h +++ b/src/client/cmdline/main.h @@ -23,6 +23,7 @@ #include #include +#include #define CMDLINE_MAIN_ERROR (cmdline_main_error_quark()) @@ -48,6 +49,9 @@ struct cmdline_command { extern const struct cmdline_command cmdline_command_table[]; +extern CaptiveVfsObject *cmdline_captive_vfs_object; + + void invoke_cmd(int cmd_argc,const char **cmd_argv); void err_cleanup(GError **errp); gboolean errvfsresult_to_gerr(GError **errp,GnomeVFSResult errvfsresult); diff --git a/src/libcaptive/client/Makefile.am b/src/libcaptive/client/Makefile.am index 54622cb..29d6e88 100644 --- a/src/libcaptive/client/Makefile.am +++ b/src/libcaptive/client/Makefile.am @@ -31,9 +31,12 @@ libclient_la_SOURCES= \ leave.c \ lib.c \ lib.h \ + options.c \ result.c \ result.h \ - usecount.c + usecount.c \ + vfs.c \ + vfs.h libclient_la_CFLAGS= \ $(GNOME_VFS_MODULE_CFLAGS) libclient_la_LIBADD= \ diff --git a/src/libcaptive/client/directory.c b/src/libcaptive/client/directory.c index e77e76f..36322c9 100644 --- a/src/libcaptive/client/directory.c +++ b/src/libcaptive/client/directory.c @@ -95,7 +95,7 @@ static const GTypeInfo captive_directory_object_info={ static GnomeVFSResult captive_directory_new_internal(CaptiveDirectoryObject **captive_directory_object_return, - const gchar *pathname,gboolean create,guint create_perm) + CaptiveVfsObject *captive_vfs_object,const gchar *pathname,gboolean create,guint create_perm) { GnomeVFSResult errvfsresult; OBJECT_ATTRIBUTES dir_ObjectAttributes; @@ -105,6 +105,7 @@ NTSTATUS err; CaptiveDirectoryObject *captive_directory_object; g_return_val_if_fail(captive_directory_object_return!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); + g_return_val_if_fail(captive_vfs_object!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); g_return_val_if_fail(pathname!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); *captive_directory_object_return=NULL; @@ -148,6 +149,7 @@ CaptiveDirectoryObject *captive_directory_object; CAPTIVE_DIRECTORY_TYPE_OBJECT, /* object_type */ NULL); /* first_property_name; FIXME: support properties */ + captive_directory_object->vfs=captive_vfs_object; captive_directory_object->dir_Handle=dir_Handle; *captive_directory_object_return=captive_directory_object; @@ -156,7 +158,7 @@ CaptiveDirectoryObject *captive_directory_object; GnomeVFSResult captive_directory_new_open(CaptiveDirectoryObject **captive_directory_object_return, - const gchar *pathname) + CaptiveVfsObject *captive_vfs_object,const gchar *pathname) { GnomeVFSResult r; @@ -164,9 +166,10 @@ GnomeVFSResult r; return captive_sandbox_parent_directory_new_open(captive_directory_object_return,pathname); g_return_val_if_fail(captive_directory_object_return!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); + g_return_val_if_fail(captive_vfs_object!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); g_return_val_if_fail(pathname!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); - r=captive_directory_new_internal(captive_directory_object_return,pathname, + r=captive_directory_new_internal(captive_directory_object_return,captive_vfs_object,pathname, FALSE, /* create */ 0); /* create_perm; ignored */ @@ -178,14 +181,15 @@ GnomeVFSResult r; GnomeVFSResult captive_directory_new_make(CaptiveDirectoryObject **captive_directory_object_return, - const gchar *pathname,guint perm) + CaptiveVfsObject *captive_vfs_object,const gchar *pathname,guint perm) { GnomeVFSResult r; g_return_val_if_fail(captive_directory_object_return!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); + g_return_val_if_fail(captive_vfs_object!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); g_return_val_if_fail(pathname!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); - r=captive_directory_new_internal(captive_directory_object_return,pathname, + r=captive_directory_new_internal(captive_directory_object_return,captive_vfs_object,pathname, TRUE, /* create */ perm); /* create_perm; ignored */ diff --git a/src/libcaptive/client/directory.h b/src/libcaptive/client/directory.h index d675a7c..b96868f 100644 --- a/src/libcaptive/client/directory.h +++ b/src/libcaptive/client/directory.h @@ -25,6 +25,7 @@ #include #include "reactos/napi/types.h" /* for NTSTATUS */ #include "reactos/ntos/zwtypes.h" /* for FILE_ID_BOTH_DIR_INFORMATION */ +#include "captive/client-vfs.h" G_BEGIN_DECLS @@ -33,6 +34,7 @@ struct _CaptiveDirectoryObject { GObject parent_instance; /*< private >*/ + CaptiveVfsObject *vfs; HANDLE dir_Handle; gboolean read_first; /* 'QueryDirectory_buf' for NtQueryDirectoryFile() must be persistent diff --git a/src/libcaptive/client/file.c b/src/libcaptive/client/file.c index 2f41332..ff2da21 100644 --- a/src/libcaptive/client/file.c +++ b/src/libcaptive/client/file.c @@ -96,6 +96,7 @@ static const GTypeInfo captive_file_object_info={ static GnomeVFSResult captive_file_new_internal(CaptiveFileObject **captive_file_object_return, + CaptiveVfsObject *captive_vfs_object, const gchar *pathname,GnomeVFSOpenMode mode,gboolean create,gboolean create_exclusive,guint create_perm) { IO_STATUS_BLOCK file_IoStatusBlock; @@ -109,6 +110,7 @@ NTSTATUS err; return captive_sandbox_parent_file_new_open(captive_file_object_return,pathname,mode); g_return_val_if_fail(captive_file_object_return!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); + g_return_val_if_fail(captive_vfs_object!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); g_return_val_if_fail(pathname!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); *captive_file_object_return=NULL; @@ -156,6 +158,7 @@ NTSTATUS err; CAPTIVE_FILE_TYPE_OBJECT, /* object_type */ NULL); /* first_property_name; FIXME: support properties */ + captive_file_object->vfs=captive_vfs_object; captive_file_object->file_Handle=file_Handle; captive_file_object->offset=0; @@ -164,15 +167,16 @@ NTSTATUS err; } -GnomeVFSResult captive_file_new_open - (CaptiveFileObject **captive_file_object_return,const gchar *pathname,GnomeVFSOpenMode mode) +GnomeVFSResult captive_file_new_open(CaptiveFileObject **captive_file_object_return, + CaptiveVfsObject *captive_vfs_object,const gchar *pathname,GnomeVFSOpenMode mode) { GnomeVFSResult r; g_return_val_if_fail(captive_file_object_return!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); + g_return_val_if_fail(captive_vfs_object!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); g_return_val_if_fail(pathname!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); - r=captive_file_new_internal(captive_file_object_return,pathname,mode, + r=captive_file_new_internal(captive_file_object_return,captive_vfs_object,pathname,mode, FALSE, /* create */ FALSE, /* create_exclusive; ignored */ 0); /* create_perm; ignored */ @@ -184,15 +188,16 @@ GnomeVFSResult r; } -GnomeVFSResult captive_file_new_create - (CaptiveFileObject **captive_file_object_return,const gchar *pathname,GnomeVFSOpenMode mode,gboolean exclusive,guint perm) +GnomeVFSResult captive_file_new_create(CaptiveFileObject **captive_file_object_return, + CaptiveVfsObject *captive_vfs_object,const gchar *pathname,GnomeVFSOpenMode mode,gboolean exclusive,guint perm) { GnomeVFSResult r; g_return_val_if_fail(captive_file_object_return!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); + g_return_val_if_fail(captive_vfs_object!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); g_return_val_if_fail(pathname!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); - r=captive_file_new_internal(captive_file_object_return,pathname,mode, + r=captive_file_new_internal(captive_file_object_return,captive_vfs_object,pathname,mode, TRUE, /* create */ exclusive, /* create_exclusive */ perm); /* create_perm */ diff --git a/src/libcaptive/client/file.h b/src/libcaptive/client/file.h index 3af3cf0..629937c 100644 --- a/src/libcaptive/client/file.h +++ b/src/libcaptive/client/file.h @@ -24,6 +24,7 @@ #include #include #include "reactos/napi/types.h" /* for NTSTATUS */ +#include "captive/client-vfs.h" G_BEGIN_DECLS @@ -32,6 +33,7 @@ struct _CaptiveFileObject { GObject parent_instance; /*< private >*/ + CaptiveVfsObject *vfs; HANDLE file_Handle; GnomeVFSFileOffset offset; }; diff --git a/src/libcaptive/client/init.c b/src/libcaptive/client/init.c index 4e81c94..b3de39e 100644 --- a/src/libcaptive/client/init.c +++ b/src/libcaptive/client/init.c @@ -19,7 +19,6 @@ #include "config.h" -#include "captive/client.h" /* self */ #include "captive/ldr.h" #include "captive/ldr_exports.h" #include "captive/unicode.h" @@ -47,8 +46,11 @@ #include #include "reactos/internal/se.h" /* for SeInit2() */ #include "captive/leave.h" +#include "captive/options.h" +struct captive_options *captive_options; + /* Are we initialized? */ static gboolean active; @@ -64,151 +66,38 @@ PVOID captive_DriverObject_ReinitRoutine_Context; static TOP_LEVEL_IRP TopLevelIrp; /* TODO:thread */ -gchar *captive_option_filesystem; -enum captive_option_rwmode captive_option_rwmode=CAPTIVE_OPTION_RWMODE_BLIND; -enum captive_option_media captive_option_media=CAPTIVE_OPTION_MEDIA_DISK; -gboolean captive_debug_messages=FALSE; -GIOChannel *captive_image_iochannel; /* Non-blinded original GIOChannel for flushing during shutdown. */ -static GIOChannel *captive_image_iochannel_orig; -guint64 captive_image_size; -static GList *captive_load_module; - - -static gchar *captive_popt_optarg; - - -static void arg_filesystem(void) -{ - g_free(captive_option_filesystem); - captive_option_filesystem=g_strdup(captive_popt_optarg); -} - -static void arg_load_module(void) -{ - captive_load_module=g_list_append(captive_load_module,g_strdup(captive_popt_optarg)); -} +static GIOChannel *captive_options_image_iochannel_orig; -static void arg_ro(void) -{ - captive_option_rwmode=CAPTIVE_OPTION_RWMODE_RO; -} -static void arg_blind(void) -{ - captive_option_rwmode=CAPTIVE_OPTION_RWMODE_BLIND; -} -static void arg_rw(void) -{ - captive_option_rwmode=CAPTIVE_OPTION_RWMODE_RW; -} -static void arg_cdrom(void) -{ - captive_option_media=CAPTIVE_OPTION_MEDIA_CDROM; -} -static void arg_disk(void) -{ - captive_option_media=CAPTIVE_OPTION_MEDIA_DISK; -} - -static void arg_debug_messages(void) -{ - captive_debug_messages=TRUE; -} +void *_local_unwind2_addr; -static void captive_popt_callback - (poptContext con,enum poptCallbackReason reason,const struct poptOption *opt,const char *arg,const void *data); - -const struct poptOption captive_popt[]={ - { argInfo:POPT_ARG_INTL_DOMAIN, arg:(void *)PACKAGE }, - { argInfo:POPT_ARG_CALLBACK, arg:(void *)captive_popt_callback }, -#define POPT_OFFSET 2 -#define CAPTIVE_POPT(longname,argInfoP,argP,descripP,argDescripP) \ - { \ - longName: (longname), \ - shortName: 0, \ - argInfo: (argInfoP), \ - arg: (void *)argP, \ - val: 0, \ - descrip: (descripP), \ - argDescrip: (argDescripP), \ - } -#define CAPTIVE_POPT_STRING(longname,descripP,argDescripP) \ - CAPTIVE_POPT(longname,POPT_ARG_STRING,&captive_popt_optarg,descripP,argDescripP) -#define CAPTIVE_POPT_NONE(longname,descripP) \ - CAPTIVE_POPT(longname,POPT_ARG_NONE ,NULL ,descripP,NULL ) - - CAPTIVE_POPT_STRING("filesystem" ,N_("Path to .sys or .so filesystem module file"),N_("pathname")), - CAPTIVE_POPT_STRING("load-module" ,N_("Path to any W32 module to load w/o initialization"),N_("pathname")), - CAPTIVE_POPT_NONE( "ro" ,N_("Read/write mode: Any write access will be forbidden")), - CAPTIVE_POPT_NONE( "blind" ,N_("Read/write mode: All writes are just simulated in memory (default)")), - CAPTIVE_POPT_NONE( "rw" ,N_("Read/write mode: Write directly to the image file/device")), - CAPTIVE_POPT_NONE( "cdrom" ,N_("Media type: CD-ROM")), - CAPTIVE_POPT_NONE( "disk" ,N_("Media type: Disk (default)")), - CAPTIVE_POPT_NONE( "debug-messages",N_("Turn on debugging messages")), - -#undef CAPTIVE_POPT_NONE -#undef CAPTIVE_POPT_STRING -#undef CAPTIVE_POPT - POPT_TABLEEND - }; - -static const struct poptOption captive_popt_standalone[]={ - CAPTIVE_POPT_INCLUDE, - POPT_AUTOHELP - POPT_TABLEEND - }; - - -static void (*const popt_func_table[])(void)={ - arg_filesystem, - arg_load_module, - arg_ro, - arg_blind, - arg_rw, - arg_cdrom, - arg_disk, - arg_debug_messages, - }; - - -/* poptCallbackType captive_popt_callback */ -static void captive_popt_callback - (poptContext con,enum poptCallbackReason reason,const struct poptOption *opt,const char *arg,const void *data) +/* Acceleration hack for ntoskrnl/dbg/print.c/DbgPrint() */ +gboolean captive_get_debug_messages(void) { -gint funci; + g_return_val_if_fail(captive_options!=NULL,TRUE); - g_return_if_fail(reason==POPT_CALLBACK_REASON_OPTION); - - funci=(opt-(captive_popt+POPT_OFFSET)); - g_return_if_fail(funci>=0); - g_return_if_fail(funci<(gint)G_N_ELEMENTS(popt_func_table)); - if (popt_func_table[funci]) - (*popt_func_table[funci])(); - free(captive_popt_optarg); - captive_popt_optarg=NULL; /* sanity, shouldn't be needed */ + return captive_options->debug_messages; } -void *_local_unwind2_addr; - - static gboolean captive_w32_init(void) { NTSTATUS err; gboolean errbool; GIOStatus erriostatus; - g_return_val_if_fail(captive_option_filesystem!=NULL,FALSE); + g_return_val_if_fail(captive_options!=NULL,FALSE); + g_return_val_if_fail(captive_options->filesystem!=NULL,FALSE); - erriostatus=g_io_channel_set_encoding(captive_image_iochannel, + erriostatus=g_io_channel_set_encoding(captive_options->image_iochannel, NULL, /* encoding; force binary data */ NULL); /* error */ g_assert(erriostatus==G_IO_STATUS_NORMAL); /* captive_giochannel_size() only _after_ g_io_channel_set_encoding() ! */ - captive_image_size=captive_giochannel_size(captive_image_iochannel); + captive_image_size=captive_giochannel_size(captive_options->image_iochannel); g_return_val_if_fail(captive_image_size>0,FALSE); /* Part of reactos/ntoskrnl/ke/main.c/KiSystemStartup() begins. */ @@ -267,8 +156,8 @@ GIOStatus erriostatus; errbool=captive_disk_init(); g_return_val_if_fail(errbool==TRUE,FALSE); - while (captive_load_module) { -gchar *modulename=captive_load_module->data; + while (captive_options->load_module) { +gchar *modulename=captive_options->load_module->data; PMODULE_OBJECT ModuleObject_tmp; NTSTATUS err; @@ -278,10 +167,10 @@ NTSTATUS err; &ModuleObject_tmp); /* ModuleObjectp */ g_return_val_if_fail(NT_SUCCESS(err),FALSE); - captive_load_module=g_list_remove(captive_load_module,modulename); + captive_options->load_module=g_list_remove(captive_options->load_module,modulename); } - /* Patch 'ntoskrnl.exe' loaded by 'captive_load_module' above. */ + /* Patch 'ntoskrnl.exe' loaded by 'captive_options->load_module' above. */ { CHAR *KeNumberProcessorsp=captive_Module_GetExportAddress("ntoskrnl.exe","KeNumberProcessors"); @@ -295,7 +184,7 @@ NTSTATUS err; _local_unwind2_addr=captive_Module_GetExportAddress("ntoskrnl.exe","_local_unwind2"); /* Initialize 'FsRtlLegalAnsiCharacterArray'. - * It requires 'ntoskrnl.exe' loaded by 'captive_load_module' above; + * It requires 'ntoskrnl.exe' loaded by 'captive_options->load_module' above; * captive_kernel_patches() should not be needed. */ captive_FsRtlLegalAnsiCharacterArray_init(); @@ -315,7 +204,7 @@ NTSTATUS err; captive_DriverObject_ReinitRoutine=NULL; err=captive_LdrpLoadAndCallImage( &ModuleObject, /* ModuleObjectp */ - captive_utf8_to_UnicodeString_alloca(captive_option_filesystem), /* ModuleName */ + captive_utf8_to_UnicodeString_alloca(captive_options->filesystem), /* ModuleName */ &captive_DriverObject, /* DriverEntry_DriverObject */ captive_utf8_to_UnicodeString_alloca("\\captive\\filesystem")); /* DriverEntry_RegistryPath */ g_return_val_if_fail(NT_SUCCESS(err),FALSE); @@ -341,25 +230,17 @@ static void log_discard_func(const gchar *log_domain,GLogLevelFlags log_level,co /** * captive_init: - * @captive_args: String with possible options to parse by popt. - * %NULL value is permitted. - * @image_iochannel: Host OS file of the disk image to mount. - * %NULL value is permitted (initialization would not apply in such case). * - * Initializes %libcaptive and loads the specified filesystem. - * You can supply %NULL value for @image_iochannel - in such case no library - * initialization is done; only passed @captive_args are parsed. Function - * will return you %FALSE value as it is not yet initializied. + * Expects #captive_options: Parsed by captive_options_parse(). + * %NULL value is forbidden. Field #image_iochannel %NULL value is forbidden. * - * You should supply only @captive_args with %NULL @image_iochannel if you - * need to parse+examine the arguments to properly initialize @image_iochannel. + * Initializes %libcaptive and loads the specified filesystem. * * Returns: %TRUE if successfuly initialized. */ -gboolean captive_init(const gchar *captive_args,GIOChannel *image_iochannel) +gboolean captive_init(void) { gboolean errbool; -int errint; #ifdef MAINTAINER_MODE g_log_set_always_fatal(~(0 @@ -371,62 +252,13 @@ int errint; g_return_val_if_fail(active==FALSE,FALSE); + g_return_val_if_fail(captive_options!=NULL,FALSE); + g_return_val_if_fail(captive_options->image_iochannel!=NULL,FALSE); + /* Initialize GObject subsystem of GLib. */ g_type_init(); - /* (optionally) parse the given 'captive_args' string */ - if (captive_args) { -int captive_args_argc; -const char **captive_args_argv=NULL; -poptContext context; -gboolean r=FALSE; - - errint=poptParseArgvString(captive_args,&captive_args_argc,&captive_args_argv); - if (errint!=0) { - g_assert_not_reached(); /* argument parsing args_error */ - goto args_err; - } - context=poptGetContext( - PACKAGE, /* name */ - captive_args_argc,captive_args_argv, /* argc,argv */ - captive_popt_standalone, /* options */ - POPT_CONTEXT_KEEP_FIRST); - if (context==NULL) { - g_assert_not_reached(); /* argument recognization args_error */ - goto args_err_argv; - } - errint=poptReadDefaultConfig(context, - TRUE); /* useEnv */ - if (errint!=0) { - g_assert_not_reached(); /* argument recognization args_error */ - goto args_err_context; - } - errint=poptGetNextOpt(context); - if (errint!=-1) { - g_assert_not_reached(); /* some non-callbacked argument reached */ - goto args_err_context; - } - if (poptPeekArg(context)) { - g_assert_not_reached(); /* some non-"--"-prefixed argument reached */ - goto args_err_context; - } - r=TRUE; /* success */ -args_err_context: - poptFreeContext(context); -args_err_argv: - free(captive_args_argv); /* may be NULL here */ -args_err: - if (!r) { - puts("FIXME: HELP HERE"); - g_return_val_if_reached(r); - } - } - - /* If we were just requested to parse the arguments. */ - if (!image_iochannel) - return FALSE; - - if (!captive_debug_messages) { + if (!captive_options->debug_messages) { g_log_set_handler( G_LOG_DOMAIN, /* log_domain; "Captive" */ 0 /* log_levels */ @@ -439,11 +271,9 @@ args_err: NULL); /* user_data */ } - if (captive_option_rwmode==CAPTIVE_OPTION_RWMODE_BLIND) - captive_image_iochannel=(GIOChannel *)captive_giochannel_blind_new(image_iochannel); - else - captive_image_iochannel=image_iochannel; - captive_image_iochannel_orig=image_iochannel; + captive_options_image_iochannel_orig=captive_options->image_iochannel; + if (captive_options->rwmode==CAPTIVE_OPTION_RWMODE_BLIND) + captive_options->image_iochannel=(GIOChannel *)captive_giochannel_blind_new(captive_options->image_iochannel); /* Do not initialize 'captive_image_size' by captive_giochannel_size() here * as we yet need to do g_io_channel_set_encoding(). @@ -466,7 +296,7 @@ void captive_cc_flush(void); * captive_shutdown: * * Closes down %libcaptive. It should flush all pending buffers and successfuly - * close the filesystem. Variable #captive_image_iochannel will be set to %NULL, + * close the filesystem. Variable #captive_options->image_iochannel will be set to %NULL, * you should close such channel yourself. * * Returns: %TRUE if successfuly shutdown. @@ -476,7 +306,7 @@ gboolean captive_shutdown(void) GIOStatus erriostatus; g_return_val_if_fail(active==TRUE,FALSE); - g_return_val_if_fail(captive_image_iochannel!=NULL,FALSE); + g_return_val_if_fail(captive_options->image_iochannel!=NULL,FALSE); /* Invoke all pending idle functions just to not to forget for anything... */ while (g_main_context_iteration( @@ -511,19 +341,19 @@ GIOStatus erriostatus; /* libcaptive is not authorized to shutdown 'captive_image_channel'. */ erriostatus=g_io_channel_flush( - captive_image_iochannel, /* channel */ + captive_options->image_iochannel, /* channel */ NULL); /* error */ g_assert(erriostatus==G_IO_STATUS_NORMAL); - /* 'captive_image_iochannel' may be blinded wrapper. */ - if (captive_image_iochannel!=captive_image_iochannel_orig) { + /* 'captive_options->image_iochannel' may be blinded wrapper. */ + if (captive_options->image_iochannel!=captive_options_image_iochannel_orig) { erriostatus=g_io_channel_flush( - captive_image_iochannel_orig, /* channel */ + captive_options_image_iochannel_orig, /* channel */ NULL); /* error */ g_assert(erriostatus==G_IO_STATUS_NORMAL); } - captive_image_iochannel=NULL; + captive_options->image_iochannel=NULL; active=FALSE; return TRUE; diff --git a/src/libcaptive/client/init.h b/src/libcaptive/client/init.h new file mode 100644 index 0000000..df0b188 --- /dev/null +++ b/src/libcaptive/client/init.h @@ -0,0 +1,35 @@ +/* $Id$ + * Include file for init and cleanup code of libcaptive to be called by client application + * Copyright (C) 2003 Jan Kratochvil + * + * 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; exactly version 2 of June 1991 is required + * + * 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 _CAPTIVE_CLIENT_INIT_H +#define _CAPTIVE_CLIENT_INIT_H 1 + + +#include + + +G_BEGIN_DECLS + +gboolean captive_init(void); +gboolean captive_shutdown(void); + +G_END_DECLS + + +#endif /* _CAPTIVE_CLIENT_INIT_H */ diff --git a/src/libcaptive/client/lib.c b/src/libcaptive/client/lib.c index 505a7d2..3847cde 100644 --- a/src/libcaptive/client/lib.c +++ b/src/libcaptive/client/lib.c @@ -26,7 +26,7 @@ #include "reactos/ntos/rtl.h" /* for InitializeObjectAttributes() */ #include "captive/unicode.h" #include /* for gnome_vfs_unescape_string() */ -#include "captive/client.h" +#include "captive/options.h" /* function will leave g_malloc()ed 'ObjectAttributes->ObjectName'! @@ -50,7 +50,7 @@ const gchar *media_root; * On the other side it will somehow get managed automatically and it works even * without the trailing "\\." for root directory open - don't ask me why. :-) */ - switch (captive_option_media) { + switch (captive_options->media) { case CAPTIVE_OPTION_MEDIA_CDROM: media_root="\\Device\\CdRom0"; break; /* libcaptive/storage/cdrom.c */ case CAPTIVE_OPTION_MEDIA_DISK: media_root="\\Device\\CaptiveHarddisk0"; break; /* libcaptive/storage/disk.c */ default: diff --git a/src/libcaptive/client/options.c b/src/libcaptive/client/options.c new file mode 100644 index 0000000..457fbcb --- /dev/null +++ b/src/libcaptive/client/options.c @@ -0,0 +1,238 @@ +/* $Id$ + * User options handling code of libcaptive + * Copyright (C) 2003 Jan Kratochvil + * + * 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; exactly version 2 of June 1991 is required + * + * 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 + */ + + +#include "config.h" + +#include "captive/options.h" /* self */ +#include +#include "captive/macros.h" +#include +#include + + +void captive_options_init(struct captive_options *options) +{ + g_return_if_fail(options!=NULL); + + CAPTIVE_MEMZERO(options); + options->rwmode=CAPTIVE_OPTION_RWMODE_BLIND; + options->media=CAPTIVE_OPTION_MEDIA_DISK; + options->debug_messages=FALSE; + options->load_module=NULL; +} + + +void captive_options_copy(struct captive_options *dest,const struct captive_options *src) +{ + g_return_if_fail(dest!=NULL); + g_return_if_fail(src!=NULL); + g_return_if_fail(dest!=src); + + memcpy(dest,src,sizeof(*dest)); + + dest->filesystem=g_strdup(src->filesystem); + g_io_channel_ref(dest->image_iochannel); +} + + +void captive_options_free(struct captive_options *options) +{ + g_return_if_fail(options!=NULL); + + g_free(options->filesystem); + g_io_channel_unref(options->image_iochannel); +} + + +static gchar *captive_popt_optarg; + + +static void arg_filesystem(void) +{ + g_free(captive_options->filesystem); + captive_options->filesystem=g_strdup(captive_popt_optarg); +} + +static void arg_load_module(void) +{ + captive_options->load_module=g_list_append(captive_options->load_module,g_strdup(captive_popt_optarg)); +} + +static void arg_ro(void) +{ + captive_options->rwmode=CAPTIVE_OPTION_RWMODE_RO; +} +static void arg_blind(void) +{ + captive_options->rwmode=CAPTIVE_OPTION_RWMODE_BLIND; +} +static void arg_rw(void) +{ + captive_options->rwmode=CAPTIVE_OPTION_RWMODE_RW; +} + +static void arg_cdrom(void) +{ + captive_options->media=CAPTIVE_OPTION_MEDIA_CDROM; +} +static void arg_disk(void) +{ + captive_options->media=CAPTIVE_OPTION_MEDIA_DISK; +} + +static void arg_debug_messages(void) +{ + captive_options->debug_messages=TRUE; +} + + +static void captive_popt_callback + (poptContext con,enum poptCallbackReason reason,const struct poptOption *opt,const char *arg,const void *data); + +const struct poptOption captive_popt[]={ + { argInfo:POPT_ARG_INTL_DOMAIN, arg:(void *)PACKAGE }, + { argInfo:POPT_ARG_CALLBACK, arg:(void *)captive_popt_callback }, +#define POPT_OFFSET 2 +#define CAPTIVE_POPT(longname,argInfoP,argP,descripP,argDescripP) \ + { \ + longName: (longname), \ + shortName: 0, \ + argInfo: (argInfoP), \ + arg: (void *)argP, \ + val: 0, \ + descrip: (descripP), \ + argDescrip: (argDescripP), \ + } +#define CAPTIVE_POPT_STRING(longname,descripP,argDescripP) \ + CAPTIVE_POPT(longname,POPT_ARG_STRING,&captive_popt_optarg,descripP,argDescripP) +#define CAPTIVE_POPT_NONE(longname,descripP) \ + CAPTIVE_POPT(longname,POPT_ARG_NONE ,NULL ,descripP,NULL ) + + CAPTIVE_POPT_STRING("filesystem" ,N_("Path to .sys or .so filesystem module file"),N_("pathname")), + CAPTIVE_POPT_STRING("load-module" ,N_("Path to any W32 module to load w/o initialization"),N_("pathname")), + CAPTIVE_POPT_NONE( "ro" ,N_("Read/write mode: Any write access will be forbidden")), + CAPTIVE_POPT_NONE( "blind" ,N_("Read/write mode: All writes are just simulated in memory (default)")), + CAPTIVE_POPT_NONE( "rw" ,N_("Read/write mode: Write directly to the image file/device")), + CAPTIVE_POPT_NONE( "cdrom" ,N_("Media type: CD-ROM")), + CAPTIVE_POPT_NONE( "disk" ,N_("Media type: Disk (default)")), + CAPTIVE_POPT_NONE( "debug-messages",N_("Turn on debugging messages")), + +#undef CAPTIVE_POPT_NONE +#undef CAPTIVE_POPT_STRING +#undef CAPTIVE_POPT + POPT_TABLEEND + }; + +static const struct poptOption captive_popt_standalone[]={ + CAPTIVE_POPT_INCLUDE, + POPT_AUTOHELP + POPT_TABLEEND + }; + + +static void (*const popt_func_table[])(void)={ + arg_filesystem, + arg_load_module, + arg_ro, + arg_blind, + arg_rw, + arg_cdrom, + arg_disk, + arg_debug_messages, + }; + + +/* poptCallbackType captive_popt_callback */ +static void captive_popt_callback + (poptContext con,enum poptCallbackReason reason,const struct poptOption *opt,const char *arg,const void *data) +{ +gint funci; + + g_return_if_fail(reason==POPT_CALLBACK_REASON_OPTION); + + funci=(opt-(captive_popt+POPT_OFFSET)); + g_return_if_fail(funci>=0); + g_return_if_fail(funci<(gint)G_N_ELEMENTS(popt_func_table)); + if (popt_func_table[funci]) + (*popt_func_table[funci])(); + free(captive_popt_optarg); + captive_popt_optarg=NULL; /* sanity, shouldn't be needed */ +} + + +gboolean captive_options_parse(struct captive_options *options,const gchar *captive_args) +{ +int errint; +int captive_args_argc; +const char **captive_args_argv=NULL; +poptContext context; +gboolean r=FALSE; + + g_return_val_if_fail(options!=NULL,FALSE); + g_return_val_if_fail(captive_args!=NULL,FALSE); + + g_assert(captive_options==NULL); + captive_options=options; + + errint=poptParseArgvString(captive_args,&captive_args_argc,&captive_args_argv); + if (errint!=0) { + g_assert_not_reached(); /* argument parsing args_error */ + goto args_err; + } + context=poptGetContext( + PACKAGE, /* name */ + captive_args_argc,captive_args_argv, /* argc,argv */ + captive_popt_standalone, /* options */ + POPT_CONTEXT_KEEP_FIRST); + if (context==NULL) { + g_assert_not_reached(); /* argument recognization args_error */ + goto args_err_argv; + } + errint=poptReadDefaultConfig(context, + TRUE); /* useEnv */ + if (errint!=0) { + g_assert_not_reached(); /* argument recognization args_error */ + goto args_err_context; + } + errint=poptGetNextOpt(context); + if (errint!=-1) { + g_assert_not_reached(); /* some non-callbacked argument reached */ + goto args_err_context; + } + if (poptPeekArg(context)) { + g_assert_not_reached(); /* some non-"--"-prefixed argument reached */ + goto args_err_context; + } + r=TRUE; /* success */ +args_err_context: + poptFreeContext(context); +args_err_argv: + free(captive_args_argv); /* may be NULL here */ +args_err: + if (!r) { + puts("FIXME: HELP HERE"); + captive_options=NULL; + g_return_val_if_reached(r); + } + + g_assert(captive_options!=NULL); + captive_options=NULL; + + return TRUE; +} diff --git a/src/libcaptive/client/vfs.c b/src/libcaptive/client/vfs.c new file mode 100644 index 0000000..bb3cd97 --- /dev/null +++ b/src/libcaptive/client/vfs.c @@ -0,0 +1,133 @@ +/* $Id$ + * captive vfs 'vfs' interface to reactos + * Copyright (C) 2002-2003 Jan Kratochvil + * + * 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; exactly version 2 of June 1991 is required + * + * 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 + */ + + +#include "config.h" + +#include "captive/client-vfs.h" /* self */ +#include "vfs.h" /* self-priv */ +#include +#include "captive/macros.h" +#include "captive/sandbox.h" +#include "init.h" + + +static gpointer captive_vfs_object_parent_class=NULL; + + +static GnomeVFSResult captive_vfs_close(CaptiveVfsObject *captive_vfs_object); + +static void captive_vfs_object_finalize(CaptiveVfsObject *captive_vfs_object) +{ +GnomeVFSResult errvfsresult; + + g_return_if_fail(captive_vfs_object!=NULL); + + errvfsresult=captive_vfs_close(captive_vfs_object); + g_assert(errvfsresult==GNOME_VFS_OK); + + G_OBJECT_CLASS(captive_vfs_object_parent_class)->finalize((GObject *)captive_vfs_object); +} + + +static void captive_vfs_object_class_init(CaptiveVfsObjectClass *class) +{ +GObjectClass *gobject_class=G_OBJECT_CLASS(class); + + captive_vfs_object_parent_class=g_type_class_ref(G_TYPE_OBJECT); + gobject_class->finalize=(void (*)(GObject *object))captive_vfs_object_finalize; +} + + +static void captive_vfs_object_init(CaptiveVfsObject *captive_vfs_object) +{ + CAPTIVE_MEMZERO(&captive_vfs_object->options); +} + + +GType captive_vfs_object_get_type(void) +{ +static GType captive_vfs_object_type=0; + + if (!captive_vfs_object_type) { +static const GTypeInfo captive_vfs_object_info={ + sizeof(CaptiveVfsObjectClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc)captive_vfs_object_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(CaptiveVfsObject), + 5, /* n_preallocs */ + (GInstanceInitFunc)captive_vfs_object_init, + }; + + captive_vfs_object_type=g_type_register_static(G_TYPE_OBJECT, + "CaptiveVfsObject",&captive_vfs_object_info,0); + } + + return captive_vfs_object_type; +} + + +GnomeVFSResult captive_vfs_new + (CaptiveVfsObject **captive_vfs_object_return,const struct captive_options *options) +{ +CaptiveVfsObject *captive_vfs_object; +gboolean errbool; + + g_return_val_if_fail(captive_vfs_object_return!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); + g_return_val_if_fail(options!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); + + *captive_vfs_object_return=NULL; + + captive_vfs_object=g_object_new( + CAPTIVE_VFS_TYPE_OBJECT, /* object_type */ + NULL); /* first_property_name; FIXME: support properties */ + + captive_options_copy(&captive_vfs_object->options,options); + + g_assert(captive_options==NULL); + captive_options=&captive_vfs_object->options; + + errbool=captive_init(); + g_assert(errbool==TRUE); + + *captive_vfs_object_return=captive_vfs_object; + return GNOME_VFS_OK; +} + + +static GnomeVFSResult captive_vfs_close(CaptiveVfsObject *captive_vfs_object) +{ +gboolean errbool; + + if (CAPTIVE_IS_SANDBOX_PARENT()) + return captive_sandbox_parent_vfs_close(captive_vfs_object); + + g_return_val_if_fail(captive_vfs_object!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS); + + g_assert(captive_options==&captive_vfs_object->options); + errbool=captive_shutdown(); + g_assert(errbool==TRUE); + + captive_options=NULL; + captive_options_free(&captive_vfs_object->options); + + return GNOME_VFS_OK; +} diff --git a/src/libcaptive/client/vfs.h b/src/libcaptive/client/vfs.h new file mode 100644 index 0000000..b1103e4 --- /dev/null +++ b/src/libcaptive/client/vfs.h @@ -0,0 +1,43 @@ +/* $Id$ + * Include vfs for captive 'vfs' private interface to reactos + * Copyright (C) 2003 Jan Kratochvil + * + * 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; exactly version 2 of June 1991 is required + * + * 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 _CAPTIVE_CLIENT_PRIV_VFS_H +#define _CAPTIVE_CLIENT_PRIV_VFS_H 1 + + +#include +#include + + +G_BEGIN_DECLS + +struct _CaptiveVfsObject { + GObject parent_instance; + + /*< private >*/ + struct captive_options options; + }; +struct _CaptiveVfsObjectClass { + GObjectClass parent_class; + }; + +G_END_DECLS + + +#endif /* _CAPTIVE_CLIENT_PRIV_VFS_H */ diff --git a/src/libcaptive/include/captive/Makefile.am b/src/libcaptive/include/captive/Makefile.am index 7351c2e..a8cd87b 100644 --- a/src/libcaptive/include/captive/Makefile.am +++ b/src/libcaptive/include/captive/Makefile.am @@ -23,13 +23,14 @@ pkginclude_HEADERS+= \ calltype_reactos.h \ client-directory.h \ client-file.h \ - client.h \ + client-vfs.h \ config2.h \ ldr.h \ ldr_exports.h \ leave.h \ macros.h \ mm.h \ + options.h \ ps_reactos.h \ rtl-file.h \ sandbox.h \ diff --git a/src/libcaptive/include/captive/client-directory.h b/src/libcaptive/include/captive/client-directory.h index 5b70dc9..22a031d 100644 --- a/src/libcaptive/include/captive/client-directory.h +++ b/src/libcaptive/include/captive/client-directory.h @@ -24,6 +24,7 @@ #include #include #include /* for GnomeVFSFileInfo */ +#include "captive/client-vfs.h" G_BEGIN_DECLS @@ -40,8 +41,11 @@ typedef struct _CaptiveDirectoryObjectClass CaptiveDirectoryObjectClass; GType captive_directory_object_get_type(void); -GnomeVFSResult captive_directory_new_open(CaptiveDirectoryObject **captive_directory_object_return,const gchar *pathname); -GnomeVFSResult captive_directory_new_make(CaptiveDirectoryObject **captive_directory_object_return,const gchar *pathname,guint perm); +GnomeVFSResult captive_directory_new_open(CaptiveDirectoryObject **captive_directory_object_return, + CaptiveVfsObject *captive_vfs_object,const gchar *pathname); +GnomeVFSResult captive_directory_new_make(CaptiveDirectoryObject **captive_directory_object_return, + CaptiveVfsObject *captive_vfs_object,const gchar *pathname,guint perm); +CaptiveVfsObject *captive_directory_get_vfs(CaptiveDirectoryObject *captive_directory_object); GnomeVFSResult captive_directory_read(CaptiveDirectoryObject *captive_directory_object,GnomeVFSFileInfo *file_info); GnomeVFSResult captive_directory_remove(CaptiveDirectoryObject *captive_directory_object); diff --git a/src/libcaptive/include/captive/client-file.h b/src/libcaptive/include/captive/client-file.h index 7c3e344..46a33dd 100644 --- a/src/libcaptive/include/captive/client-file.h +++ b/src/libcaptive/include/captive/client-file.h @@ -24,6 +24,7 @@ #include #include #include /* for GnomeVFSOpenMode */ +#include "captive/client-vfs.h" G_BEGIN_DECLS @@ -40,10 +41,11 @@ typedef struct _CaptiveFileObjectClass CaptiveFileObjectClass; GType captive_file_object_get_type(void); -GnomeVFSResult captive_file_new_open - (CaptiveFileObject **captive_file_object_return,const gchar *pathname,GnomeVFSOpenMode mode); -GnomeVFSResult captive_file_new_create - (CaptiveFileObject **captive_file_object_return,const gchar *pathname,GnomeVFSOpenMode mode,gboolean exclusive,guint perm); +GnomeVFSResult captive_file_new_open(CaptiveFileObject **captive_file_object_return, + CaptiveVfsObject *captive_vfs_object,const gchar *pathname,GnomeVFSOpenMode mode); +GnomeVFSResult captive_file_new_create(CaptiveFileObject **captive_file_object_return, + CaptiveVfsObject *captive_vfs_object,const gchar *pathname,GnomeVFSOpenMode mode,gboolean exclusive,guint perm); +CaptiveVfsObject *captive_file_get_vfs(CaptiveFileObject *captive_file_object); GnomeVFSResult captive_file_read(CaptiveFileObject *captive_file_object, gpointer buffer,GnomeVFSFileSize num_bytes,GnomeVFSFileSize *bytes_read_return); GnomeVFSResult captive_file_write(CaptiveFileObject *captive_file_object, diff --git a/src/libcaptive/include/captive/client-vfs.h b/src/libcaptive/include/captive/client-vfs.h new file mode 100644 index 0000000..38f2ad9 --- /dev/null +++ b/src/libcaptive/include/captive/client-vfs.h @@ -0,0 +1,52 @@ +/* $Id$ + * Include file with client general VFS access to libcaptive + * Copyright (C) 2003 Jan Kratochvil + * + * 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; exactly version 2 of June 1991 is required + * + * 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 _CAPTIVE_CLIENT_VFS_H +#define _CAPTIVE_CLIENT_VFS_H 1 + + +#include +#include +#include +#include "captive/options.h" /* for captive_options */ + + +G_BEGIN_DECLS + +#define CAPTIVE_VFS_TYPE_OBJECT (captive_vfs_object_get_type()) +#define CAPTIVE_VFS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST((object),CAPTIVE_VFS_TYPE_OBJECT,CaptiveVfsObject)) +#define CAPTIVE_VFS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),CAPTIVE_VFS_TYPE_OBJECT,CaptiveVfsObjectClass)) +#define CAPTIVE_VFS_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE((object),CAPTIVE_VFS_TYPE_OBJECT)) +#define CAPTIVE_VFS_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),CAPTIVE_VFS_TYPE_OBJECT)) +#define CAPTIVE_VFS_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj),CAPTIVE_VFS_TYPE_OBJECT,CaptiveVfsObjectClass)) +typedef struct _CaptiveVfsObject CaptiveVfsObject; +typedef struct _CaptiveVfsObjectClass CaptiveVfsObjectClass; + + +GType captive_vfs_object_get_type(void); + +struct captive_options; + +GnomeVFSResult captive_vfs_new + (CaptiveVfsObject **captive_vfs_object_return,const struct captive_options *options); + +G_END_DECLS + + +#endif /* _CAPTIVE_CLIENT_VFS_H */ diff --git a/src/libcaptive/include/captive/client.h b/src/libcaptive/include/captive/client.h deleted file mode 100644 index 980af34..0000000 --- a/src/libcaptive/include/captive/client.h +++ /dev/null @@ -1,66 +0,0 @@ -/* $Id$ - * Include file with client-application access to libcaptive - * Copyright (C) 2002 Jan Kratochvil - * - * 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; exactly version 2 of June 1991 is required - * - * 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 _CAPTIVE_CLIENT_H -#define _CAPTIVE_CLIENT_H 1 - - -#include -#include -#include -#include - - -G_BEGIN_DECLS - -extern const struct poptOption captive_popt[]; -#define CAPTIVE_POPT_INCLUDE \ - { NULL,'\0',POPT_ARG_INCLUDE_TABLE,(struct poptOption *)&captive_popt,0,"Captive" } - -extern gchar *captive_option_filesystem; -enum captive_option_rwmode { - CAPTIVE_OPTION_RWMODE_RO, - CAPTIVE_OPTION_RWMODE_BLIND, - CAPTIVE_OPTION_RWMODE_RW, - }; -extern enum captive_option_rwmode captive_option_rwmode; -enum captive_option_media { - CAPTIVE_OPTION_MEDIA_CDROM, - CAPTIVE_OPTION_MEDIA_DISK, - }; -extern enum captive_option_media captive_option_media; -extern gboolean captive_debug_messages; -extern GIOChannel *captive_image_iochannel; -/** - * captive_image_size: - * - * Size of #captive_image_iochannel. Empty files are rejected and therefore - * this value is always >0 after successful captive_init(). - * Value is detected by captive_giochannel_size(captive_image_iochannel). - */ -extern guint64 captive_image_size; - - -gboolean captive_init(const gchar *captive_args,GIOChannel *image_iochannel); -gboolean captive_shutdown(void); - -G_END_DECLS - - -#endif /* _CAPTIVE_CLIENT_H */ diff --git a/src/libcaptive/include/captive/options.h b/src/libcaptive/include/captive/options.h new file mode 100644 index 0000000..41c1e15 --- /dev/null +++ b/src/libcaptive/include/captive/options.h @@ -0,0 +1,74 @@ +/* $Id$ + * Include file with captive_options definition of libcaptive + * Copyright (C) 2003 Jan Kratochvil + * + * 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; exactly version 2 of June 1991 is required + * + * 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 _CAPTIVE_CLIENT_OPTIONS_H +#define _CAPTIVE_CLIENT_OPTIONS_H 1 + + +#include +#include +#include +#include + + +G_BEGIN_DECLS + +extern const struct poptOption captive_popt[]; +#define CAPTIVE_POPT_INCLUDE \ + { NULL,'\0',POPT_ARG_INCLUDE_TABLE,(struct poptOption *)&captive_popt,0,"Captive" } + + +enum captive_option_rwmode { + CAPTIVE_OPTION_RWMODE_RO, + CAPTIVE_OPTION_RWMODE_BLIND, + CAPTIVE_OPTION_RWMODE_RW, + }; + +enum captive_option_media { + CAPTIVE_OPTION_MEDIA_CDROM, + CAPTIVE_OPTION_MEDIA_DISK, + }; + +struct captive_options { + gchar *filesystem; + enum captive_option_rwmode rwmode; + enum captive_option_media media; + gboolean debug_messages; + GIOChannel *image_iochannel; + GList *load_module; /* of 'gchar *' */ + }; + +/** + * captive_options: + * Current options set in one CORBA sandboxed child. + * It is also set when run in non-CORBA debugging mode. + * Set to %NULL in the CORBA master process. + */ +extern struct captive_options *captive_options; + +/* Functions handle just the fields, not the structure itself. */ +void captive_options_init(struct captive_options *options); +void captive_options_copy(struct captive_options *dest,const struct captive_options *src); +void captive_options_free(struct captive_options *options); +gboolean captive_options_parse(struct captive_options *options,const gchar *captive_args); + +G_END_DECLS + + +#endif /* _CAPTIVE_CLIENT_OPTIONS_H */ diff --git a/src/libcaptive/include/captive/storage.h b/src/libcaptive/include/captive/storage.h index 15679cd..af4597c 100644 --- a/src/libcaptive/include/captive/storage.h +++ b/src/libcaptive/include/captive/storage.h @@ -28,6 +28,16 @@ G_BEGIN_DECLS +/** + * captive_image_size: + * + * Size of #captive_image_iochannel. Empty files are rejected and therefore + * this value is always >0 after successful captive_init(). + * Value is detected by captive_giochannel_size(captive_image_iochannel). + */ +extern guint64 captive_image_size; + + guint64 captive_giochannel_size(GIOChannel *channel); gboolean captive_cdrom_init(void); gboolean captive_disk_init(void); diff --git a/src/libcaptive/sandbox/Makefile.am b/src/libcaptive/sandbox/Makefile.am index 3b34fb7..42e5705 100644 --- a/src/libcaptive/sandbox/Makefile.am +++ b/src/libcaptive/sandbox/Makefile.am @@ -34,8 +34,10 @@ libsandbox_la_SOURCES= \ server-GlibLogFunc.h \ server-Directory.c \ server-Directory.h \ - server-VFS.c \ - server-VFS.h + server-File.c \ + server-File.h \ + server-Vfs.c \ + server-Vfs.h libsandbox_la_CFLAGS=$(ORBIT_CFLAGS) $(LINC_CFLAGS) $(GNOME_VFS_MODULE_CFLAGS) diff --git a/src/libcaptive/sandbox/sandbox.idl b/src/libcaptive/sandbox/sandbox.idl index ad1c13c..e57dfed 100644 --- a/src/libcaptive/sandbox/sandbox.idl +++ b/src/libcaptive/sandbox/sandbox.idl @@ -1,6 +1,6 @@ /* $Id$ * CORBA ORBit IDL definition of sandbox intra-captive interface - * Copyright (C) 2002 Jan Kratochvil + * Copyright (C) 2002-2003 Jan Kratochvil * * 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 @@ -24,7 +24,8 @@ module Captive GnomeVFSResult gnome_vfs_result; }; - typedef unsigned long GLogLevelFlags; /* enum */ + + typedef unsigned long GLogLevelFlags; /* enum mask */ struct GlibLogMessage { /* accepted by 'GLogFunc' */ /* string log_domain; always "Captive" */ GLogLevelFlags log_level; @@ -39,38 +40,77 @@ module Captive void glibLogFunc(in GlibLogMessage glib_log_message); }; - interface Directory - { - enum GnomeVFSFileType { - GNOME_VFS_FILE_TYPE_UNKNOWN, - GNOME_VFS_FILE_TYPE_REGULAR, - GNOME_VFS_FILE_TYPE_DIRECTORY, - GNOME_VFS_FILE_TYPE_SOCKET, - GNOME_VFS_FILE_TYPE_CHARACTER_DEVICE, - GNOME_VFS_FILE_TYPE_BLOCK_DEVICE - }; - typedef unsigned short GnomeVFSFilePermissions; - typedef unsigned long long time_t; - typedef unsigned long long GnomeVFSFileSize; - struct GnomeVFSFileInfo { - string name; /* Base name of the file (no path). */ - /* File type (i.e. regular, directory, block device...). */ - GnomeVFSFileType type; - GnomeVFSFilePermissions permissions; /* File permissions. */ - GnomeVFSFileSize size; /* Size in bytes. */ - GnomeVFSFileSize block_count; /* Size measured in units of 512-byte blocks. */ - /* Access, modification and change times. */ - time_t atime; /* not present if ==(time_t)0 */ - time_t mtime; /* not present if ==(time_t)0 */ - time_t ctime; /* not present if ==(time_t)0 */ - }; + + typedef unsigned long GnomeVFSFileType; /* enum */ + typedef unsigned short GnomeVFSFilePermissions; + typedef unsigned long long time_t; + typedef unsigned long long GnomeVFSFileSize; + typedef unsigned long long GnomeVFSFileFlags; + typedef long long GnomeVFSFileOffset; + typedef unsigned long GnomeVFSSeekPosition; /* enum */ + typedef unsigned long GnomeVFSSetFileInfoMask; /* enum mask */ + typedef unsigned long long GnomeVFSOpenMode; /* enum mask */ + struct GnomeVFSFileInfo { + string name; /* Base name of the file (no path). */ + /* File type (i.e. regular, directory, block device...). */ + GnomeVFSFileType type; + boolean type_valid; + GnomeVFSFilePermissions permissions; /* File permissions. */ + boolean permissions_valid; + GnomeVFSFileSize size; /* Size in bytes. */ + boolean size_valid; + GnomeVFSFileSize block_count; /* Size measured in units of 512-byte blocks. */ + boolean block_count_valid; + /* Access, modification and change times. */ + time_t atime; /* not valid if ==(time_t)0 */ + time_t mtime; /* not valid if ==(time_t)0 */ + time_t ctime; /* not valid if ==(time_t)0 */ + GnomeVFSFileFlags flags; + boolean flags_valid; + }; + + typedef sequence Bytes; + + + interface Directory { GnomeVFSFileInfo read() raises (GnomeVFSResultException,GlibLogMessageFatal); + void remove() + raises (GnomeVFSResultException,GlibLogMessageFatal); + }; + + + interface File { + void read(out Bytes buffer,in GnomeVFSFileSize num_bytes,out GnomeVFSFileSize bytes_read_return) + raises (GnomeVFSResultException,GlibLogMessageFatal); + void write(in Bytes buffer,out GnomeVFSFileSize bytes_written_return) + raises (GnomeVFSResultException,GlibLogMessageFatal); + void seek(in GnomeVFSSeekPosition whence,in GnomeVFSFileOffset offset) + raises (GnomeVFSResultException,GlibLogMessageFatal); + void tell(out GnomeVFSFileOffset offset_return) + raises (GnomeVFSResultException,GlibLogMessageFatal); + void remove() + raises (GnomeVFSResultException,GlibLogMessageFatal); + void file_info_get(out GnomeVFSFileInfo file_info) + raises (GnomeVFSResultException,GlibLogMessageFatal); + void file_info_set(in GnomeVFSFileInfo file_info,in GnomeVFSSetFileInfoMask mask) + raises (GnomeVFSResultException,GlibLogMessageFatal); + void truncate(in GnomeVFSFileSize file_size) + raises (GnomeVFSResultException,GlibLogMessageFatal); + void move(in string pathname_new,in boolean force_replace) + raises (GnomeVFSResultException,GlibLogMessageFatal); }; - interface VFS - { + + + interface Vfs { void registerGlibLogFunc(in GlibLogFunc glib_log_func); - Directory openDirectory(in string pathname) + Directory directory_new_open(in string pathname) + raises (GnomeVFSResultException,GlibLogMessageFatal); + Directory directory_new_make(in string pathname,in GnomeVFSFilePermissions perm) + raises (GnomeVFSResultException,GlibLogMessageFatal); + File file_new_open(in string pathname,in GnomeVFSOpenMode mode) + raises (GnomeVFSResultException,GlibLogMessageFatal); + File file_new_create(in string pathname,in GnomeVFSOpenMode mode,in boolean exclusive,in unsigned long perm) raises (GnomeVFSResultException,GlibLogMessageFatal); }; }; diff --git a/src/libcaptive/sandbox/server-Directory.c b/src/libcaptive/sandbox/server-Directory.c index 01c42d4..f863540 100644 --- a/src/libcaptive/sandbox/server-Directory.c +++ b/src/libcaptive/sandbox/server-Directory.c @@ -30,7 +30,7 @@ typedef struct { PortableServer_POA poa; } impl_POA_Captive_Directory; -static Captive_Directory_GnomeVFSFileInfo *impl_Captive_Directory_read +static Captive_GnomeVFSFileInfo *impl_Captive_Directory_read (impl_POA_Captive_Directory *servant,CORBA_Environment *ev); static PortableServer_ServantBase__epv impl_Captive_Directory_base_epv={ @@ -66,12 +66,12 @@ PortableServer_ObjectId *objid; } -static Captive_Directory_GnomeVFSFileInfo *impl_Captive_Directory_read +static Captive_GnomeVFSFileInfo *impl_Captive_Directory_read (impl_POA_Captive_Directory *servant,CORBA_Environment *ev) { -Captive_Directory_GnomeVFSFileInfo *retval; +Captive_GnomeVFSFileInfo *retval; - retval=Captive_Directory_GnomeVFSFileInfo__alloc(); + retval=Captive_GnomeVFSFileInfo__alloc(); /* CORBA_string name; Captive_Directory_GnomeVFSFileType type; diff --git a/src/libcaptive/sandbox/server-File.c b/src/libcaptive/sandbox/server-File.c new file mode 100644 index 0000000..056ac74 --- /dev/null +++ b/src/libcaptive/sandbox/server-File.c @@ -0,0 +1,86 @@ +/* $Id$ + * CORBA/ORBit server side of File object, ran by sandbox_child() + * Copyright (C) 2003 Jan Kratochvil + * + * 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; exactly version 2 of June 1991 is required + * + * 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 + */ + + +#include "config.h" + +#include "server-File.h" /* self */ +#include "sandbox.h" +#include +#include "captive/macros.h" + + +typedef struct { + POA_Captive_File servant; + PortableServer_POA poa; + } impl_POA_Captive_File; + +static Captive_GnomeVFSFileInfo *impl_Captive_File_read + (impl_POA_Captive_File *servant,CORBA_Environment *ev); + +static PortableServer_ServantBase__epv impl_Captive_File_base_epv={ + NULL, /* _private data */ + NULL, /* finalize routine */ + NULL, /* default_POA routine */ + }; +static POA_Captive_File__epv impl_Captive_File_epv={ + NULL, /* _private */ + (gpointer)&impl_Captive_File_read, + }; +static POA_Captive_File__vepv impl_Captive_File_vepv={ + &impl_Captive_File_base_epv, + &impl_Captive_File_epv, + }; + + +Captive_File impl_Captive_File__create(PortableServer_POA poa,CORBA_Environment *ev) +{ +Captive_File retval; +impl_POA_Captive_File *newservant; +PortableServer_ObjectId *objid; + + captive_new0(newservant); /* FIXME: leak */ + newservant->servant.vepv=&impl_Captive_File_vepv; + newservant->poa=poa; + POA_Captive_File__init((PortableServer_Servant)newservant,ev); + objid=PortableServer_POA_activate_object(poa,newservant,ev); + CORBA_free(objid); + retval=PortableServer_POA_servant_to_reference(poa,newservant,ev); + + return retval; +} + + +static Captive_GnomeVFSFileInfo *impl_Captive_File_read + (impl_POA_Captive_File *servant,CORBA_Environment *ev) +{ +Captive_GnomeVFSFileInfo *retval; + + retval=Captive_GnomeVFSFileInfo__alloc(); +/* + CORBA_string name; + Captive_File_GnomeVFSFileType type; + Captive_File_GnomeVFSFilePermissions permissions; + Captive_File_GnomeVFSFileSize size; + Captive_File_GnomeVFSFileSize block_count; + Captive_File_time_t atime; + Captive_File_time_t mtime; + Captive_File_time_t ctime; +*/ + return retval; +} diff --git a/src/libcaptive/sandbox/server-VFS.h b/src/libcaptive/sandbox/server-File.h similarity index 73% rename from src/libcaptive/sandbox/server-VFS.h rename to src/libcaptive/sandbox/server-File.h index 8f822ca..4be50af 100644 --- a/src/libcaptive/sandbox/server-VFS.h +++ b/src/libcaptive/sandbox/server-File.h @@ -1,5 +1,5 @@ /* $Id$ - * Include file for CORBA/ORBit server side of VFS object + * Include file for CORBA/ORBit server side of File object * Copyright (C) 2003 Jan Kratochvil * * This program is free software; you can redistribute it and/or modify @@ -17,8 +17,8 @@ */ -#ifndef _SERVER_VFS_H -#define _SERVER_VFS_H 1 +#ifndef _SERVER_DIRECTORY_H +#define _SERVER_DIRECTORY_H 1 #include @@ -27,15 +27,9 @@ G_BEGIN_DECLS -typedef struct { - POA_Captive_VFS servant; - PortableServer_POA poa; - } impl_POA_Captive_VFS; - - -Captive_VFS impl_Captive_VFS__create(PortableServer_POA poa,CORBA_Environment *ev); +Captive_File impl_Captive_File__create(PortableServer_POA poa,CORBA_Environment *ev); G_END_DECLS -#endif /* _SERVER_VFS_H */ +#endif /* _SERVER_DIRECTORY_H */ diff --git a/src/libcaptive/sandbox/server-GlibLogFunc.c b/src/libcaptive/sandbox/server-GlibLogFunc.c index af4fdf4..dd68980 100644 --- a/src/libcaptive/sandbox/server-GlibLogFunc.c +++ b/src/libcaptive/sandbox/server-GlibLogFunc.c @@ -74,7 +74,7 @@ static void impl_Captive_GlibLogFunc_glibLogFunc } -static void impl_Captive_VFS_registerGlibLogFunc_log_func +static void impl_Captive_Vfs_registerGlibLogFunc_log_func (const gchar *log_domain,GLogLevelFlags log_level,const gchar *message,const Captive_GlibLogFunc obj /* user_data */) { CORBA_Environment ev; @@ -93,8 +93,8 @@ Captive_GlibLogMessage glib_log_message; } -void impl_Captive_VFS_registerGlibLogFunc - (impl_POA_Captive_VFS *servant,const Captive_GlibLogFunc glib_log_func,CORBA_Environment *ev) +void impl_Captive_Vfs_registerGlibLogFunc + (impl_POA_Captive_Vfs *servant,const Captive_GlibLogFunc glib_log_func,CORBA_Environment *ev) { g_log_set_handler( G_LOG_DOMAIN, /* log_domain; "Captive" */ @@ -102,6 +102,6 @@ void impl_Captive_VFS_registerGlibLogFunc | 0 /* !G_LOG_FLAG_RECURSION */ | G_LOG_FLAG_FATAL | G_LOG_LEVEL_MASK, - (GLogFunc)impl_Captive_VFS_registerGlibLogFunc_log_func, /* log_func */ + (GLogFunc)impl_Captive_Vfs_registerGlibLogFunc_log_func, /* log_func */ (gpointer)glib_log_func); /* user_data */ } diff --git a/src/libcaptive/sandbox/server-GlibLogFunc.h b/src/libcaptive/sandbox/server-GlibLogFunc.h index 22ce282..90dd962 100644 --- a/src/libcaptive/sandbox/server-GlibLogFunc.h +++ b/src/libcaptive/sandbox/server-GlibLogFunc.h @@ -23,13 +23,13 @@ #include #include "sandbox.h" -#include "server-VFS.h" /* for impl_POA_Captive_VFS */ +#include "server-Vfs.h" /* for impl_POA_Captive_Vfs */ G_BEGIN_DECLS -void impl_Captive_VFS_registerGlibLogFunc - (impl_POA_Captive_VFS *servant,const Captive_GlibLogFunc glib_log_func,CORBA_Environment *ev); +void impl_Captive_Vfs_registerGlibLogFunc + (impl_POA_Captive_Vfs *servant,const Captive_GlibLogFunc glib_log_func,CORBA_Environment *ev); Captive_GlibLogFunc impl_Captive_GlibLogFunc__create(PortableServer_POA poa,CORBA_Environment *ev); G_END_DECLS diff --git a/src/libcaptive/sandbox/server-VFS.c b/src/libcaptive/sandbox/server-VFS.c deleted file mode 100644 index 2b83c05..0000000 --- a/src/libcaptive/sandbox/server-VFS.c +++ /dev/null @@ -1,72 +0,0 @@ -/* $Id$ - * CORBA/ORBit server side of VFS object, ran by sandbox_child() - * Copyright (C) 2003 Jan Kratochvil - * - * 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; exactly version 2 of June 1991 is required - * - * 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 - */ - - -#include "config.h" - -#include "server-VFS.h" /* self */ -#include "server-GlibLogFunc.h" /* for impl_Captive_VFS_registerGlibLogFunc() */ -#include "sandbox.h" -#include -#include "captive/macros.h" - - -static Captive_Directory impl_Captive_VFS_openDirectory - (impl_POA_Captive_VFS *servant,const CORBA_char *pathname,CORBA_Environment *ev); - -static PortableServer_ServantBase__epv impl_Captive_VFS_base_epv={ - NULL, /* _private data */ - NULL, /* finalize routine */ - NULL, /* default_POA routine */ - }; -static POA_Captive_VFS__epv impl_Captive_VFS_epv={ - NULL, /* _private */ - (gpointer)&impl_Captive_VFS_registerGlibLogFunc, - (gpointer)&impl_Captive_VFS_openDirectory, - }; -static POA_Captive_VFS__vepv impl_Captive_VFS_vepv={ - &impl_Captive_VFS_base_epv, - &impl_Captive_VFS_epv, - }; - - -Captive_VFS impl_Captive_VFS__create(PortableServer_POA poa,CORBA_Environment *ev) -{ -Captive_VFS retval; -impl_POA_Captive_VFS *newservant; -PortableServer_ObjectId *objid; - - captive_new0(newservant); /* FIXME: leak */ - newservant->servant.vepv=&impl_Captive_VFS_vepv; - newservant->poa=poa; - POA_Captive_VFS__init((PortableServer_Servant)newservant,ev); - objid=PortableServer_POA_activate_object(poa,newservant,ev); - CORBA_free(objid); - retval=PortableServer_POA_servant_to_reference(poa,newservant,ev); - - return retval; -} - - -static Captive_Directory impl_Captive_VFS_openDirectory - (impl_POA_Captive_VFS *servant,const CORBA_char *pathname,CORBA_Environment *ev) -{ -Captive_Directory retval; - - return retval; -} diff --git a/src/libcaptive/sandbox/split.c b/src/libcaptive/sandbox/split.c index a55d1f3..021d03f 100644 --- a/src/libcaptive/sandbox/split.c +++ b/src/libcaptive/sandbox/split.c @@ -31,7 +31,7 @@ #include /* for linc_main_get_loop() */ #include "server-GlibLogFunc.h" #include "server-Directory.h" -#include "server-VFS.h" +#include "server-Vfs.h" /* CONFIG: */ @@ -157,13 +157,13 @@ CORBA_Environment ev; } -static void sandbox_child(int VFS_IOR_fd_write,GSource *gsource) G_GNUC_NORETURN; -static void sandbox_child(int VFS_IOR_fd_write,GSource *gsource) +static void sandbox_child(int Vfs_IOR_fd_write,GSource *gsource) G_GNUC_NORETURN; +static void sandbox_child(int Vfs_IOR_fd_write,GSource *gsource) { CORBA_Environment ev; CORBA_ORB orb; PortableServer_POA poa; -Captive_VFS VFS_object; +Captive_Vfs Vfs_object; gboolean errbool; int errint; guint errguint; @@ -178,21 +178,21 @@ guint errguint; g_main_loop_get_context(linc_main_get_loop())); /* context; NULL means 'default context' */ g_assert(errguint!=0); - /* Init 'VFS_object' */ - VFS_object=impl_Captive_VFS__create(poa,&ev); + /* Init 'Vfs_object' */ + Vfs_object=impl_Captive_Vfs__create(poa,&ev); g_assert(validate_CORBA_Environment(&ev)); /* pass IOR to our parent */ { -char *VFS_IOR; - VFS_IOR=CORBA_ORB_object_to_string(orb,VFS_object,&ev); +char *Vfs_IOR; + Vfs_IOR=CORBA_ORB_object_to_string(orb,Vfs_object,&ev); g_assert(validate_CORBA_Environment(&ev)); - g_assert(VFS_IOR!=NULL); - errint=write(VFS_IOR_fd_write,VFS_IOR,strlen(VFS_IOR)+1); - g_assert((unsigned)errint==strlen(VFS_IOR)+1); - errint=close(VFS_IOR_fd_write); + g_assert(Vfs_IOR!=NULL); + errint=write(Vfs_IOR_fd_write,Vfs_IOR,strlen(Vfs_IOR)+1); + g_assert((unsigned)errint==strlen(Vfs_IOR)+1); + errint=close(Vfs_IOR_fd_write); g_assert(errint==0); - CORBA_free(VFS_IOR); + CORBA_free(Vfs_IOR); } /* CORBA_ORB_run() -> linc_main_loop_run() -> g_main_loop_run() @@ -201,8 +201,8 @@ char *VFS_IOR; CORBA_ORB_run(orb,&ev); g_assert(validate_CORBA_Environment(&ev)); - /* Shutdown 'VFS' servant */ - errbool=corba_servant_object_destroy(poa,VFS_object,&ev); + /* Shutdown 'Vfs' servant */ + errbool=corba_servant_object_destroy(poa,Vfs_object,&ev); g_assert(errbool==TRUE); errbool=corba_shutdown(&ev,&orb,&poa); @@ -211,40 +211,40 @@ char *VFS_IOR; _exit(EXIT_SUCCESS); } -static void sandbox_parent(int VFS_IOR_fd_read) +static void sandbox_parent(int Vfs_IOR_fd_read) { CORBA_Environment ev; CORBA_ORB orb; PortableServer_POA poa; gboolean errbool; -char *VFS_IOR; -gsize VFS_IOR_size; +char *Vfs_IOR; +gsize Vfs_IOR_size; Captive_Directory directory_object; -Captive_VFS VFS_object; +Captive_Vfs Vfs_object; Captive_GlibLogFunc GlibLogFunc_object; int errint; errbool=corba_init("sandbox_parent",&ev,&orb,&poa); g_return_if_fail(errbool==TRUE); - VFS_IOR=captive_rtl_file_read(VFS_IOR_fd_read,&VFS_IOR_size); - g_assert(VFS_IOR!=NULL); - g_assert(VFS_IOR_size>=1); - g_assert(memchr(VFS_IOR,0,VFS_IOR_size)==VFS_IOR+(VFS_IOR_size-1)); /* check exactly for 0-terminated string */ - errint=close(VFS_IOR_fd_read); + Vfs_IOR=captive_rtl_file_read(Vfs_IOR_fd_read,&Vfs_IOR_size); + g_assert(Vfs_IOR!=NULL); + g_assert(Vfs_IOR_size>=1); + g_assert(memchr(Vfs_IOR,0,Vfs_IOR_size)==Vfs_IOR+(Vfs_IOR_size-1)); /* check exactly for 0-terminated string */ + errint=close(Vfs_IOR_fd_read); g_assert(errint==0); - VFS_object=CORBA_ORB_string_to_object(orb,VFS_IOR,&ev); + Vfs_object=CORBA_ORB_string_to_object(orb,Vfs_IOR,&ev); g_assert(validate_CORBA_Environment(&ev)); - g_free(VFS_IOR); + g_free(Vfs_IOR); /* Init 'GlibLogFunc_object' */ GlibLogFunc_object=impl_Captive_GlibLogFunc__create(poa,&ev); g_assert(validate_CORBA_Environment(&ev)); - Captive_VFS_registerGlibLogFunc(VFS_object,GlibLogFunc_object,&ev); + Captive_Vfs_registerGlibLogFunc(Vfs_object,GlibLogFunc_object,&ev); g_assert(validate_CORBA_Environment(&ev)); - directory_object=Captive_VFS_openDirectory(VFS_object,"/directory",&ev); + directory_object=Captive_Vfs_directory_new_open(Vfs_object,"/directory",&ev); g_assert(validate_CORBA_Environment(&ev)); puts("TEST DONE"); @@ -252,7 +252,7 @@ int errint; errbool=corba_servant_object_destroy(poa,GlibLogFunc_object,&ev); g_assert(errbool==TRUE); - CORBA_Object_release(VFS_object,&ev); + CORBA_Object_release(Vfs_object,&ev); g_assert(validate_CORBA_Environment(&ev)); errbool=corba_shutdown(&ev,&orb,&poa); @@ -289,13 +289,13 @@ static GSourceFuncs heartbeat_source_watch_funcs={ void captive_sandbox_init(void) { -/* VFS_IOR_fds[0] for reading by sandbox_parent() - client, - * VFS_IOR_fds[1] for writing by sandbox_child() - server +/* Vfs_IOR_fds[0] for reading by sandbox_parent() - client, + * Vfs_IOR_fds[1] for writing by sandbox_child() - server */ -int VFS_IOR_fds[2],parentheart_fds[2]; +int Vfs_IOR_fds[2],parentheart_fds[2]; int errint; - errint=pipe(VFS_IOR_fds); + errint=pipe(Vfs_IOR_fds); g_assert(errint==0); errint=pipe(parentheart_fds); g_assert(errint==0); @@ -306,7 +306,7 @@ int errint; case 0: { /* child */ GSource *gsource; - errint=close(VFS_IOR_fds[0]); /* close VFS_IOR_fd_read */ + errint=close(Vfs_IOR_fds[0]); /* close Vfs_IOR_fd_read */ g_assert(errint==0); errint=close(parentheart_fds[1]); /* close parentheart_fd_write */ g_assert(errint==0); @@ -325,11 +325,11 @@ GSource *gsource; heartbeat_source_check_gpollfd.events=HEARTBEAT_SOURCE_CHECK_EVENTS; heartbeat_source_check_gpollfd.revents=0; g_source_add_poll(gsource,&heartbeat_source_check_gpollfd); - sandbox_child(VFS_IOR_fds[1],gsource); /* pass VFS_IOR_fd_write */ + sandbox_child(Vfs_IOR_fds[1],gsource); /* pass Vfs_IOR_fd_write */ } /* NOTREACHED */ default: /* parent */ - errint=close(VFS_IOR_fds[1]); /* close VFS_IOR_fd_write */ + errint=close(Vfs_IOR_fds[1]); /* close Vfs_IOR_fd_write */ g_assert(errint==0); errint=close(parentheart_fds[0]); /* close parentheart_fd_read */ g_assert(errint==0); @@ -340,7 +340,7 @@ GSource *gsource; * Currently I am not aware such case would occur. */ g_assert(errint==0); - sandbox_parent(VFS_IOR_fds[0]); /* pass VFS_IOR_fd_read, it will be closed there */ + sandbox_parent(Vfs_IOR_fds[0]); /* pass Vfs_IOR_fd_read, it will be closed there */ break; } /* 'parentheart_fds[1]' - parentheart_fd_write - is left open here */ diff --git a/src/libcaptive/storage/cdrom.c b/src/libcaptive/storage/cdrom.c index fdf09da..e149b57 100644 --- a/src/libcaptive/storage/cdrom.c +++ b/src/libcaptive/storage/cdrom.c @@ -20,18 +20,18 @@ #include "config.h" #include "captive/storage.h" /* self */ -#include "captive/client.h" #include "media.h" #include #include "captive/unicode.h" #include "reactos/ddk/status.h" /* for NT_SUCCESS() */ +#include "captive/options.h" /** * captive_cdrom_init: * * Creates system device "\Device\CdRom%d" providing readonly access - * to the given #captive_image_iochannel as emulation of CD-ROM driver. + * to the given #image_iochannel as emulation of CD-ROM driver. * * libcaptive currently supports just one drive and thus "\Device\CdRom0" * is always created. It is forbidden to call this function twice. @@ -43,7 +43,7 @@ gboolean captive_cdrom_init(void) static struct captive_DriverObject cdrom_captive_DriverObject; NTSTATUS err; - g_return_val_if_fail(captive_image_iochannel!=NULL,FALSE); + g_return_val_if_fail(captive_options->image_iochannel!=NULL,FALSE); cdrom_captive_DriverObject.DiskGeometry.BytesPerSector=2048; cdrom_captive_DriverObject.DiskGeometry.MediaType=RemovableMedia; diff --git a/src/libcaptive/storage/disk.c b/src/libcaptive/storage/disk.c index 2bb7f13..384dda0 100644 --- a/src/libcaptive/storage/disk.c +++ b/src/libcaptive/storage/disk.c @@ -20,24 +20,24 @@ #include "config.h" #include "captive/storage.h" /* self */ -#include "captive/client.h" #include "media.h" #include #include "captive/unicode.h" #include "reactos/ddk/status.h" /* for NT_SUCCESS() */ +#include "captive/options.h" /** * captive_disk_init: * * Creates system device "\Device\CaptiveHarddisk%d" providing readwrite access - * to the given #captive_image_iochannel as emulation of harddisk driver. + * to the given #image_iochannel as emulation of harddisk driver. * reactos initializes "\Device\Harddisk%d\Partition0" as the whole disk * and each partition it founds by IoReadPartitionTable() it will create * as "\Device\Harddisk%d\Partition1", "\Device\Harddisk%d\Partition2" etc. * * libcaptive does not (yet?) support any partitions and it will always create - * just the disk device for the whole given #captive_image_iochannel. + * just the disk device for the whole given #image_iochannel. * As this behaviour is a bit specific we rather create some non-standard name * of the device; anyway I have seen some "\Device\Harddisk%dVolume%d" on W32 * system. @@ -52,7 +52,7 @@ gboolean captive_disk_init(void) static struct captive_DriverObject disk_captive_DriverObject; NTSTATUS err; - g_return_val_if_fail(captive_image_iochannel!=NULL,FALSE); + g_return_val_if_fail(captive_options->image_iochannel!=NULL,FALSE); disk_captive_DriverObject.DiskGeometry.BytesPerSector=512; disk_captive_DriverObject.DiskGeometry.MediaType=FixedMedia; diff --git a/src/libcaptive/storage/media.c b/src/libcaptive/storage/media.c index 9d3d9be..543638e 100644 --- a/src/libcaptive/storage/media.c +++ b/src/libcaptive/storage/media.c @@ -20,9 +20,9 @@ #include "config.h" #include "media.h" /* self */ +#include "captive/storage.h" /* self */ #include #include "reactos/ddk/class2.h" /* for DEVICE_EXTENSION */ -#include "captive/client.h" #include "reactos/ddk/status.h" #include "reactos/ddk/iofuncs.h" /* for IoIsErrorUserInduced() */ #include "captive/macros.h" @@ -30,6 +30,10 @@ #include "captive/unicode.h" #include #include "reactos/structs.h" /* for PREVENT_MEDIA_REMOVAL */ +#include "captive/options.h" + + +guint64 captive_image_size; static gboolean validate_DeviceObject(DEVICE_OBJECT *DeviceObject) @@ -243,7 +247,7 @@ PARTITION_INFORMATION_EX *PartitionInformationEx; case IOCTL_DISK_IS_WRITABLE: Irp->IoStatus.Information=0; - switch (captive_option_rwmode) { + switch (captive_options->rwmode) { case CAPTIVE_OPTION_RWMODE_RO: Irp->IoStatus.Status=STATUS_MEDIA_WRITE_PROTECTED; break; case CAPTIVE_OPTION_RWMODE_BLIND: Irp->IoStatus.Status=STATUS_SUCCESS; break; case CAPTIVE_OPTION_RWMODE_RW: Irp->IoStatus.Status=STATUS_SUCCESS; break; @@ -389,7 +393,7 @@ const struct MajorFunction_READ_WRITE_func_Parameters *Parameters=NULL; /* Preve G_STRLOC,(IrpStack->MajorFunction==IRP_MJ_READ ? "IRP_MJ_READ" : "IRP_MJ_WRITE"), (guint64)Parameters->ByteOffset.QuadPart,(gulong)Parameters->Length); - erriostatus=g_io_channel_seek_position(captive_image_iochannel, + erriostatus=g_io_channel_seek_position(captive_options->image_iochannel, Parameters->ByteOffset.QuadPart, /* offset */ G_SEEK_SET, /* type */ NULL); /* error */ @@ -399,7 +403,7 @@ const struct MajorFunction_READ_WRITE_func_Parameters *Parameters=NULL; /* Preve case IRP_MJ_READ: { gsize bytesread; - erriostatus=g_io_channel_read_chars(captive_image_iochannel, + erriostatus=g_io_channel_read_chars(captive_options->image_iochannel, buffer, /* buf */ Parameters->Length, /* count */ &bytesread, /* bytesread */ @@ -411,7 +415,7 @@ gsize bytesread; case IRP_MJ_WRITE: { gsize byteswritten; - erriostatus=g_io_channel_write_chars(captive_image_iochannel, + erriostatus=g_io_channel_write_chars(captive_options->image_iochannel, buffer, /* buf */ Parameters->Length, /* count */ &byteswritten, /* byteswritten */ @@ -453,7 +457,7 @@ struct captive_DriverObject *captive_DriverObject; /* libcaptive is not authorized to shutdown 'captive_image_channel'. */ erriostatus=g_io_channel_flush( - captive_image_iochannel, /* channel */ + captive_options->image_iochannel, /* channel */ NULL); /* error */ g_assert(erriostatus==G_IO_STATUS_NORMAL); -- 1.8.3.1