X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Finclude%2Fpalacios%2Fvmm_file.h;h=7b0872cf437e8bb8706ca7da69a5254c33d90ff1;hb=24e0221dd2fdcf613cc5e487ec57a30f2fef25e3;hp=bf4a1d054e74db9271d34994fc6466f5a705c7cc;hpb=4731ff7dc97e42853546b38b4d441d793e7a4ec8;p=palacios.git diff --git a/palacios/include/palacios/vmm_file.h b/palacios/include/palacios/vmm_file.h index bf4a1d0..7b0872c 100644 --- a/palacios/include/palacios/vmm_file.h +++ b/palacios/include/palacios/vmm_file.h @@ -26,39 +26,54 @@ #ifdef __V3VEE__ -#define V3_FileOpen(path, mode) \ +#define V3_FileOpen(path, mode, host_data) \ ({ \ + void * fd = NULL; \ extern struct v3_file_hooks * file_hooks; \ - ((file_hooks) && (file_hooks)->file_open) ? \ - (file_hooks)->file_open((path), (mode)) : -1; \ + if ((file_hooks) && (file_hooks)->file_open) { \ + fd = (file_hooks)->file_open((path), (mode), (host_data)); \ + } \ + fd; \ }) #define V3_FileClose(fd) \ ({ \ + int ret = 0; \ extern struct v3_file_hooks * file_hooks; \ - ((file_hooks) && (file_hooks)->file_close) ? \ - (file_hooks)->file_close((fd)) : -1; \ + if ((file_hooks) && (file_hooks)->file_close) { \ + ret = (file_hooks)->file_close((fd)); \ + } \ + ret; \ }) #define V3_FileSize(fd) \ ({ \ + long long size = -1; \ extern struct v3_file_hooks * file_hooks; \ - ((file_hooks) && (file_hooks)->file_size) ? \ - (file_hooks)->file_size((fd)) : -1; \ + if ((file_hooks) && (file_hooks)->file_size) { \ + size = (file_hooks)->file_size((fd)); \ + } \ + size; \ }) #define V3_FileRead(fd, start, buf, len) \ ({ \ + long long ret = -1; \ extern struct v3_file_hooks * file_hooks; \ - ((file_hooks) && (file_hooks)->file_read) ? \ - (file_hooks)->file_read((fd), (start), (buf), (len)) : -1; \ + if ((file_hooks) && (file_hooks)->file_read) { \ + ret = (file_hooks)->file_read((fd), (buf), (len), (start)); \ + } \ + ret; \ }) #define V3_FileWrite(fd,start,buf,len) \ ({ \ + long long ret = -1; \ extern struct v3_file_hooks * file_hooks; \ - ((file_hooks) && (file_hooks)->file_write) ? \ - (file_hooks)->file_write((fd), (start), (buf), (len)) : -1; \ + if ((file_hooks) && (file_hooks)->file_write) { \ + ret = (file_hooks)->file_write((fd), (buf), (len), (start)); \ + } \ + ret; \ }) @@ -69,14 +84,14 @@ struct v3_file_hooks { - int (*file_open)(const char * path, int mode); - int (*file_close)(int fd); + void * (*file_open)(const char * path, int mode, void * host_data); + int (*file_close)(void * fd); - long long (*file_size)(int fd); + long long (*file_size)(void * fd); // blocking reads and writes - long long (*file_read)(int fd, long long start, void * buffer, long long length); - long long (*file_write)(int fd, long long start, void * buffer, long long length); + long long (*file_read)(void * fd, void * buffer, long long length, long long offset); + long long (*file_write)(void * fd, void * buffer, long long length, long long offset); };