[心得]嵌入式平台 掛載 cifs windows share folder

荒廢了一陣子 的blog,最近 終於又有衝動想寫了

這邊筆記一下  掛載 windows share folder 方式

基本上 開發版 busybox  mount  的 cifs  功能選項要打開
然後 Linux kernel 的 network filesystem 部分關於 cifs 的 也要打開

確認登入使用的帳號 在機器上有足夠的權限

假定windows PC:/folder/share的共享名为 share , 有用户administrator ,密码123
在linux  機器上,把share挂到/mnt目录:
mount -t cifs -o username=administrator,password=123 //192.168.0.11/share /mnt

就類似 如上的指令,有人是把 帳號密碼 寫在最後面

另外 也有指令是用 mount.cifs 的方式 通常這個在Linux PC 上 才有.

大部分的 嵌入式開發平台 為了簡化code size 其實像這一類功能 預設 都是沒有編譯的

一些編譯的 必要選項 可參考,和 如果 kernel 版本 太新的話 ,搭配對應的linux kernel 也得留意

二、内核支持: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)
    {
      ...
      char *hostname, *dotted, *ip, *share, *unc;//增加share unc
      ...
      hostname[len] = '\0';
      //以下为增加内容
     share = hostname + len + 1;
     if (share[0] == '\0')
       goto report_error;
     unc = xasprintf("unc=\\\\%s\\%s", hostname, share);
     parse_mount_options(unc, &filteropts);
     if (ENABLE_FEATURE_CLEAN_UP) free(unc);
     //以上为增加内容
     dotted = xmalloc_sockaddr2dotted_noport(&lsa->u.sa);
     ...
    }


http://www.embeddedlinux.org.cn/emb-linux/system-development/201706/26-6852.html


如果掛載 出現 錯誤

Operation now in progress”


通常是因為 windows 防火牆問題

https://blog.csdn.net/yuesichiu/article/details/77839875

一些其他錯誤
https://blog.csdn.net/linking530/article/details/51816322

留言