您的位置:首页 > 运维架构 > Linux

CentOS7安装VMwareTools过程中报错导致hgfs下没有出现共享文件

2017-01-10 14:03 197 查看
在VM上安装了CentOS虚拟机,想使用共享文件夹,安装VMwareTools,hgfs下找不到响应的目录,但是使用vmware-hgfsclient命令 却能看到我设置的共享目录.

仔细再进行了一遍检查,发现在安装VMwareTools时编译报错.

报错如下

CC [M]  /tmp/modconfig-71euqe/vmhgfs-only/page.o

/tmp/modconfig-71euqe/vmhgfs-only/page.c: In function ‘HgfsWbRequestWait’:

/tmp/modconfig-71euqe/vmhgfs-only/page.c:1649:23: warning: passing argument 3 of ‘wait_on_bit’ makes integer from pointer without a cast [enabled by default]

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-71euqe/vmhgfs-only/page.c:28:

include/linux/wait.h:1044:1: note: expected ‘unsigned int’ but argument is of type ‘int (*)(void *)’

wait_on_bit(void *word, int bit, unsigned mode)

^

/tmp/modconfig-71euqe/vmhgfs-only/page.c:1649:23: error: too many arguments to function ‘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-71euqe/vmhgfs-only/page.c:28:

include/linux/wait.h:1044:1: note: declared here

wait_on_bit(void *word, int bit, unsigned mode)

^

make[2]: *** [/tmp/modconfig-71euqe/vmhgfs-only/page.o] Error 1

make[2]: *** Waiting for unfinished jobs....

make[1]: *** [_module_/tmp/modconfig-71euqe/vmhgfs-only] Error 2

make[1]: Leaving directory `/usr/src/kernels/3.10.0-514.2.2.el7.x86_64'

make: *** [vmhgfs.ko] Error 2

make: Leaving directory `/tmp/modconfig-71euqe/vmhgfs-only'


通过查看后发现因为centos 7的Linux内核用的3.10版本,在函数 wait_on_bit_io()中有三个参数,而vmtool的代码在内核3.19后才用3个参数的wait_on_bit_io()函数,代码如下

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


个人推测,在其他linux版本中可能也会出现类是的问题,只要看看报错源码,如果是由于#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0),这种判断造成的报错,只要把宏改成当前的版本号,一般都能解决问题.

vmware-tools-distrib/lib/modules/source的目录下有不少tar文件,我是根据报错的提示

“/tmp/modconfig-71euqe/vmhgfs-only/page.c:1649:23: error: too many arguments to function ‘wait_on_bit’” 一个个去解压了找的

解压指令

tar xf vmhgfs.tar

修改目录下的page文件的1639行

1639 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)


改为如下↓

1639 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)


解压后修改完成打包指令

tar cf vmhgfs.tar vmhgfs-only

然后执行vmware-install.pl 问题解决
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  centos 虚拟机
相关文章推荐