マニュアルをすべて読んだわけではありません。
capgetマニュアルは、あなたがそれを使用しないように説得することから始まり:datap
は以前__user_cap_data_struct
へのポインタとして定義されて
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].
。したがって、2つの__u32
の配列が2つの__user_cap_data_struct
の64ビット値を表します。
これだけでこのAPIを使用しないように指示しているので、残りのマニュアルは読んでいません。
私はいつも、それぞれの機能が、設定されているか設定されていないこれらの3つのビットマップのそれぞれのビットとして実装されていると考えました。そのため、32ビットの34の可能な機能があります。 – abirvalg
@abirvalg:そうではありません。それらが '#defined'にある値を見てください。それらはビット定数ではありません。 – Puppy
@DeadMG:残念ながら... – BatchyX