#include <popt.h>
#include <stdlib.h>
#include <string.h>
-#include "captive/client-directory.h"
+#include <captive/client-directory.h>
#include <stdio.h>
#include "cmd_cd.h" /* self */
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,
#include <glib/gmessages.h>
#include <glib/gerror.h>
#include <popt.h>
-#include "captive/client-file.h"
+#include <captive/client-file.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
-#include "captive/macros.h"
+#include <captive/macros.h>
#include "cmd_get.h" /* self */
#include "cmd_cd.h" /* for cmdline_path_from_cwd() */
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);
#include <popt.h>
#include <stdlib.h>
#include <string.h>
-#include "captive/client-file.h"
+#include <captive/client-file.h>
#include "cmd_info.h" /* self */
#include "cmd_cd.h" /* for cmdline_path_from_cwd() */
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);
#include <popt.h>
#include <stdlib.h>
#include <string.h>
-#include "captive/client-directory.h"
+#include <captive/client-directory.h>
#include "cmd_ls.h" /* self */
#include "cmd_cd.h" /* for cmdline_path_from_cwd() */
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,
#include <glib/gmessages.h>
#include <glib/gerror.h>
#include <popt.h>
-#include "captive/client-directory.h"
+#include <captive/client-directory.h>
#include "cmd_mkdir.h" /* self */
#include "cmd_cd.h" /* for cmdline_path_from_cwd() */
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);
#include <glib/gmessages.h>
#include <glib/gerror.h>
#include <popt.h>
-#include "captive/client-file.h"
+#include <captive/client-file.h>
#include "cmd_mv.h" /* self */
#include "cmd_cd.h" /* for cmdline_path_from_cwd() */
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);
#include <glib/gmessages.h>
#include <glib/gerror.h>
#include <popt.h>
-#include "captive/client-file.h"
+#include <captive/client-file.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
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 */
#include <glib/gmessages.h>
#include <glib/gerror.h>
#include <popt.h>
-#include "captive/client-file.h"
+#include <captive/client-file.h>
#include "cmd_rm.h" /* self */
#include "cmd_cd.h" /* for cmdline_path_from_cwd() */
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);
#include <glib/gmessages.h>
#include <glib/gerror.h>
#include <popt.h>
-#include "captive/client-directory.h"
+#include <captive/client-directory.h>
#include "cmd_rmdir.h" /* self */
#include "cmd_cd.h" /* for cmdline_path_from_cwd() */
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,
#include <stdio.h>
#include <locale.h>
-#include <captive/client.h> /* for captive_init() */
+#include <captive/client-vfs.h>
#include "main.h" /* self */
#include "cmd_shell.h"
#include "cmd_help.h"
+CaptiveVfsObject *cmdline_captive_vfs_object;
+
+
GQuark cmdline_main_error_quark(void)
{
GQuark r=0;
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 */
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);
#include <glib/gtypes.h>
#include <libgnomevfs/gnome-vfs-result.h>
+#include <captive/client-vfs.h>
#define CMDLINE_MAIN_ERROR (cmdline_main_error_quark())
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);
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= \
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;
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;
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;
GnomeVFSResult captive_directory_new_open(CaptiveDirectoryObject **captive_directory_object_return,
- const gchar *pathname)
+ CaptiveVfsObject *captive_vfs_object,const gchar *pathname)
{
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 */
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 */
#include <glib/gtypes.h>
#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
GObject parent_instance;
/*< private >*/
+ CaptiveVfsObject *vfs;
HANDLE dir_Handle;
gboolean read_first;
/* 'QueryDirectory_buf' for NtQueryDirectoryFile() must be persistent
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;
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;
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;
}
-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 */
}
-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 */
#include <glib/gmacros.h>
#include <glib/gtypes.h>
#include "reactos/napi/types.h" /* for NTSTATUS */
+#include "captive/client-vfs.h"
G_BEGIN_DECLS
GObject parent_instance;
/*< private >*/
+ CaptiveVfsObject *vfs;
HANDLE file_Handle;
GnomeVFSFileOffset offset;
};
#include "config.h"
-#include "captive/client.h" /* self */
#include "captive/ldr.h"
#include "captive/ldr_exports.h"
#include "captive/unicode.h"
#include <glib-object.h>
#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;
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. */
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;
&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");
_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();
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);
/**
* 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
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 */
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().
* 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.
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(
/* 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;
--- /dev/null
+/* $Id$
+ * Include file for init and cleanup code of libcaptive to be called by client application
+ * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
+ *
+ * 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 <glib/gtypes.h>
+
+
+G_BEGIN_DECLS
+
+gboolean captive_init(void);
+gboolean captive_shutdown(void);
+
+G_END_DECLS
+
+
+#endif /* _CAPTIVE_CLIENT_INIT_H */
#include "reactos/ntos/rtl.h" /* for InitializeObjectAttributes() */
#include "captive/unicode.h"
#include <libgnomevfs/gnome-vfs-utils.h> /* for gnome_vfs_unescape_string() */
-#include "captive/client.h"
+#include "captive/options.h"
/* function will leave g_malloc()ed 'ObjectAttributes->ObjectName'!
* 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:
--- /dev/null
+/* $Id$
+ * User options handling code of libcaptive
+ * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
+ *
+ * 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 <glib/gmessages.h>
+#include "captive/macros.h"
+#include <glib/gstrfuncs.h>
+#include <stdlib.h>
+
+
+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;
+}
--- /dev/null
+/* $Id$
+ * captive vfs 'vfs' interface to reactos
+ * Copyright (C) 2002-2003 Jan Kratochvil <project-captive@jankratochvil.net>
+ *
+ * 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 <glib/gmessages.h>
+#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;
+}
--- /dev/null
+/* $Id$
+ * Include vfs for captive 'vfs' private interface to reactos
+ * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
+ *
+ * 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 <glib/gmacros.h>
+#include <glib/gtypes.h>
+
+
+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 */
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 \
#include <glib/gmacros.h>
#include <glib-object.h>
#include <libgnomevfs/gnome-vfs-file-info.h> /* for GnomeVFSFileInfo */
+#include "captive/client-vfs.h"
G_BEGIN_DECLS
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);
#include <glib/gmacros.h>
#include <glib-object.h>
#include <libgnomevfs/gnome-vfs-handle.h> /* for GnomeVFSOpenMode */
+#include "captive/client-vfs.h"
G_BEGIN_DECLS
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,
--- /dev/null
+/* $Id$
+ * Include file with client general VFS access to libcaptive
+ * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
+ *
+ * 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 <glib/gtypes.h>
+#include <glib-object.h>
+#include <libgnomevfs/gnome-vfs-result.h>
+#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 */
+++ /dev/null
-/* $Id$
- * Include file with client-application access to libcaptive
- * Copyright (C) 2002 Jan Kratochvil <project-captive@jankratochvil.net>
- *
- * 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 <glib/gmacros.h>
-#include <glib/gtypes.h>
-#include <glib/giochannel.h>
-#include <popt.h>
-
-
-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 */
--- /dev/null
+/* $Id$
+ * Include file with captive_options definition of libcaptive
+ * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
+ *
+ * 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 <glib/gtypes.h>
+#include <glib/giochannel.h>
+#include <popt.h>
+#include <glib/glist.h>
+
+
+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 */
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);
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)
/* $Id$
* CORBA ORBit IDL definition of sandbox intra-captive interface
- * Copyright (C) 2002 Jan Kratochvil <project-captive@jankratochvil.net>
+ * Copyright (C) 2002-2003 Jan Kratochvil <project-captive@jankratochvil.net>
*
* 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
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;
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<octet> 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);
};
};
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={
}
-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;
--- /dev/null
+/* $Id$
+ * CORBA/ORBit server side of File object, ran by sandbox_child()
+ * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
+ *
+ * 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 <glib/gmessages.h>
+#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;
+}
/* $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 <project-captive@jankratochvil.net>
*
* This program is free software; you can redistribute it and/or modify
*/
-#ifndef _SERVER_VFS_H
-#define _SERVER_VFS_H 1
+#ifndef _SERVER_DIRECTORY_H
+#define _SERVER_DIRECTORY_H 1
#include <glib/gmacros.h>
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 */
}
-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;
}
-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" */
| 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 */
}
#include <glib/gmacros.h>
#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
+++ /dev/null
-/* $Id$
- * CORBA/ORBit server side of VFS object, ran by sandbox_child()
- * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
- *
- * 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 <glib/gmessages.h>
-#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;
-}
#include <linc/linc.h> /* for linc_main_get_loop() */
#include "server-GlibLogFunc.h"
#include "server-Directory.h"
-#include "server-VFS.h"
+#include "server-Vfs.h"
/* CONFIG: */
}
-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;
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()
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);
_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");
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);
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);
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);
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);
* 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 */
#include "config.h"
#include "captive/storage.h" /* self */
-#include "captive/client.h"
#include "media.h"
#include <glib/gmessages.h>
#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.
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;
#include "config.h"
#include "captive/storage.h" /* self */
-#include "captive/client.h"
#include "media.h"
#include <glib/gmessages.h>
#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.
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;
#include "config.h"
#include "media.h" /* self */
+#include "captive/storage.h" /* self */
#include <glib/gmessages.h>
#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"
#include "captive/unicode.h"
#include <glib/gmacros.h>
#include "reactos/structs.h" /* for PREVENT_MEDIA_REMOVAL */
+#include "captive/options.h"
+
+
+guint64 captive_image_size;
static gboolean validate_DeviceObject(DEVICE_OBJECT *DeviceObject)
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;
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 */
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 */
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 */
/* 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);