开发者

Debugfs file mode flags?

开发者 https://www.devze.com 2023-02-10 01:36 出处:网络
What flags do I use for debugfs_create_file_N(...)?All the resources I can find basically say \'set them as appropriate\'.

What flags do I use for debugfs_create_file_N(...)? All the resources I can find basically say 'set them as appropriate'.

I've tried 777, MAY_WRITE|MAY_READ, and FMODE_WRITE|FMODE_READ; but so far 开发者_高级运维cat'ing the file only gives me a '0'.


Didn't you hear, "777 is almost always wrong" :-) MAY_* and FMODE_* are not file modes either, but internal flags and file states.

Better:

debugfs_create_file(..., S_ISREG | S_IRUGO | S_IWUSR, ...);


For a world readable file, use S_IRUGO

validation@tb04:~> ls -l /sys/kernel/debug/spc0/registers
-r--r--r-- 1 root root 0 Feb 14  2011 /sys/kernel/debug/spc0/registers

Internally, this sets S_IRUSR|S_IRGRP|S_IROTH which set read mode for the user, group, and others. See include/stat.h in the kernel for other macro definitions.

0

精彩评论

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

关注公众号