因为您还没有阅读全部手册。
的capget手动启动说服你不使用它:
These two functions are the raw kernel interface for getting and set‐
ting thread capabilities. Not only are these system calls specific to
Linux, but the kernel API is likely to change and use of these func‐
tions (in particular the format of the cap_user_*_t types) is subject
to extension with each kernel revision, but old programs will keep
working.
The portable interfaces are cap_set_proc(3) and cap_get_proc(3); if
possible you should use those interfaces in applications. If you wish
to use the Linux extensions in applications, you should use the easier-
to-use interfaces capsetp(3) and capgetp(3).
当前细节
Now that you have been warned, some current kernel details. The struc‐
tures are defined as follows.
#define _LINUX_CAPABILITY_VERSION_1 0x19980330
#define _LINUX_CAPABILITY_U32S_1 1
#define _LINUX_CAPABILITY_VERSION_2 0x20071026
#define _LINUX_CAPABILITY_U32S_2 2
[...]
effective, permitted, inheritable are bitmasks of the capabilities
defined in capability(7). Note the CAP_* values are bit indexes and
need to be bit-shifted before ORing into the bit fields.
[...]
Kernels prior to 2.6.25 prefer 32-bit capabilities with version
_LINUX_CAPABILITY_VERSION_1, and kernels 2.6.25+ prefer 64-bit capabil‐
ities with version _LINUX_CAPABILITY_VERSION_2. Note, 64-bit capabili‐
ties use datap[0] and datap[1], whereas 32-bit capabilities only use
datap[0].
其中datap
较早的指针__user_cap_data_struct
定义。所以你只是代表一个64bit的值,其中两个__u32
在两个__user_cap_data_struct
的数组中。
这个,单独告诉我永远不要使用这个API,所以我没有阅读手册的其余部分。
我一直认为每个功能都是在这3个位图的每一个中实现的,它们可以是设置的也可以是未设置的。所以我们有34种可能的功能,只有32位。 – abirvalg 2011-12-27 19:11:40
@abirvalg:他们不是。看看他们'#defined'的值。那些不是常量。 – Puppy 2011-12-27 19:23:48
@DeadMG:不幸的是...... – BatchyX 2011-12-27 20:52:48