File vmware-6.0.2-alt4.patch of Package kernel-src-vmware

vmblock/linux/control.c    | 35 +++++++++++++++++++++++++++++++++++
 vmblock/linux/dentry.c     | 12 ++++++++++++
 vmblock/linux/file.c       | 28 ++++++++++++++++++++++++++++
 vmblock/linux/inode.c      | 22 ++++++++++++++++++++++
 vmblock/shared/vm_assert.h |  3 +++
 vmci/linux/driver.c        |  4 ++++
 vmci/shared/vm_assert.h    |  3 +++
 vmmon/include/vm_assert.h  |  3 +++
 vmmon/linux/driver.c       |  2 +-
 vmnet/vm_assert.h          |  3 +++
 vsock/linux/af_vsock.c     |  4 ++++
 vsock/linux/notify.c       |  4 ++++
 vsock/linux/notifyQState.c |  8 ++++++++
 vsock/shared/vm_assert.h   |  3 +++
 14 files changed, 133 insertions(+), 1 deletion(-)

diff --git a/vmblock/linux/control.c b/vmblock/linux/control.c
index 79716bd..302c2fb 100644
--- a/vmblock/linux/control.c
+++ b/vmblock/linux/control.c
@@ -208,9 +208,16 @@ SetupProcDevice(void)
    VMBlockSetProcEntryOwner(controlProcMountpoint);
 
    /* Create /proc/fs/vmblock/dev */
+#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 +225,9 @@ SetupProcDevice(void)
       return -EINVAL;
    }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 10, 0)
    controlProcEntry->proc_fops = &ControlFileOps;
+#endif
    return 0;
 }
 
@@ -281,19 +290,45 @@ ExecuteBlockOp(const char __user *buf,                // IN: buffer with name
    char *name;
    int i;
    int retval;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)
+
+   name = __getname();
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
+   struct filename *tmp = getname(buf);
+
+   if (IS_ERR(tmp))
+      return PTR_ERR(tmp);
+   name = (char*)tmp->name;
+#else
 
    name = getname(buf);
+#endif
+
    if (IS_ERR(name)) {
       return PTR_ERR(name);
    }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)
+   i = strncpy_from_user(name, buf, PATH_MAX);
+   if (i < 0 || i == PATH_MAX) {
+      __putname(name);
+      return -EINVAL;
+   }
+#endif
+
    for (i = strlen(name) - 1; i >= 0 && name[i] == '/'; i--) {
       name[i] = '\0';
    }
 
    retval = i < 0 ? -EINVAL : blockOp(name, blocker);
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)
+   __putname(name);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
+   __putname(tmp);
+#else
    putname(name);
+#endif
 
    return retval;
 }
diff --git a/vmblock/linux/dentry.c b/vmblock/linux/dentry.c
index 05ea95a..556d4ac 100644
--- a/vmblock/linux/dentry.c
+++ b/vmblock/linux/dentry.c
@@ -32,7 +32,11 @@
 #include "block.h"
 
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 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 +64,11 @@ struct dentry_operations LinkDentryOps = {
 
 static int
 DentryOpRevalidate(struct dentry *dentry,  // IN: dentry revalidating
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0)
                    struct nameidata *nd)   // IN: lookup flags & intent
+#else
+                   unsigned int flags)     // IN: lookup flags
+#endif
 {
    VMBlockInodeInfo *iinfo;
    struct nameidata actualNd;
@@ -101,7 +109,11 @@ DentryOpRevalidate(struct dentry *dentry,  // IN: dentry revalidating
    if (actualDentry &&
        actualDentry->d_op &&
        actualDentry->d_op->d_revalidate) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 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)) {
diff --git a/vmblock/linux/file.c b/vmblock/linux/file.c
index d7ac1f6..e0fcc72 100644
--- a/vmblock/linux/file.c
+++ b/vmblock/linux/file.c
@@ -38,6 +38,7 @@ typedef u64 inode_num_t;
 typedef ino_t inode_num_t;
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0)
 /* Specifically for our filldir_t callback */
 typedef struct FilldirInfo {
    filldir_t filldir;
@@ -76,6 +77,7 @@ Filldir(void *buf,              // IN: Dirent buffer passed from FileOpReaddir
    /* Specify DT_LNK regardless */
    return info->filldir(info->dirent, name, namelen, offset, ino, DT_LNK);
 }
+#endif
 
 
 /* File operations */
@@ -145,6 +147,7 @@ FileOpOpen(struct inode *inode,  // IN
 }
 
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0)
 /*
  *----------------------------------------------------------------------------
  *
@@ -193,6 +196,27 @@ FileOpReaddir(struct file *file,  // IN
 
    return ret;
 }
+#else
+static int
+FileOpIterate(struct file *file,        // IN
+              struct dir_context *ctx)  // IN
+{
+   struct file *actualFile;
+
+   if (!file) {
+      Warning("FileOpIterate: invalid args from kernel\n");
+      return -EINVAL;
+   }
+
+   actualFile = file->private_data;
+   if (!actualFile) {
+      Warning("FileOpIterate: no actual file found\n");
+      return -EINVAL;
+   }
+
+   return iterate_dir(actualFile, ctx);
+}
+#endif
 
 
 /*
@@ -237,7 +261,11 @@ FileOpRelease(struct inode *inode, // IN
 
 
 struct file_operations RootFileOps = {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 11, 0)
    .readdir = FileOpReaddir,
+#else
+   .iterate = FileOpIterate,
+#endif
    .open    = FileOpOpen,
    .release = FileOpRelease,
 };
diff --git a/vmblock/linux/inode.c b/vmblock/linux/inode.c
index 098c94c..648993c 100644
--- a/vmblock/linux/inode.c
+++ b/vmblock/linux/inode.c
@@ -36,7 +36,11 @@
 
 /* Inode operations */
 static struct dentry *InodeOpLookup(struct inode *dir,
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 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 +79,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
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0)
               struct nameidata *nd)   // IN: lookup intent and information
+#else
+              unsigned int flags)     // IN: lookup flags
+#endif
 {
    char *filename;
    struct inode *inode;
@@ -135,7 +143,12 @@ InodeOpLookup(struct inode *dir,      // IN: parent directory's inode
    inode->i_size = INODE_TO_IINFO(inode)->nameLen;
    inode->i_version = 1;
    inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 5, 0)
    inode->i_uid = inode->i_gid = 0;
+#else
+   inode->i_gid = make_kgid(current_user_ns(), 0);
+   inode->i_uid = make_kuid(current_user_ns(), 0);
+#endif
    inode->i_op = &LinkInodeOps;
 
    d_add(dentry, inode);
@@ -177,7 +190,11 @@ InodeOpReadlink(struct dentry *dentry,  // IN : dentry of symlink
       return -EINVAL;
    }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 15, 0)
    return vfs_readlink(dentry, buffer, buflen, iinfo->name);
+#else
+   return readlink_copy(buffer, buflen, iinfo->name);
+#endif
 }
 
 
@@ -221,7 +238,12 @@ InodeOpFollowlink(struct dentry *dentry,  // IN : dentry of symlink
       goto out;
    }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0)
    ret = vfs_follow_link(nd, iinfo->name);
+#else
+   nd_set_link(nd, iinfo->name);
+   return NULL;
+#endif
 
 out:
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 13)
diff --git a/vmblock/shared/vm_assert.h b/vmblock/shared/vm_assert.h
index 1996f9d..ced0609 100644
--- a/vmblock/shared/vm_assert.h
+++ b/vmblock/shared/vm_assert.h
@@ -250,6 +250,9 @@ void WarningThrottled(uint32 *count, const char *fmt, ...)
 
 #define LOG_ONCE(_s) DO_ONCE(Log _s)
 
+#ifdef DEPRECATED
+#undef DEPRECATED
+#endif
 #ifdef VMX86_DEVEL
    #define DEPRECATED(_fix) DO_ONCE(                                     \
                                Warning("%s:%d: %s is DEPRECATED. %s\n",  \
diff --git a/vmci/linux/driver.c b/vmci/linux/driver.c
index 79128dc..add6a65 100644
--- a/vmci/linux/driver.c
+++ b/vmci/linux/driver.c
@@ -737,7 +737,11 @@ LinuxDriver_Ioctl(struct inode *inode,
          goto init_release;
       }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 5, 0)
       user = current_uid();
+#else
+      user = from_kuid(current_user_ns(), current_uid());
+#endif
       retval = VMCIContext_InitContext(initBlock.cid, initBlock.flags,
                                        0 /* Unused */, vmciLinux->userVersion,
                                        &user, &vmciLinux->context);
diff --git a/vmci/shared/vm_assert.h b/vmci/shared/vm_assert.h
index 1996f9d..ced0609 100644
--- a/vmci/shared/vm_assert.h
+++ b/vmci/shared/vm_assert.h
@@ -250,6 +250,9 @@ void WarningThrottled(uint32 *count, const char *fmt, ...)
 
 #define LOG_ONCE(_s) DO_ONCE(Log _s)
 
+#ifdef DEPRECATED
+#undef DEPRECATED
+#endif
 #ifdef VMX86_DEVEL
    #define DEPRECATED(_fix) DO_ONCE(                                     \
                                Warning("%s:%d: %s is DEPRECATED. %s\n",  \
diff --git a/vmmon/include/vm_assert.h b/vmmon/include/vm_assert.h
index 1996f9d..ced0609 100644
--- a/vmmon/include/vm_assert.h
+++ b/vmmon/include/vm_assert.h
@@ -250,6 +250,9 @@ void WarningThrottled(uint32 *count, const char *fmt, ...)
 
 #define LOG_ONCE(_s) DO_ONCE(Log _s)
 
+#ifdef DEPRECATED
+#undef DEPRECATED
+#endif
 #ifdef VMX86_DEVEL
    #define DEPRECATED(_fix) DO_ONCE(                                     \
                                Warning("%s:%d: %s is DEPRECATED. %s\n",  \
diff --git a/vmmon/linux/driver.c b/vmmon/linux/driver.c
index 728c4bb..4ae7b19 100644
--- a/vmmon/linux/driver.c
+++ b/vmmon/linux/driver.c
@@ -1338,7 +1338,7 @@ LinuxDriverReadTSC(void *data,   // OUT: TSC values
  *-----------------------------------------------------------------------------
  */
 
-__attribute__((always_inline)) static Bool
+__always_inline static Bool
 LinuxDriverSyncReadTSCs(uint64 *delta) // OUT: TSC max - TSC min
 {
    TSCDelta tscDelta;
diff --git a/vmnet/vm_assert.h b/vmnet/vm_assert.h
index 1996f9d..ced0609 100644
--- a/vmnet/vm_assert.h
+++ b/vmnet/vm_assert.h
@@ -250,6 +250,9 @@ void WarningThrottled(uint32 *count, const char *fmt, ...)
 
 #define LOG_ONCE(_s) DO_ONCE(Log _s)
 
+#ifdef DEPRECATED
+#undef DEPRECATED
+#endif
 #ifdef VMX86_DEVEL
    #define DEPRECATED(_fix) DO_ONCE(                                     \
                                Warning("%s:%d: %s is DEPRECATED. %s\n",  \
diff --git a/vsock/linux/af_vsock.c b/vsock/linux/af_vsock.c
index 694f644..775d4f3 100644
--- a/vsock/linux/af_vsock.c
+++ b/vsock/linux/af_vsock.c
@@ -2869,7 +2869,11 @@ __VSockVmciCreate(struct net *net,       // IN: Network namespace
       vsk->connectTimeout = psk->connectTimeout;
    } else {
       vsk->trusted = capable(CAP_NET_ADMIN);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 5, 0)
       vsk->owner = current_uid();
+#else
+      vsk->owner = from_kuid(current_user_ns(), current_uid());
+#endif
       vsk->queuePairSize = VSOCK_DEFAULT_QP_SIZE;
       vsk->queuePairMinSize = VSOCK_DEFAULT_QP_SIZE_MIN;
       vsk->queuePairMaxSize = VSOCK_DEFAULT_QP_SIZE_MAX;
diff --git a/vsock/linux/notify.c b/vsock/linux/notify.c
index f627956..494e9b2 100644
--- a/vsock/linux/notify.c
+++ b/vsock/linux/notify.c
@@ -516,7 +516,11 @@ VSockVmciHandleWrote(struct sock *sk,            // IN
    PKT_FIELD(vsk, sentWaitingRead) = FALSE;
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 15, 0)
    sk->sk_data_ready(sk, 0);
+#else
+   sk->sk_data_ready(sk);
+#endif
 }
 
 
diff --git a/vsock/linux/notifyQState.c b/vsock/linux/notifyQState.c
index f3816d4..89012ae 100644
--- a/vsock/linux/notifyQState.c
+++ b/vsock/linux/notifyQState.c
@@ -164,7 +164,11 @@ VSockVmciHandleWrote(struct sock *sk,            // IN
                      struct sockaddr_vm *dst,    // IN: unused
                      struct sockaddr_vm *src)    // IN: unused
 {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 15, 0)
    sk->sk_data_ready(sk, 0);
+#else
+   sk->sk_data_ready(sk);
+#endif
 }
 
 
@@ -566,7 +570,11 @@ VSockVmciNotifyPktRecvPostDequeue(struct sock *sk,               // IN
       }
 
       /* See the comment in VSockVmciNotifyPktSendPostEnqueue */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 15, 0)
       sk->sk_data_ready(sk, 0);
+#else
+      sk->sk_data_ready(sk);
+#endif
    }
 
    return err;
diff --git a/vsock/shared/vm_assert.h b/vsock/shared/vm_assert.h
index 1996f9d..ced0609 100644
--- a/vsock/shared/vm_assert.h
+++ b/vsock/shared/vm_assert.h
@@ -250,6 +250,9 @@ void WarningThrottled(uint32 *count, const char *fmt, ...)
 
 #define LOG_ONCE(_s) DO_ONCE(Log _s)
 
+#ifdef DEPRECATED
+#undef DEPRECATED
+#endif
 #ifdef VMX86_DEVEL
    #define DEPRECATED(_fix) DO_ONCE(                                     \
                                Warning("%s:%d: %s is DEPRECATED. %s\n",  \
openSUSE Build Service is sponsored by