X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Fpalacios-file.c;h=396183bb98bb5749faba30b54182f0de6b90f73d;hb=0c358dc90e403625cc23036dab769ca951cda645;hp=2f414b55bbf5bbe412d3bdb3c738b803607cbfcd;hpb=ea1de8c79b78fdb77e4ed017c2eb0e87d701bc4a;p=palacios.releases.git diff --git a/linux_module/palacios-file.c b/linux_module/palacios-file.c index 2f414b5..396183b 100644 --- a/linux_module/palacios-file.c +++ b/linux_module/palacios-file.c @@ -10,11 +10,13 @@ #include #include "palacios.h" +#include "linux-exts.h" #include static struct list_head global_files; + struct palacios_file { struct file * filp; @@ -30,10 +32,26 @@ struct palacios_file { }; +// Currently this just holds the list of open files +struct vm_file_state { + struct list_head open_files; +}; + + static void * palacios_file_open(const char * path, int mode, void * private_data) { struct v3_guest * guest = (struct v3_guest *)private_data; - struct palacios_file * pfile = NULL; + struct palacios_file * pfile = NULL; + struct vm_file_state * vm_state = NULL; + + if (guest != NULL) { + vm_state = get_vm_ext_data(guest, "FILE_INTERFACE"); + + if (vm_state == NULL) { + printk("ERROR: Could not locate vm file state for extension FILE_INTERFACE\n"); + return NULL; + } + } pfile = kmalloc(sizeof(struct palacios_file), GFP_KERNEL); memset(pfile, 0, sizeof(struct palacios_file)); @@ -62,7 +80,7 @@ static void * palacios_file_open(const char * path, int mode, void * private_dat if (guest == NULL) { list_add(&(pfile->file_node), &(global_files)); } else { - list_add(&(pfile->file_node), &(guest->files)); + list_add(&(pfile->file_node), &(vm_state->open_files)); } @@ -150,7 +168,8 @@ static struct v3_file_hooks palacios_file_hooks = { }; -int palacios_file_init( void ) { + +static int file_init( void ) { INIT_LIST_HEAD(&(global_files)); V3_Init_File(&palacios_file_hooks); @@ -159,10 +178,38 @@ int palacios_file_init( void ) { } -int palacios_file_deinit( void ) { +static int file_deinit( void ) { if (!list_empty(&(global_files))) { printk("Error removing module with open files\n"); } return 0; } + +static int guest_file_init(struct v3_guest * guest, void ** vm_data) { + struct vm_file_state * state = kmalloc(sizeof(struct vm_file_state), GFP_KERNEL); + + INIT_LIST_HEAD(&(state->open_files)); + + *vm_data = state; + + return 0; +} + + +static int guest_file_deinit(struct v3_guest * guest, void * vm_data) { + + return 0; +} + + +static struct linux_ext file_ext = { + .name = "FILE_INTERFACE", + .init = file_init, + .deinit = file_deinit, + .guest_init = guest_file_init, + .guest_deinit = guest_file_deinit +}; + + +register_extension(&file_ext);