zoukankan      html  css  js  c++  java
  • centos 7.3 安装vmtools,解决无法编译共享文件夹模块

    环境说明:

    vmware 12.5.0 build-4352439

    centos 7.3.1611   64位,内核版本:Linux version 3.10.0-514.16.1.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) )

    在安装vmtools 时,编译共享文件时会报错,错误信息如下:

    /tmp/modconfig-xkFtz3/vmhgfs-only/page.c: 在函数‘HgfsWbRequestWait’中:
    /tmp/modconfig-xkFtz3/vmhgfs-only/page.c:1649:23: 警告:传递‘wait_on_bit’的第 3 个参数时将指针赋给整数,未作类型转换 [默认启用]
                           TASK_UNINTERRUPTIBLE);
                           ^
    In file included from include/linux/mmzone.h:9:0,
                     from include/linux/gfp.h:5,
                     from include/linux/mm.h:9,
                     from include/linux/pagemap.h:7,
                     from /tmp/modconfig-xkFtz3/vmhgfs-only/page.c:28:
    include/linux/wait.h:1044:1: 附注:需要类型‘unsigned int’,但实参的类型为‘int (*)(void *)’
     wait_on_bit(void *word, int bit, unsigned mode)
     ^
    /tmp/modconfig-xkFtz3/vmhgfs-only/page.c:1649:23: 错误:提供给函数‘wait_on_bit’的实参太多
                           TASK_UNINTERRUPTIBLE);
                           ^
    In file included from include/linux/mmzone.h:9:0,
                     from include/linux/gfp.h:5,
                     from include/linux/mm.h:9,
                     from include/linux/pagemap.h:7,
                     from /tmp/modconfig-xkFtz3/vmhgfs-only/page.c:28:
    include/linux/wait.h:1044:1: 附注:在此声明
     wait_on_bit(void *word, int bit, unsigned mode)
     ^
    make[2]: *** [/tmp/modconfig-xkFtz3/vmhgfs-only/page.o] 错误 1
    make[2]: *** 正在等待未完成的任务....
    make[1]: *** [_module_/tmp/modconfig-xkFtz3/vmhgfs-only] 错误 2
    make[1]: 离开目录“/usr/src/kernels/3.10.0-514.16.1.el7.x86_64”
    make: *** [vmhgfs.ko] 错误 2

    大概意思就是由于 vmhgfs-only/page.c 文件中1649 行出现了wait_on_bit函数调用错误,传递的实参太多了

    查看include/linux/wait.h 的文件,该文件为操作系统的头文件,在我个人机器上全路径为/usr/src/kernels/3.10.0-514.el7.x86_64/include/linux/wait.h。

    wait_on_bit 函数的定义如下

    wait_on_bit(void *word, int bit, unsigned mode)
    {
            if (!test_bit(bit, word))
                    return 0;
            return out_of_line_wait_on_bit(word, bit,
                                           bit_wait,
                                           mode);
    }

    我们再翻看page.c 的源码,page.c 源码在 /opt/vmware-tools-distrib/lib/modules/source/vmhgfs.tar 压缩文件中。

    大家可以直接解压

    解压命令为

    tar -xvf vmhgfs.tar

    查看page.c 文件

    vi /opt/vmware-tools-distrib/lib/modules/source/vmhgfs-only/page.c

    查看page.c 1649 行这个HgfsWbRequestWait函数定义

       1636 int
       1637 HgfsWbRequestWait(HgfsWbPage *req)  // IN: request of page data to write
       1638 {
       1639 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
       1640    return wait_on_bit_io(&req->wb_flags,
       1641                          PG_BUSY,
       1642                          TASK_UNINTERRUPTIBLE);
       1643 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 13)
       1644    return wait_on_bit(&req->wb_flags,
       1645                       PG_BUSY,
       1646 #if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
       1647                       HgfsWbRequestWaitUninterruptible,
       1648 #endif
       1649                       TASK_UNINTERRUPTIBLE);
       1650 #else
       1651    wait_event(req->wb_queue,
       1652               !test_bit(PG_BUSY, &req->wb_flags));
       1653    return 0;
       1654 #endif
       1655 }

    可以发现在1649 行,程序在调用wait_on_bit 函数时,当 LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 13) 并且 LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0) 时,会为 wait_on_bit 函数传递 4 个参数,不符合wait_on_bit 函数的定义。

    所以到这里解决的方式就很简单了,只要将第三个参数人为去掉就可以了,修改后的HgfsWbRequestWait 函数代码

       1636 int
       1637 HgfsWbRequestWait(HgfsWbPage *req)  // IN: request of page data to write
       1638 {
       1639 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
       1640    return wait_on_bit_io(&req->wb_flags,
       1641                          PG_BUSY,
       1642                          TASK_UNINTERRUPTIBLE);
       1643 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 13)
       1644    return wait_on_bit(&req->wb_flags,
       1645                       PG_BUSY,
       1646                       TASK_UNINTERRUPTIBLE);
       1647 #else
       1648    wait_event(req->wb_queue,
       1649               !test_bit(PG_BUSY, &req->wb_flags));
       1650    return 0;
       1651 #endif
       1652 }

    然后大家再对修改后的 vmhgfs-only 源码文件夹重新打包,打包命令如下

    tar -cvf vmhgfs.tar vmhgfs-only/*

    然后大家重新安装vmtools 软件就可以了,安装命令

    /opt/vmware-tools-distrib/vmware-install.pl

    大家一路回车确认即可

  • 相关阅读:
    不能在注册表中识别出来python时的解决方法
    Biopython
    Biopython
    生信相关网站
    linux下的查找命令
    class
    不同版本的Eclipse安装SVN插件
    【如何快速的开发一个完整的iOS直播app】(原理篇)
    iOS 直播
    Ios-视频直播-知识点汇总-持续更新
  • 原文地址:https://www.cnblogs.com/chenfool/p/6808245.html
Copyright © 2011-2022 走看看