How to get ucred/xucred in user space?

Mike Ma mikemandarine at gmail.com
Tue May 14 08:00:27 UTC 2013


Hi folks,

Can I ask if there's any way to get ucred/xucred of a process in user space?
As I'm trying to port glustertfs and it's a userland filesystem, I need to
get secondary groups of a process.

AFAIK, Linux gets them in /proc and NetBSD gets them in this way:
        int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, frame->root->pid
};
        size_t namelen = sizeof name / sizeof name[0];
        struct kinfo_proc kp;
        size_t kplen = sizeof(kp);
int i, ngroups;
        if (sysctl(name, namelen, &kp, &kplen, NULL, 0) != 0)
                return;
        ngroups = MIN(kp.kp_eproc.e_ucred.cr_ngroups, GF_REQUEST_MAXGROUPS);

I realized none of them would work in FreeBSD.
I'm wondering if there's any alternative way to get group information?

-- 
Cheers,
Mike


More information about the freebsd-hackers mailing list