Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Avoid strict-aliasing related issues when compiling with optimization
[palacios.git] / linux_module / iface-file.c
index da5aabb..e826296 100644 (file)
@@ -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);