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

next in thread | previous in thread | raw e-mail | index | archive | help
> 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?11353544.443834.1302742821487.JavaMail.root>