CIFS介绍及使用

一、背景:

CIFS - Common Internet File System,通用internet文件系统。

CIFS 是微软提出的协议,它使程序可以访问远程Internet计算机上的文件并要求此计算机的服务。

CIFS 使用客户/服务器模式。客户程序请求远在服务器上的服务器程序为它提供服务。服务器获得请求并返回响应。

CIFS是公共的或开放的SMB协议版本,并由Microsoft使用。

SMB协议现在是局域网上用于服务器文件访问和打印的协议。像SMB协议一样,CIFS在高层运行,而不像TCP/IP协议那样运行在底层。CIFS可以看做是应用程序协议如文件传输协议和超文本传输协议的一个实现。

嵌入式使用主要为从开发板与windows的共享。

二、内核支持:linux-3.4.35

File systems  --->

  [*] Network File Systems  --->

    <*>   CIFS support (advanced network filesystem, SMBFS successor)

    [*]     CIFS statistics

    [ ]       Extended statistics

    [*]     Support legacy servers which use weaker LANMAN security

    [*]     Kerberos/SPNEGO advanced session setup

    [ ]     CIFS extended attributes

    [ ]     Enable additional CIFS debugging routines

    [*]     DFS feature support 

三、busybox支持:busybox-1.20.2

  Linux System Utilities  --->

    [*] mount

    [*]   Support mounting CIFS/SMB file systems

注意:内核从3.4版本开始,mount时的选项"unc=\\machine\share"变成强制的了。但是busybox中在调用mount的时候没有传递unc参数。

    因此,需要修改vi util-linux/mount.c

    static int singlemount(struct mntent *mp, int ignore_busy)

    {

>  		int len;
>  		char c;
>  		len_and_sockaddr *lsa;
> -		char *hostname, *dotted, *ip;
> +		char *hostname, *dotted, *ip, *share, *unc;
>>  		hostname = mp->mnt_fsname + 2;
>  		len = strcspn(hostname, "/\\");
> @@ -1646,6 +1646,15 @@ static int singlemount(struct mntent *mp, intignore_busy)
>  			goto report_error;
>  		c = hostname[len];
>  		hostname[len] = '\0';
> +
> +		share = hostname + len + 1;
> +		if (share[0] == '\0')
> +			goto report_error;
> +		// Insert "unc=\\hostname\share" option into options
> +		unc = xasprintf("unc=\\\\%s\\%s", hostname, share);
> +		parse_mount_options(unc, &filteropts);
> +		if (ENABLE_FEATURE_CLEAN_UP) free(unc);
> +
>  		lsa = host2sockaddr(hostname, 0);
>  		hostname[len] = c;
>  		if (!lsa)

  make CROSS_COMPILE=arm-linux  menuconfig

  make CROSS_COMPILE=arm-linux  

  make CROSS_COMPILE=arm-linux  install

  将_install/bin/mount放到开发板上

四、使用

  mount -t cifs -o username=windows账号,password="windows密码" //windowsIP/windows共享目录 /mnt/cifs

posted @ 2017-06-20 10:47  扑克face  阅读(1621)  评论(0编辑  收藏  举报