开发者

Strace: how to debug invalid argument error

I am writing a python program to mount the fuse filesystem through mount system call using ctypes. Now its giving invalid argument error in mount system call. I have checked all the arguments and they seem to be correct. I heard from a friend that strace can be 开发者_运维知识库used to debug these type of errors. Can someone guide me how to use strace to debug the problem. Any help would be appreciated. Thanks in advance.

Let me make the question more generic, how can I use strace to debug the same problem in c langauge.


Using strace is pretty easy, but it might not give you the information you want.

Since you know what system call you're after, the simplest thing would be to do:

strace -fv -e trace=mount mount /dev/sda1 /tmp

(replace mount /dev/... with your python script). The -f is to follow children (probably unnecessary here), -v for verbose, and -e trace=mount instructs strace to only track the mount syscall.

Sample output here:

$ sudo strace -fv -e trace=mount mount /dev/sda1 /tmp
mount("/dev/sda1", "/tmp", "ext2", MS_MGC_VAL, NULL) = 0

So you see the arguments passed in essentially in the form that they will reach the kernel, and the return code.

You won't get an "explanation" of the EINVAL though, but that's only supposed to happen when the source parameter has an invalid superblock, so the message is pretty explicit (unless you're doing something more exotic, in which case there are other possibilities as listed here).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜