Re: VNOP_GETATTR
Re: VNOP_GETATTR
- Subject: Re: VNOP_GETATTR
- From: Mike Smith <email@hidden>
- Date: Thu, 12 May 2005 12:17:09 -0700
On May 12, 2005, at 11:10 AM, Pezeshgi, Shahriar wrote:
I'm trying to read a file size from my KEXT under Tiger but I'm
getting
0 only, is there anyone with more experience on this?
struct vnode *vnode;
struct vnode_attr vattr;
If (VNOP_GETATTR (vnode, &vattr, vfs_context_create(NULL) == 0)
{
size = vattr.va_size;
}
Do not call VNOP_GETATTR, use vnode_getattr. Avoid using the VNOP
functions entirely; they are not
as a general rule meant to be called directly.
You must initialise the vnode_attr structure with VATTR_INIT, and set
the requested field(s) appropriately:
vnode_t vp; /* use vnode_t, to you it is not a structure, it's
a handle */
struct vnode_attr va;
vnode_context_t ctx;
VATTR_INIT(&va);
VATTR_WANTED(&va, va_data_size);
err = vnode_getattr(vp, &va, ctx);
if (!err && VATTR_IS_SUPPORTED(&va, va_data_size))
my_file_size = va.va_data_size;
Note that there are a number of size values associated with a file;
pick the one that best suits your needs.
Also note that vnode_getattr will synthesise values not supported by
the underlying filesystem; you don't
need to handle those cases yourself.
= Mike
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >VNOP_GETATTR (From: "Pezeshgi, Shahriar" <email@hidden>) |