这对于开发FUSE文件系统的人来说是一个永恒的问题。
该链接(几乎不可能在单个答案中整合所有内容)可能会有所帮助。解决方法涉及对fusermount进行即时替换,并且(取决于情况)需要一些额外的选项来防止valgrind跟踪子进程。
实际上,如果您在valgrind下运行我的FS,您将得到此输出(足够多的人遇到了这个问题,以至于我实际上检测到了启动上的valgrind并显示了链接)。
root@tower:~ # valgrind xsfs /xs
==9479== Memcheck, a memory error detector.
==9479== Copyright (C) 2002-2008, and GNU GPL'd, by Julian Seward et al.
==9479== Using LibVEX rev 1884, a library for dynamic binary translation.
==9479== Copyright (C) 2004-2008, and GNU GPL'd, by OpenWorks LLP.
==9479== Using valgrind-3.4.1, a dynamic binary instrumentation framework.
==9479== Copyright (C) 2000-2008, and GNU GPL'd, by Julian Seward et al.
==9479== For more details, rerun with: -v
==9479==
******** Valgrind has been detected by xsfs
******** If you have difficulties getting xsfs to work under Valgrind,
******** see the following thread:
******** http://www.nabble.com/valgrind-and-fuse-file-systems-td13112112.html
******** Sleeping for 5 seconds so this doesn't fly by ....
最简单的方法是在以root身份运行的可丢弃虚拟机中进行所有调试,在其中可以轻松地放弃setuid位,然后就做完了。确保您测试了自己的代码,以确保没有任何泄漏或违规行为,并测试任何未使用fuse的链接库代码。将构建结果交给“valgrind-clean”,并在文档中注明您已这样做。
然后,从“valgrind/valgrind.h”中获取一些内容来检测它,并为那些仍然运行它的人显示一个短消息。绕过它的黑客技巧需要root的合作,而且坦率地说,在沙盒中也可以更容易地完成。
如果设置了setuid位,则拒绝在valgrind下运行也很容易,并为希望这样做的人显示有用的消息以将其关闭。