我发现我的系统日志中几乎 75% 的错误是
WARNING **: Couldn't create directory monitor on smb://x-gnome-default-workgroup/. Error: Operation not supported by backend
我不需要能够监视我的任何 samba 共享上的更改,所以我只想禁用它,这样它就不会破坏我的日志。我该怎么办?
我也遇到了同样的问题,尝试更改 GVFS 环境变量和相关的 dconf 键,但没有得到任何好的结果,因此决定查看源代码。我在 daemon/gvfsbackendnetwork.c 文件中找到了下一个代码:
g_warning ("Couldn't create directory monitor on %s. Error: %s\n",
uri, error ? error->message : "");
Run Code Online (Sandbox Code Playgroud)
...这产生了问题中描述的警告。顺便说一句,该文件中有 2 个位置在 Ubuntu GVFS 源中具有相同的警告,而在 GNOME.org 的 git 中,其中 1 个条目实际上是 g_debug,而不是 g_warning。我决定将 Ubuntu 版本中的两个 g_warning 调用更改为 g_debug,因为这将是清除这些嘈杂警告的系统日志的最小补丁。
要重现后续步骤,您必须首先启用源代码存储库。然后在系统终端(又名 bash、sh)中运行描述的命令:
# install build tools
sudo apt-get install build-essential devscripts fakeroot
# install gvfs build dependencies
sudo apt-get build-dep gvfs
# create temporary directory for the source code and get it via apt
mkdir ~/src; cd ~/src
apt-get source gvfs
# at the moment I've got gvfs-1.28.2 @ Ubuntu 16.04, update the path if you've got another version
# check g_warning entries to be sure what we're editing:
cat ~/src/gvfs-1.28.2/daemon/gvfsbackendnetwork.c | grep g_warning
Run Code Online (Sandbox Code Playgroud)
g_warning(“无法在 %s 上创建目录监视器。错误:%s”,
g_warning(“无法在 %s 上创建目录监视器。错误:%s”,
# replace g_warning to g_debug as described way above
sed --in-place "s/g_warning/g_debug/g" ~/src/gvfs-1.28.2/daemon/gvfsbackendnetwork.c
# go to the source directory root
cd ~/src/gvfs-1.28.2
# bump version, edit changelog if needed, then save the file
dch -i
Run Code Online (Sandbox Code Playgroud)
那看起来像:
gvfs (1.28.2-1ubuntu1~16.04.2ubuntu1) 未发布;紧急程度=中
通过将不可禁用警告转变为调试消息,保持系统日志中的干净。
-- 哈贝丁 2018 年 12 月 21 日星期五 20:00:00 +0300
# finally, build the .deb packages
debuild -b -us -uc
# one level up from the source root - to the compiled .deb packages
cd ..
# install them all
sudo dpkg -i *.deb
Run Code Online (Sandbox Code Playgroud)
最后一点,我得到的debuild参数的描述man dpkg-buildpackage
:
-b 指定仅二进制构建,不构建和/或分发源文件。
-us 不对源码包进行签名。
-uc 不签署.changes 文件。
这是解决问题的有点肮脏的方法,但我没有找到合适的内置解决方案,所以目前这是我发现的实际清理系统日志的唯一方法。