From owner-freebsd-hackers@FreeBSD.ORG Wed Apr 13 22:24:46 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B5AA6106564A for ; Wed, 13 Apr 2011 22:24:46 +0000 (UTC) (envelope-from jstuart@adaranet.com) Received: from barracuda.adaranet.com (smtp.adaranet.com [72.5.229.2]) by mx1.freebsd.org (Postfix) with ESMTP id 91A0D8FC12 for ; Wed, 13 Apr 2011 22:24:46 +0000 (UTC) X-ASG-Debug-ID: 1302733486-522b09040001-P5m3U7 Received: from SJ-EXCH-1.adaranet.com ([10.10.1.29]) by barracuda.adaranet.com with ESMTP id ZelwxkiC4BuY68Uc; Wed, 13 Apr 2011 15:24:46 -0700 (PDT) X-Barracuda-Envelope-From: jstuart@adaranet.com Received: from SJ-EXCH-1.adaranet.com ([fe80::7042:d8c2:5973:c523]) by SJ-EXCH-1.adaranet.com ([fe80::7042:d8c2:5973:c523%14]) with mapi; Wed, 13 Apr 2011 15:24:46 -0700 From: Jonathan Stuart X-Barracuda-BBL-IP: fe80::7042:d8c2:5973:c523 X-Barracuda-RBL-IP: fe80::7042:d8c2:5973:c523 To: Matthew Fleming Date: Wed, 13 Apr 2011 15:25:04 -0700 X-ASG-Orig-Subj: RE: Getting vnode + credentials of a file from a struct mount and UFS inode # Thread-Topic: Getting vnode + credentials of a file from a struct mount and UFS inode # Thread-Index: Acv6KOTQP1whERqtRW+zvPxfZ2hA2wAACMFA Message-ID: <32AB5C9615CC494997D9ABB1DB12783C024E929FE5@SJ-EXCH-1.adaranet.com> References: <32AB5C9615CC494997D9ABB1DB12783C024E929F93@SJ-EXCH-1.adaranet.com> <32AB5C9615CC494997D9ABB1DB12783C024E929FD0@SJ-EXCH-1.adaranet.com> <32AB5C9615CC494997D9ABB1DB12783C024E929FDC@SJ-EXCH-1.adaranet.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Barracuda-Connect: UNKNOWN[10.10.1.29] X-Barracuda-Start-Time: 1302733486 X-Barracuda-URL: http://172.16.10.203:8000/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at adaranet.com X-Mailman-Approved-At: Wed, 13 Apr 2011 23:23:34 +0000 Cc: "freebsd-hackers@freebsd.org" Subject: RE: Getting vnode + credentials of a file from a struct mount and UFS inode # X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Apr 2011 22:24:46 -0000 Hi, Yes, I am.. that was my suspicion (e.g., that it was the parameters of the = process which called open()/creat()/socket()/... originally). What's the q= uickest way to get back to the v/inode's uid/gid? Also, calling VFS_VGET() seems to give me a lockmgr panic with unknown type= 0x0. What is odd is that the only way I can get a vnode for VFS_VGET is through = struct file, and then shouldn't I be able to use that? I tried using the f= lipping that vnode->inode with VTOI() and it was also giving me zeros for i= _uid, i_gid, etc., when it shouldn't have been. Kind Regards, Jon -----Original Message----- From: Matthew Fleming [mailto:mdf356@gmail.com] Sent: Wednesday, April 13, 2011 3:20 PM To: Jonathan Stuart Cc: freebsd-hackers@freebsd.org Subject: Re: Getting vnode + credentials of a file from a struct mount and = UFS inode # On Wed, Apr 13, 2011 at 2:37 PM, Jonathan Stuart wro= te: > Yes, however getvnode() does initialize a struct file *.. but f_cred seem= s to not contain valid/correct entries. > In my last post I probably should have pointed out that I have the inode = stored from another operation. I haven't looked at this field before, but it looks that f_cred is set on falloc() to the cred of the thread creating the struct file (the thread that called open or socket or pipe or kqueue, etc.). Are you running this as root/wheel? Cheers, matthew > -----Original Message----- > From: Matthew Fleming [mailto:mdf356@gmail.com] > Sent: Wednesday, April 13, 2011 2:35 PM > To: Jonathan Stuart > Cc: freebsd-hackers@freebsd.org > Subject: Re: Getting vnode + credentials of a file from a struct mount an= d UFS inode # > > On Wed, Apr 13, 2011 at 2:18 PM, Jonathan Stuart w= rote: >> Hi Matthew, >> >> Thanks, I'll give it a shot.. for some reason f_cred off the vnode is re= turning all zeros for uid/gid, and >> pulling the VTOI does the same thing (using getvnode()).. do these not g= et initialized properly? > > f_cred is a field in struct file, not struct vnode, so I'm confused as > to what you're referring to. > > Cheers, > matthew > >> -----Original Message----- >> From: Matthew Fleming [mailto:mdf356@gmail.com] >> Sent: Wednesday, April 13, 2011 1:48 PM >> To: Jonathan Stuart >> Cc: freebsd-hackers@freebsd.org >> Subject: Re: Getting vnode + credentials of a file from a struct mount a= nd UFS inode # >> >> On Wed, Apr 13, 2011 at 12:31 PM, Jonathan Stuart = wrote: >>> Hi, >>> >>> I'd like to pull the owner/group ownership from a file (the information= I have about the file is it's UFS inode # and it's struct mount *). I'm s= ure there's got to be a function that would return a vnode and I could VTOI= () to get this information from the inode.. but I'm having a brainfreeze. >>> >> >> VFS_VGET(mp, ino, flags, &vp) is probably what you want. >> >> Cheers, >> matthew >> >