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.


updated kernel version numbers for file interface
[palacios.git] / linux_module / iface-file.c
index 3d8ab4d..39f909b 100644 (file)
@@ -81,7 +81,10 @@ static int mkdir_recursive(const char * path, unsigned short perms) {
 
        // Ignore empty directories
        if ((tmp_iter - dirname_ptr) > 1) {
-           palacios_file_mkdir(tmp_str, perms, 0);
+           if (palacios_file_mkdir(tmp_str, perms, 0) != 0) {
+               printk("Could not create directory (%s)\n", tmp_str);
+               return -1;
+           }
        }
 
        if (done) {
@@ -101,8 +104,9 @@ static int mkdir_recursive(const char * path, unsigned short perms) {
 }
 
 static int palacios_file_mkdir(const char * pathname, unsigned short perms, int recurse) {
+    /* Welcome to the jungle... */
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,41)
     /* DO NOT REFERENCE THIS VARIABLE */
     /* It only exists to provide version compatibility */
     struct path tmp_path; 
@@ -119,10 +123,23 @@ 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(3,1,0)
+#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,37) 
        ret = kern_path_parent(pathname, &nd);
+#else 
+
+       if (path_lookup(pathname, LOOKUP_DIRECTORY | LOOKUP_FOLLOW, &nd) == 0) {
+           return 0;
+       }
+
+       if (path_lookup(pathname, LOOKUP_PARENT | LOOKUP_FOLLOW, &nd) != 0) {
+           return -1;
+       }
+#endif
 
        if (ret != 0) {
            printk("%s:%d - Error: kern_path_parent() returned error for (%s)\n", __FILE__, __LINE__, 
@@ -138,7 +155,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)) {
-           return -1;
+           return 0;
        }
        
        path_ptr = &tmp_path;
@@ -152,6 +169,7 @@ static int palacios_file_mkdir(const char * pathname, unsigned short perms, int
 
     mutex_unlock(&(path_ptr->dentry->d_inode->i_mutex));
     path_put(path_ptr);
+
     return ret;
 }
 
@@ -186,9 +204,12 @@ 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);
     
-    if (pfile->filp == NULL) {
+    if (IS_ERR(pfile->filp)) {
        printk("Cannot open file: %s\n", path);
        return NULL;
     }
@@ -316,6 +337,7 @@ static int guest_file_init(struct v3_guest * guest, void ** vm_data) {
 
     *vm_data = state;
 
+
     return 0;
 }