[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-hackers
Subject:    RE: Getting vnode + credentials of a file from a struct mount and
From:       Jonathan Stuart <jstuart () adaranet ! com>
Date:       2011-04-14 1:02:18
Message-ID: 32AB5C9615CC494997D9ABB1DB12783C024E92A00D () SJ-EXCH-1 ! adaranet ! com
[Download RAW message or body]

[Attachment #2 (unknown)]

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


_______________________________________________
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic