X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Fiface-file.c;h=6f69c3d7766dac38a32a29e89edd48a1b58646b1;hb=a8686374c6aa74d805b32e7675f42f7ab9a0b348;hp=78c4e0b901448b2d1996bacef83f184cbf148656;hpb=0b2115047303e779be8578e9802cfa55d1767c7b;p=palacios.git diff --git a/linux_module/iface-file.c b/linux_module/iface-file.c index 78c4e0b..6f69c3d 100644 --- a/linux_module/iface-file.c +++ b/linux_module/iface-file.c @@ -20,6 +20,12 @@ static struct list_head global_files; #define isprint(a) ((a >= ' ') && (a <= '~')) +#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0) +#define PAL_VFS_GETATTR(path, kstat) vfs_getattr(path.mnt, path.dentry, kstat) +#else +#define PAL_VFS_GETATTR(path, kstat) vfs_getattr(path, kstat) +#endif + struct palacios_file { struct file * filp; @@ -56,6 +62,7 @@ static int mkdir_recursive(const char * path, unsigned short perms) { } memset(tmp_str, 0, strlen(path) + 1); + // will terminate tmp_str strncpy(tmp_str, path, strlen(path)); dirname_ptr = tmp_str; @@ -118,6 +125,9 @@ static int palacios_file_mkdir(const char * pathname, unsigned short perms, int /* It only exists to provide version compatibility */ struct path tmp_path; #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,41) + struct nameidata nd; +#endif struct path * path_ptr = NULL; struct dentry * dentry; @@ -132,8 +142,6 @@ static int palacios_file_mkdir(const char * pathname, unsigned short perms, int /* Before Linux 3.1 this was somewhat more difficult */ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,41) { - struct nameidata nd; - // I'm not 100% sure about the version here, but it was around this time that the API changed #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38) ret = kern_path_parent(pathname, &nd); @@ -218,7 +226,7 @@ static void * palacios_file_open(const char * path, int mode, void * private_dat pfile->mode |= O_LARGEFILE; - pfile->filp = filp_open(path, pfile->mode, 0); + pfile->filp = filp_open(path, pfile->mode, 0600); // rw------- to start if (!pfile->filp || IS_ERR(pfile->filp)) { ERROR("Cannot open file: %s\n", path); @@ -226,7 +234,7 @@ static void * palacios_file_open(const char * path, int mode, void * private_dat return NULL; } - pfile->path = palacios_alloc(strlen(path)); + pfile->path = palacios_alloc(strlen(path) + 1); if (!pfile->path) { ERROR("Cannot allocate in file open\n"); @@ -234,7 +242,7 @@ static void * palacios_file_open(const char * path, int mode, void * private_dat palacios_free(pfile); return NULL; } - strncpy(pfile->path, path, strlen(path)); + strncpy(pfile->path, path, strlen(path)); // will terminate pfile->path pfile->guest = guest; palacios_spinlock_init(&(pfile->lock)); @@ -274,7 +282,7 @@ static unsigned long long palacios_file_size(void * file_ptr) { struct kstat s; int ret; - ret = vfs_getattr(filp->f_path.mnt, filp->f_path.dentry, &s); + ret = PAL_VFS_GETATTR(filp->f_path, &s); if (ret != 0) { ERROR("Failed to fstat file\n");