From owner-freebsd-hackers@FreeBSD.ORG Tue May 14 08:00:27 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id DDFAC71B for ; Tue, 14 May 2013 08:00:27 +0000 (UTC) (envelope-from mikemandarine@gmail.com) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx1.freebsd.org (Postfix) with ESMTP id A617D8B1 for ; Tue, 14 May 2013 08:00:27 +0000 (UTC) Received: by mail-vc0-f174.google.com with SMTP id hr11so198806vcb.5 for ; Tue, 14 May 2013 01:00:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=W8GAAtpX1dP6YPCWGoEP5ngcboZHxZRKPdmp6AQMZGw=; b=gcCI7IbO7dl+/PPj3X9S+4kIGok7xxgvz1JcNnGGFPabh/XeigxbMH5+3bmb/zZXhx N1tZa70503xB/xRe0grSjO8fCrMrwbNciDfTwIm4navbmAnsMK1bCM063k6qBO2uSzZZ +UDQVP74iJHhw4SMJ2LWiwphfz2MELajZALHX/gdC4C0QWNlXBJlkgPHA6f+W/chQJ5i is6mYBuhjpAct7W4xP+Qs0Gg11cxVxL5GwkMlENE8UX6t7ifl7AUT2XMqc8FhqnpB5SJ zgqF/SYCOub2EuBs7PPw8GJGucQLjPiWYLu6DZWX2GhE0A/0p59qh2DYYNtr3fdoKIUr Gzjg== MIME-Version: 1.0 X-Received: by 10.52.240.211 with SMTP id wc19mr17850657vdc.12.1368518421101; Tue, 14 May 2013 01:00:21 -0700 (PDT) Received: by 10.220.248.72 with HTTP; Tue, 14 May 2013 01:00:21 -0700 (PDT) Date: Tue, 14 May 2013 10:00:21 +0200 Message-ID: Subject: How to get ucred/xucred in user space? From: Mike Ma To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 May 2013 08:00:27 -0000 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