X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Fiface-file.c;h=e826296e1339bb890f95c8d83c2b3a599e30d71e;hb=e3102a252f2e92de3275bdcf2af96beb85c693e4;hp=da5aabba93ada8469027e949c736cec148f74e00;hpb=5c2a2684778fa080c41a0f04518721ebe476efb1;p=palacios.git diff --git a/linux_module/iface-file.c b/linux_module/iface-file.c index da5aabb..e826296 100644 --- a/linux_module/iface-file.c +++ b/linux_module/iface-file.c @@ -161,7 +161,7 @@ static int palacios_file_mkdir(const char * pathname, unsigned short perms, int { dentry = kern_path_create(AT_FDCWD, pathname, &tmp_path, 1); - if (IS_ERR(dentry)) { + if (!dentry || IS_ERR(dentry)) { return 0; } @@ -170,7 +170,7 @@ static int palacios_file_mkdir(const char * pathname, unsigned short perms, int #endif - if (!IS_ERR(dentry)) { + if (!(!dentry || IS_ERR(dentry))) { ret = vfs_mkdir(path_ptr->dentry->d_inode, dentry, perms); } @@ -218,9 +218,9 @@ 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 (IS_ERR(pfile->filp)) { + if (!pfile->filp || IS_ERR(pfile->filp)) { ERROR("Cannot open file: %s\n", path); palacios_free(pfile); return NULL; @@ -252,10 +252,16 @@ static void * palacios_file_open(const char * path, int mode, void * private_dat static int palacios_file_close(void * file_ptr) { struct palacios_file * pfile = (struct palacios_file *)file_ptr; + if (!pfile) { + return -1; + } + filp_close(pfile->filp, NULL); list_del(&(pfile->file_node)); + palacios_spinlock_deinit(&(pfile->lock)); + palacios_free(pfile->path); palacios_free(pfile);