在AFS (Andrew File System)中,单独的进程可以放在不同的PAG中,我的问题是:如何通过编程获得某个进程的PAG编号?谢谢。
发布于 2014-05-11 05:38:41
您可以在C程序中通过调用Russ Allbery here最初发布的VIOC_GETPAG pioctl来完成此操作
#include <stdio.h>
#include <afs/param.h>
#include <afs/afssyscalls.h>
#include <afs/vice.h>
#include <afs/vioc.h>
int
main(void)
{
struct ViceIoctl iob;
afs_uint32 pag;
int code;
iob.in = NULL;
iob.in_size = 0;
iob.out = (void *) &pag;
iob.out_size = sizeof(pag);
code = pioctl(NULL, VIOC_GETPAG, &iob, 0);
if (code != 0) {
fprintf(stderr, "Cannot get PAG\n");
return 1;
}
printf("PAG number is: %lu\n", (unsigned long) pag);
return 0;
}目前还没有正式的接口可以在C程序之外获取PAG号;比如说,通过运行一些命令。大多数情况下,您可以通过查看当前进程的补充组列表并查找编号非常高的组来确定PAG编号。然而,虽然目前这主要是“有效”的,但在某些情况下,这些信息可能是不正确的,并且不能保证它在未来对所有平台都有效。具体地说,在现代Linux上,PAG编号的权威位置在内核密钥环中,提供组id只是为了“尽最大努力”,将来可能会消失。
https://stackoverflow.com/questions/17802654
复制相似问题