Fix: Patch for Parallel Tools 9.0.23062 to support Linux Kernel 3.11 (Ubuntu 13.10)

millix

Junior Member
Here's a patch to fix the recent removal of readdir() in the file_operations struct for the 3.11 Linux kernel release that will be in Ubuntu 13.10 release. Not extensively tested but works fine for me.

(I had to paste it here inline since Attachment upload is broken under Chrome on Linux... which means TABs are not preserved)

Usage (Debian/Ubuntu-specific):

1) Try to install Parallells Tools 9.x, let it fail (this will install Xorg 1.14 driver just fine)
2) Save the patch (from Code block below) into a file, perhaps called "patch" in your home directory
3) cd /usr/src/parallels-tools-9.0.23062.920702
4) sudo patch -l -p1 < ~/patch
5) sudo dkms build parallels-tools/9.0.23062.920702 --all
6) sudo dkms install parallels-tools/9.0.23062.920702 --all
7) dkms status # should show it installed for all kernels
7) If successfully installed, reboot

NOTE: If there is a more recent version of 9.0.x Tools and Linux 3.11 is /still/ not supported (which will not surprise me for the next year), try substituting the full 9.0.x version number above.

Code:
diff --git a/prl_fs/SharedFolders/Guest/Linux/prl_fs/file.c b/prl_fs/SharedFolders/Guest/Linux/prl_fs/file.c
index 68bbaa1..ae7544d 100644
--- a/prl_fs/SharedFolders/Guest/Linux/prl_fs/file.c
+++ b/prl_fs/SharedFolders/Guest/Linux/prl_fs/file.c
@@ -85,7 +85,11 @@ static unsigned char prlfs_filetype_table[PRLFS_FILE_TYPE_MAX] = {
        DT_LNK,
 };

+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
+static int prlfs_fill_dir(struct file *filp, struct dir_context *ctx,
+#else
 static int prlfs_fill_dir(struct file *filp, void *dirent, filldir_t filldir,
+#endif
                                        loff_t *pos, void *buf, int buflen)
 {
        struct super_block *sb;
@@ -138,7 +142,11 @@ static int prlfs_fill_dir(struct file *filp, void *dirent, filldir_t filldir,
                DPRINTK("filldir: name %s len %d, offset %lld, "
                                                "de->type %d -> type %d\n",
                         de->name, name_len, (*pos), de->file_type, type);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
+                err = dir_emit(ctx, de->name, name_len, ino, type);
+#else
                err = filldir(dirent, de->name, name_len, (*pos), ino, type);
+#endif
                if (err < 0)
                        goto out;
  
@@ -150,7 +158,11 @@ out:
        return ret;
 }
  
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
+static int prlfs_iterate(struct file *filp, struct dir_context *ctx)
+#else
 static int prlfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
+#endif
 {
        struct prlfs_file_info pfi;
        struct super_block *sb;
@@ -160,7 +172,11 @@ static int prlfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
  
        DPRINTK("ENTER\n");
        ret = 0;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
+       init_pfi(&pfi, PFD(filp)->fd, PFD(filp)->sfid, ctx->pos, 0);
+#else
        init_pfi(&pfi, PFD(filp)->fd, PFD(filp)->sfid, filp->f_pos, 0);
+#endif
        assert(filp->f_dentry);
        assert(filp->f_dentry->d_sb);
        sb = filp->f_dentry->d_sb;
@@ -178,7 +194,11 @@ static int prlfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
                        break;
  
                prev_offset = pfi.offset;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
+               ret = prlfs_fill_dir(filp, ctx,
+#else
                ret = prlfs_fill_dir(filp, dirent, filldir,
+#endif
                                        &pfi.offset, buf, len);
                if (ret < 0)
                        break;
@@ -186,7 +206,11 @@ static int prlfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
                        break;
        }
        kfree(buf);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
+       ctx->pos = pfi.offset;
+#else
        filp->f_pos = pfi.offset;
+#endif
 out:
        DPRINTK("EXIT returning %d\n", ret);
        return ret;
@@ -397,13 +421,21 @@ struct file_operations prlfs_file_fops = {
  
 struct file_operations prlfs_dir_fops = {
        .open           = prlfs_open,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
+        .iterate       = prlfs_iterate,
+#else
        .readdir        = prlfs_readdir,
+#endif
        .release        = prlfs_release,
        .read           = generic_read_dir,
 };
  
 struct file_operations prlfs_root_fops = {
        .open           = prlfs_open,
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)
+        .iterate       = prlfs_iterate,
+#else
        .readdir        = prlfs_readdir,
+#endif
        .read           = generic_read_dir,
 };
 
Thanks very much for posting this. I wish I wasn't too scared of kernel development to attempt fixing it myself!

On a more negative note, it's a complete disgrace that this isn't fixed in Parallels, given the patch is so trivial. The latency of support for new kernels is making me consider switching to the competition's product. Although to be fair, I don't know how they compare in this regard.
 
Hey millix, thanks for the patch! The tools source seems to have changed a bit since your post so the patch fails now, ended up editing the code manually.
For those who stumble across this, here's a quick & easy way to get your parallels tools installing:

1. Copy the contents of the parallels disk into a folder on your HD.
2. Replace "./kmods/prl_mod.tar.gz" with this one: prl_mod.tar.gz
3. Install parallels tools from your copy ("./install")

Thanks again to millix for the fix :)
 
Hey Marcus,

I just wanted to thank you for putting this together. I was about to start manually editing the code myself and I somehow managed to stumble upon this right after you posted it. It compiled perfectly for me.

For whom it concerns:
Running Arch ( Current ) on Kernel 3.11.2-1-ARCH i686
 
Hey millix, thanks for the patch! The tools source seems to have changed a bit since your post so the patch fails now, ended up editing the code manually.
For those who stumble across this, here's a quick & easy way to get your parallels tools installing:

1. Copy the contents of the parallels disk into a folder on your HD.
2. Replace "./kmods/prl_mod.tar.gz" with this one: prl_mod.tar.gz
3. Install parallels tools from your copy ("./install")

Unfortunately this didn't work for me. I've upgraded kubuntu 13.10 in a BootCamp partition. After your fix, everything compiled well and I rebooted. But the screen of the XServer (even when the login screen should show up) is just black. Any suggestions? Do you need further information?

edit: Now with Build 9.0.23136 (Refinement 932290; Wendesday, October the 16th 2013) the parallel tools simply build. And (nearly) everything is fine. But I needed to remove parallels tools, then reinstall the kernel (because it seemed to be tainted still), and then install the new parallels tools.
 
Last edited:
Is there a similar fix for Parallels 8 Desktop on the mac? The build of the official "Parallels Tools" with this release fails much earlier than for the 9.x version of Parallels, the patch fixes the failed build, but doesn't work for 8 -- the video driver is stuck at 1024x768, the keyboard/mouse capture is manual, and the psf filesystem cannot be mounted. All in all, a no-go for now.
 
I'm also looking for a fix to install Ubuntu 13.10 in Parallels 8. Ubuntu installs but Parallels Tools fails to install with a error. An update is obviously needed but it's not available.
 
I downloaded the trial of Parallels 9, extracted the iso of Parallels Tools for Linux and then installed it in Ubuntu 13.10. Works fine. The Parallels app is hidden within the installer and it's very tricky in Mavericks to show hidden files. The method used in Mountain Lion doesn't work. Anyway, I have the Parallels Tools iso from Parallels 9 that works in Parallels 8. If anyone needs it, send me a PM and i'll upload it somewhere.
 
I installed Parallels Tools for Lubuntu 13.10 from the trial of Parallels 9, and it worked great.

You can find the .iso at

/Volumes/Parallels Desktop 9/Parallels Desktop.app/Contents/Resources/Tools/prl-tools-lin.iso

Get it into your virtual machine (a public Dropbox link is one good way to do this) and then mount it in the virtual machine as per http://www.cyberciti.biz/tips/how-to-mount-iso-image-under-linux.html

I did the same thing, worked for me
Extracted file from 9, used it on 8.

Not a fix, but good workaround until Parallels patches it for 8 users
 
Back
Top