2 * This file is part of the Palacios Virtual Machine Monitor developed
3 * by the V3VEE Project with funding from the United States National
4 * Science Foundation and the Department of Energy.
6 * The V3VEE Project is a joint project between Northwestern University
7 * and the University of New Mexico. You can find out more at
10 * Copyright (c) 2010, Peter Dinda <pdinda@northwestern.edu>
11 * Copyright (c) 2010, The V3VEE Project <http://www.v3vee.org>
12 * All rights reserved.
14 * Author: Peter Dinda <pdinda@northwestern.edu>
16 * This is free software. You are permitted to use,
17 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
21 #include <interfaces/vmm_file.h>
22 #include <palacios/vmm.h>
23 #include <palacios/vmm_debug.h>
24 #include <palacios/vmm_types.h>
25 #include <palacios/vm_guest.h>
27 static struct v3_file_hooks * file_hooks = NULL;
29 void V3_Init_File(struct v3_file_hooks * hooks) {
31 V3_Print(VM_NONE, VCORE_NONE, "V3 file interface intialized\n");
36 int v3_mkdir(char * path, uint16_t permissions, uint8_t recursive) {
37 V3_ASSERT(VM_NONE, VCORE_NONE, file_hooks);
38 V3_ASSERT(VM_NONE, VCORE_NONE, file_hooks->mkdir);
40 return file_hooks->mkdir(path, permissions, recursive);
43 v3_file_t v3_file_open(struct v3_vm_info * vm, char * path, uint8_t mode) {
44 void * priv_data = NULL;
45 V3_ASSERT(vm, VCORE_NONE, file_hooks);
46 V3_ASSERT(vm, VCORE_NONE, file_hooks->open);
49 priv_data = vm->host_priv_data;
52 return file_hooks->open(path, mode, priv_data);
55 int v3_file_close(v3_file_t file) {
56 V3_ASSERT(VM_NONE, VCORE_NONE, file_hooks);
57 V3_ASSERT(VM_NONE, VCORE_NONE, file_hooks->close);
59 return file_hooks->close(file);
62 uint64_t v3_file_size(v3_file_t file) {
63 V3_ASSERT(VM_NONE, VCORE_NONE, file_hooks);
64 V3_ASSERT(VM_NONE, VCORE_NONE, file_hooks->size);
66 return file_hooks->size(file);
69 uint64_t v3_file_read(v3_file_t file, uint8_t * buf, uint64_t len, uint64_t off) {
70 V3_ASSERT(VM_NONE, VCORE_NONE, file_hooks);
71 V3_ASSERT(VM_NONE, VCORE_NONE, file_hooks->read);
73 return file_hooks->read(file, buf, len, off);
77 uint64_t v3_file_write(v3_file_t file, uint8_t * buf, uint64_t len, uint64_t off) {
78 V3_ASSERT(VM_NONE, VCORE_NONE, file_hooks);
79 V3_ASSERT(VM_NONE, VCORE_NONE, file_hooks->write);
81 return file_hooks->write(file, buf, len, off);