安装CIFS客户端/与系统/安装座的连接

发布于 2025-01-28 18:15:14 字数 1253 浏览 3 评论 0原文

我正在尝试在Ubuntu客户端桌面和Windows 10服务器桌面之间建立CIFS连接,因此我可以通过本地网络共享文件夹和文件。 我的代码如下:

#include <sys/mount.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <string>

using namespace std;

int main()
{
  string src = "//xxx.xxx.x.xxx/shared_folder"; //xxx.xxx.x.xxx should be replaced by the server IP. shared_folder is my folder shared on the server side
  string dst = "/opt/share";//My shared folder on Linux
  string fstype = "cifs";

  printf("src: %s\n", src.c_str());

  if( -1 == mount(src.c_str(), dst.c_str(), fstype.c_str(), MS_MGC_VAL | MS_SILENT , "[email protected],password=mypassword") )
  {
      printf("mount failed with error: %s\n",strerror(errno));
  }
  else
      printf("mount success!\n");
  return 0;
}

但是它总是返回:

src: //xxx.xxx.x.xxx/shared_folder
mount failed with error: Operation not permitted
[1] + Done                       "/usr/bin/gdb" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-fmryivr5.02p" 1>"/tmp/Microsoft-MIEngine-Out-zfdhv3x2.zc5"

请问吗?

I am trying to make a CIFS connection between my Ubuntu client desktop and my Windows 10 server Desktop, so I can share folders and files though a local network.
My code is the following:

#include <sys/mount.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <string>

using namespace std;

int main()
{
  string src = "//xxx.xxx.x.xxx/shared_folder"; //xxx.xxx.x.xxx should be replaced by the server IP. shared_folder is my folder shared on the server side
  string dst = "/opt/share";//My shared folder on Linux
  string fstype = "cifs";

  printf("src: %s\n", src.c_str());

  if( -1 == mount(src.c_str(), dst.c_str(), fstype.c_str(), MS_MGC_VAL | MS_SILENT , "[email protected],password=mypassword") )
  {
      printf("mount failed with error: %s\n",strerror(errno));
  }
  else
      printf("mount success!\n");
  return 0;
}

But it always returns:

src: //xxx.xxx.x.xxx/shared_folder
mount failed with error: Operation not permitted
[1] + Done                       "/usr/bin/gdb" --interpreter=mi --tty=${DbgTerm} 0<"/tmp/Microsoft-MIEngine-In-fmryivr5.02p" 1>"/tmp/Microsoft-MIEngine-Out-zfdhv3x2.zc5"

Any clue, please?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文