[packages/open-vm-tools] - make kernel patch universal for all kernels

baggins baggins at pld-linux.org
Sun Oct 27 21:59:51 CET 2013


commit 0a51dd4333aba3ae06b3625b9c73c70ad8420c7a
Author: Jan Rękorajski <baggins at pld-linux.org>
Date:   Sun Oct 27 21:58:33 2013 +0100

    - make kernel patch universal for all kernels

 open-vm-tools-linux-3.10.patch | 170 +++++++++++++++++++++++++++++++----------
 1 file changed, 129 insertions(+), 41 deletions(-)
---
diff --git a/open-vm-tools-linux-3.10.patch b/open-vm-tools-linux-3.10.patch
index 88d7aa7..4245cf4 100644
--- a/open-vm-tools-linux-3.10.patch
+++ b/open-vm-tools-linux-3.10.patch
@@ -62,52 +62,77 @@ diff --git a/modules/linux/vmblock/linux/control.c b/modules/linux/vmblock/linux
 index 79716bd..ee64cdc 100644
 --- a/modules/linux/vmblock/linux/control.c
 +++ b/modules/linux/vmblock/linux/control.c
-@@ -208,9 +208,10 @@ SetupProcDevice(void)
+@@ -28,6 +28,7 @@
+ #include <linux/proc_fs.h>
+ #include <linux/stat.h>
+ #include <linux/fs.h>
++#include <linux/version.h>
+ 
+ #include <asm/uaccess.h>
+ 
+@@ -208,9 +208,16 @@ SetupProcDevice(void)
     VMBlockSetProcEntryOwner(controlProcMountpoint);
  
     /* Create /proc/fs/vmblock/dev */
--   controlProcEntry = create_proc_entry(VMBLOCK_CONTROL_DEVNAME,
--                                        VMBLOCK_CONTROL_MODE,
--                                        controlProcDirEntry);
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
+    controlProcEntry = create_proc_entry(VMBLOCK_CONTROL_DEVNAME,
+                                         VMBLOCK_CONTROL_MODE,
+                                         controlProcDirEntry);
++#else
 +   controlProcEntry = proc_create(VMBLOCK_CONTROL_DEVNAME,
 +                                  VMBLOCK_CONTROL_MODE,
 +                                  controlProcDirEntry,
 +                                  &ControlFileOps);
++#endif
     if (!controlProcEntry) {
        Warning("SetupProcDevice: could not create " VMBLOCK_DEVICE "\n");
        remove_proc_entry(VMBLOCK_CONTROL_MOUNTPOINT, controlProcDirEntry);
-@@ -218,7 +219,6 @@ SetupProcDevice(void)
+@@ -218,7 +219,9 @@ SetupProcDevice(void)
        return -EINVAL;
     }
  
--   controlProcEntry->proc_fops = &ControlFileOps;
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)
+    controlProcEntry->proc_fops = &ControlFileOps;
++#endif
     return 0;
  }
  
-@@ -278,7 +278,7 @@ ExecuteBlockOp(const char __user *buf,                // IN: buffer with name
+@@ -278,7 +278,11 @@ ExecuteBlockOp(const char __user *buf,                // IN: buffer with name
                 int (*blockOp)(const char *filename,   // IN: block operation
                                const os_blocker_id_t blocker))
  {
--   char *name;
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
+    char *name;
++#else
 +   struct filename *name;
++#endif
     int i;
     int retval;
  
-@@ -287,13 +287,13 @@ ExecuteBlockOp(const char __user *buf,                // IN: buffer with name
+@@ -287,13 +287,26 @@ ExecuteBlockOp(const char __user *buf,                // IN: buffer with name
        return PTR_ERR(name);
     }
  
--   for (i = strlen(name) - 1; i >= 0 && name[i] == '/'; i--) {
--      name[i] = '\0';
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
+    for (i = strlen(name) - 1; i >= 0 && name[i] == '/'; i--) {
+       name[i] = '\0';
++#else
 +   for (i = strlen(name->name) - 1; i >= 0 && name->name[i] == '/'; i--) {
 +      ((char *)name->name)[i] = '\0';
++#endif
     }
  
--   retval = i < 0 ? -EINVAL : blockOp(name, blocker);
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
+    retval = i < 0 ? -EINVAL : blockOp(name, blocker);
++#else
 +   retval = i < 0 ? -EINVAL : blockOp(name->name, blocker);
++#endif
  
--   putname(name);
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
+    putname(name);
++#else
 +   __putname(name);
++#endif
  
     return retval;
  }
@@ -115,31 +140,47 @@ diff --git a/modules/linux/vmblock/linux/dentry.c b/modules/linux/vmblock/linux/
 index 05ea95a..d93b2f0 100644
 --- a/modules/linux/vmblock/linux/dentry.c
 +++ b/modules/linux/vmblock/linux/dentry.c
-@@ -31,8 +31,7 @@
+@@ -26,6 +26,7 @@
+ #include "driver-config.h"
+ 
+ #include <linux/fs.h>
++#include <linux/version.h>
+ #include "compat_namei.h"
+ #include "vmblockInt.h"
  #include "filesystem.h"
+@@ -31,7 +31,11 @@
  #include "block.h"
  
--
--static int DentryOpRevalidate(struct dentry *dentry, struct nameidata *nd);
+ 
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
+ static int DentryOpRevalidate(struct dentry *dentry, struct nameidata *nd);
++#else
 +static int DentryOpRevalidate(struct dentry *dentry, unsigned int flags);
++#endif
  
  struct dentry_operations LinkDentryOps = {
     .d_revalidate = DentryOpRevalidate,
-@@ -60,7 +59,7 @@ struct dentry_operations LinkDentryOps = {
+@@ -60,7 +59,11 @@ struct dentry_operations LinkDentryOps = {
  
  static int
  DentryOpRevalidate(struct dentry *dentry,  // IN: dentry revalidating
--                   struct nameidata *nd)   // IN: lookup flags & intent
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
+                    struct nameidata *nd)   // IN: lookup flags & intent
++#else
 +                   unsigned int flags)     // IN: lookup flags
++#endif
  {
     VMBlockInodeInfo *iinfo;
     struct nameidata actualNd;
-@@ -101,7 +100,7 @@ DentryOpRevalidate(struct dentry *dentry,  // IN: dentry revalidating
+@@ -101,7 +100,11 @@ DentryOpRevalidate(struct dentry *dentry,  // IN: dentry revalidating
     if (actualDentry &&
         actualDentry->d_op &&
         actualDentry->d_op->d_revalidate) {
--      return actualDentry->d_op->d_revalidate(actualDentry, nd);
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
+       return actualDentry->d_op->d_revalidate(actualDentry, nd);
++#else
 +      return actualDentry->d_op->d_revalidate(actualDentry, flags);
++#endif
     }
  
     if (compat_path_lookup(iinfo->name, 0, &actualNd)) {
@@ -147,21 +188,35 @@ diff --git a/modules/linux/vmblock/linux/inode.c b/modules/linux/vmblock/linux/i
 index 098c94c..ddd37f3 100644
 --- a/modules/linux/vmblock/linux/inode.c
 +++ b/modules/linux/vmblock/linux/inode.c
-@@ -36,7 +36,7 @@
+@@ -28,6 +28,7 @@
+ #include <linux/fs.h>
+ #include <linux/time.h>
+ #include <linux/namei.h>
++#include <linux/version.h>
+ 
+ #include "vmblockInt.h"
+ #include "filesystem.h"
+@@ -36,7 +36,11 @@
  
  /* Inode operations */
  static struct dentry *InodeOpLookup(struct inode *dir,
--                                    struct dentry *dentry, struct nameidata *nd);
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
+                                     struct dentry *dentry, struct nameidata *nd);
++#else
 +                                    struct dentry *dentry, unsigned int flags);
++#endif
  static int InodeOpReadlink(struct dentry *dentry, char __user *buffer, int buflen);
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 13)
  static void *InodeOpFollowlink(struct dentry *dentry, struct nameidata *nd);
-@@ -75,7 +75,7 @@ static struct inode_operations LinkInodeOps = {
+@@ -75,7 +75,11 @@ static struct inode_operations LinkInodeOps = {
  static struct dentry *
  InodeOpLookup(struct inode *dir,      // IN: parent directory's inode
                struct dentry *dentry,  // IN: dentry to lookup
--              struct nameidata *nd)   // IN: lookup intent and information
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
+               struct nameidata *nd)   // IN: lookup intent and information
++#else
 +              unsigned int flags)     // IN: lookup flags
++#endif
  {
     char *filename;
     struct inode *inode;
@@ -169,7 +224,7 @@ diff --git a/modules/linux/vmhgfs/file.c b/modules/linux/vmhgfs/file.c
 index 1033984..db62070 100644
 --- a/modules/linux/vmhgfs/file.c
 +++ b/modules/linux/vmhgfs/file.c
-@@ -25,6 +25,7 @@
+@@ -25,9 +25,11 @@
  /* Must come before any kernel header file. */
  #include "driver-config.h"
  
@@ -177,83 +232,116 @@ index 1033984..db62070 100644
  #include <linux/errno.h>
  #include <linux/module.h>
  #include <linux/signal.h>
++#include <linux/version.h>
+ #include "compat_cred.h"
+ #include "compat_fs.h"
+ #include "compat_kernel.h"
 diff --git a/modules/linux/vmsync/sync.c b/modules/linux/vmsync/sync.c
 index d05ccad..73baf8b 100644
 --- a/modules/linux/vmsync/sync.c
 +++ b/modules/linux/vmsync/sync.c
-@@ -162,7 +162,7 @@ VmSyncThawDevices(void  *_state)  // IN
+@@ -43,6 +43,7 @@
+ #include <asm/string.h>
+ #include <linux/buffer_head.h>
+ #include <linux/proc_fs.h>
++#include <linux/version.h>
+ 
+ #include "compat_fs.h"
+ #include "compat_module.h"
+@@ -162,7 +162,11 @@ VmSyncThawDevices(void  *_state)  // IN
     cancel_delayed_work(&state->thawTask);
     list_for_each_safe(cur, tmp, &state->devices) {
        dev = list_entry(cur, VmSyncBlockDevice, list);
--      if (dev->sb != NULL && dev->sb->s_frozen != SB_UNFROZEN) {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
+       if (dev->sb != NULL && dev->sb->s_frozen != SB_UNFROZEN) {
++#else
 +      if (dev->sb != NULL && dev->sb->s_writers.frozen != SB_UNFROZEN) {
++#endif
           thaw_bdev(dev->bdev, dev->sb);
           atomic_dec(&gFreezeCount);
        }
-@@ -237,7 +237,7 @@ VmSyncAddPath(const VmSyncState *state,   // IN
+@@ -237,7 +237,11 @@ VmSyncAddPath(const VmSyncState *state,   // IN
      * the superblock is already frozen.
      */
     if (inode->i_sb->s_bdev == NULL ||
--       inode->i_sb->s_frozen != SB_UNFROZEN) {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
+        inode->i_sb->s_frozen != SB_UNFROZEN) {
++#else
 +       inode->i_sb->s_writers.frozen != SB_UNFROZEN) {
++#endif
        result = (inode->i_sb->s_bdev == NULL) ? -EINVAL : -EALREADY;
        compat_path_release(&nd);
        goto exit;
-@@ -303,7 +303,7 @@ VmSyncFreezeDevices(VmSyncState *state,            // IN
+@@ -303,7 +303,11 @@ VmSyncFreezeDevices(VmSyncState *state,            // IN
                      const char __user *userPaths)  // IN
  {
     int result = 0;
--   char *paths;
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
+    char *paths;
++#else
 +   struct filename *paths;
++#endif
     char *currPath;
     char *nextSep;
     struct list_head *cur, *tmp;
-@@ -328,7 +328,8 @@ VmSyncFreezeDevices(VmSyncState *state,            // IN
+@@ -328,7 +328,12 @@ VmSyncFreezeDevices(VmSyncState *state,            // IN
     /*
      * First, try to add all paths to the list of paths to be frozen.
      */
--   currPath = paths;
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
+    currPath = paths;
++#else
 +   currPath = __getname();
 +   strcpy(currPath, paths->name);
++#endif
     do {
        nextSep = strchr(currPath, ':');
        if (nextSep != NULL) {
-@@ -347,6 +348,7 @@ VmSyncFreezeDevices(VmSyncState *state,            // IN
+@@ -347,6 +348,9 @@ VmSyncFreezeDevices(VmSyncState *state,            // IN
        }
        currPath = nextSep + 1;
     } while (nextSep != NULL);
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)
 +   __putname(currPath);
++#endif
  
     /*
      * If adding all the requested paths worked, then freeze them.
-@@ -371,6 +373,8 @@ VmSyncFreezeDevices(VmSyncState *state,            // IN
+@@ -371,6 +373,10 @@ VmSyncFreezeDevices(VmSyncState *state,            // IN
     compat_mutex_unlock(&state->lock);
     compat_mutex_unlock(&gFreezeLock);
  
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0)
 +   __putname(paths);
++#endif
 +
     if (result == 0) {
        compat_schedule_delayed_work(&state->thawTask, VMSYNC_THAW_TASK_DELAY);
     }
-@@ -670,9 +674,10 @@ init_module(void)
+@@ -670,9 +674,16 @@ init_module(void)
     }
  
     /* Create /proc/driver/vmware-sync */
--   controlProcEntry = create_proc_entry("driver/vmware-sync",
--                                        S_IFREG | S_IRUSR | S_IRGRP | S_IROTH,
--                                        NULL);
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
+    controlProcEntry = create_proc_entry("driver/vmware-sync",
+                                         S_IFREG | S_IRUSR | S_IRGRP | S_IROTH,
+                                         NULL);
++#else
 +   controlProcEntry = proc_create("driver/vmware-sync",
 +                                  S_IFREG | S_IRUSR | S_IRGRP | S_IROTH,
 +                                  NULL,
 +                                  &VmSyncFileOps);
++#endif
     if (!controlProcEntry) {
        printk(KERN_ERR "vmsync: could not create /proc/driver/vmware-sync\n");
        kmem_cache_destroy(gSyncStateCache);
-@@ -680,7 +685,6 @@ init_module(void)
+@@ -680,7 +685,9 @@ init_module(void)
        return -EINVAL;
     }
  
--   controlProcEntry->proc_fops = &VmSyncFileOps;
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)
+    controlProcEntry->proc_fops = &VmSyncFileOps;
++#endif
     return 0;
  }
  
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/open-vm-tools.git/commitdiff/ab6955926d6e527ec0baf66661353f941709bd55



More information about the pld-cvs-commit mailing list