apt install -y git gcc pkgconf autoconf automake libtool make meson ninja-build gawk libnl-3-dev libnl-genl-3-dev libglib2.0-dev
dnf install -y git gcc pkgconf autoconf automake libtool make meson ninja-build gawk libnl3-devel glib2-devel
git clone https://github.com/cifsd-team/ksmbd-tools.git
cd ksmbd-tools
./autogen.sh
./configure --with-rundir=/run # --prefix=/usr/local/sbin --sysconfdir=/usr/local/etc
make
sudo make install
安装的二进制文件为/usr/local/sbin/ksmbd.*
,配置文件例子/usr/local/etc/ksmbd/ksmbd.conf.example
。
以上是使用autotools
编译,如果要使用meson
编译,查看ksmbd-tools README。
用户操作:
mkdir -vp /tmp/s_test
# 生成 ksmbd.conf
sudo ksmbd.addshare --add \
--option "path = /tmp/s_test" \
--option 'read only = no' \
TEST
sudo ksmbd.addshare --update TEST # 填写其他信息
sudo ksmbd.adduser --add root
sudo ksmbd.adduser --delete root # 删除用户
配置文件/usr/local/etc/ksmbd/ksmbd.conf
的一个例子如下:
global]
[writeable = yes
public = yes
TEST]
[comment = xfstests test dir
; 注意路径后面不要有空格,我被路径后的空格坑过path = /tmp/s_test
执行脚本ksmbd-svr-setup.sh启动内核的ksmbd server。
sudo ksmbd.control --shutdown # 关闭
sudo ksmbd.mountd # 启动
sudo mount -o user=root //127.0.0.1/TEST /mnt
kthread
worker_thread
process_scheduled_works
process_one_work
handle_ksmbd_work
__handle_ksmbd_work
__process_request
smb2_open
dentry_open
vfs_open
do_dentry_open ext2_file_open