Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Apr 2011 18:02:18 -0700
From:      Jonathan Stuart <jstuart@adaranet.com>
To:        Rick Macklem <rmacklem@uoguelph.ca>
Cc:        "freebsd-hackers@freebsd.org" <freebsd-hackers@freebsd.org>, Fleming <mdf356@gmail.com>, Matthew
Subject:   RE: Getting vnode + credentials of a file from a struct mount and UFS inode #
Message-ID:  <32AB5C9615CC494997D9ABB1DB12783C024E92A00D@SJ-EXCH-1.adaranet.com>
In-Reply-To: <11353544.443834.1302742821487.JavaMail.root@erie.cs.uoguelph.ca>
References:  <32AB5C9615CC494997D9ABB1DB12783C024E929FE5@SJ-EXCH-1.adaranet.com> <11353544.443834.1302742821487.JavaMail.root@erie.cs.uoguelph.ca>

next in thread | previous in thread | raw e-mail | index | archive | help

Thanks Rick, will try!

-----Original Message-----
From: Rick Macklem [mailto:rmacklem@uoguelph.ca]
Sent: Wednesday, April 13, 2011 6:00 PM
To: Jonathan Stuart
Cc: freebsd-hackers@freebsd.org; Matthew Fleming
Subject: Re: Getting vnode + credentials of a file from a struct mount and UFS inode #

> 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 quickest 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.

VFS_VGET() returns a vnode ptr, it doesn't need the argument set to one.
The flags argument (assuming a recent kernel) needs to be LK_EXCLUSIVE or
LK_SHARED, not 0 (I suspect that's your panic).

> 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 flipping that vnode->inode with VTOI() and it was also
> giving me zeros for i_uid, i_gid, etc., when it shouldn't have been.
>
After VFS_VGET returns a vp, I'd do a VOP_GETATTR() and then vput() the
vp to release it. Look for examples of these calls in the kernel sources.
The "struct vattr" filled in by VOP_GETATTR() has va_uid and va_gid in it,
which are the uid,gid that owns the file, which is what I think you are
trying to get. (Credentials generally refer to the effective uid + gids
etc of the process/thread trying to do the syscall.)

rick


Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?32AB5C9615CC494997D9ABB1DB12783C024E92A00D>