这个samba程序也是够了,那么多版本,只修复后面的bug不修复之前发布的bug,本来以为分分钟搞定,结果入坑3个小时。
samba程序版本间变化好像比较大, 我下了好几个版本,要不是编译不过,要不就是差异太大自己懒得看。最后看到网上好多人用的都是这个版本samba-3.0.23。我也用这个版本放的最后搞定了。
移植过程:
1.程序下载:3.0.23 我不是在官网上下载的,官网上找不到,大家可以点【我的下载】来down。
2.编译:
(1)解压进入编译目录
tar vxf samba-3.0.23.tar.gz
cd samba-3.0.23
cd source
(2)执行configue生成makefile
./configure CC=arm-hisiv400-linux-gcc LD=arm-hisiv400-linux-ld AR=arm-hisiv400-linux-ar --target=arm-hisiv400-linux --host=arm-hisiv400-linux samba_cv_CC_NEGATIVE_ENUM_VALUES=yes
执行时会报错
configure: error: cannot run test program while cross compiling
解决方法:修改configure文件 重新执行(2)中的命令就可以通过了,共需要修改7处。
echo "$as_me: error: cannot run test program while cross compiling
See \`config.log' for more details." >&2;}
{ (exit 1); exit 1; }; }
修改为
echo "$as_me: error: cannot run test program while cross compiling
See \`config.log' for more details." >&2;}
}
(3)修改代码
source/lib/time.c
//gettimeofday(tval);
gettimeofday(tval,NULL);
source/client/mount.cifs.c
增加宏
#define PATH_MAX 50
(4)编译 source文件夹下执行make 顺利通过
3.移植:
(1)板卡端执行 创建samba需要用的文件夹
mkdir /usr/local/samba/bin -p
mkdir /usr/local/samba/lib -p
mkdir /usr/local/samba/private -p
mkdir /usr/local/samba/var -p
(2)准备可执行文件和samba配置文件
拷贝交叉编译后的source/bin 目录下的smbd 到板卡/usr/local/samba/bin目录下
在/usr/local/samba/lib目录下创建smb.conf
smb.conf内容:
[global]
workgroup = myworkgroup
server string = samba
netbios name = hisi
guest account=root
security =share
interfaces = eth0
[share]
path = /
guest ok=yes
browseable=yes
4.测试
运行程序./smbd -D
打开window中的文件夹在目录中输入//192.xxx.xxx.xxx/成功开启samba服务