X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Finclude%2Fpalacios%2Fvmm_file.h;h=7b0872cf437e8bb8706ca7da69a5254c33d90ff1;hb=0acab7cc621777394096377d6412e7f796e41769;hp=cac4c4d219003e8f9f3c312c4e6b130bce47b241;hpb=7f424638a5e63b0f5434c640543a3558aad75b57;p=palacios.git diff --git a/palacios/include/palacios/vmm_file.h b/palacios/include/palacios/vmm_file.h index cac4c4d..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), (buf), (len), (start)) : -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), (buf), (len), (start)) : -1; \ + if ((file_hooks) && (file_hooks)->file_write) { \ + ret = (file_hooks)->file_write((fd), (buf), (len), (start)); \ + } \ + ret; \ }) @@ -69,7 +84,7 @@ struct v3_file_hooks { - void (*file_open)(const char * path, int mode, void * host_data); + void * (*file_open)(const char * path, int mode, void * host_data); int (*file_close)(void * fd); long long (*file_size)(void * fd);