Hi,
   This might be a lame query...but ...

 I am trying to create a file from kernel space given
the vnode of the parent directory using VOP_CREATE.
The code is as below.

int make_file(struct vnode *dvp, struct vnode **vpp, struct proc *p, char 
*name)
{
    struct componentname cnp;
    struct vattr va, *vap = &va;

    /* set component name */
    cnp.cn_nameiop = CREATE;
    cnp.cn_flags = LOCKLEAF;
    cnp.cn_proc = p;
    cnp.cn_cred = p->p_ucred;
    cnp.cn_pnbuf = cnp.cn_nameptr = name;
    cnp.cn_namelen = cnp.cn_consume = strlen(name);

    /* set attributes */
    VATTR_NULL(vap);
    vap->va_type = VREG;

    return VOP_CREATE(dvp, vpp, &cnp, vap);
}

Now the file is getting created, but if I do an ls on its parent
directory, I get something like;
foo: Bad file descriptor.

I am sure I am doing something wrong or missing something. I tried looking
at the nfs and kern code, but couldn't figure out much.

Can you experts just correct me..

thanks in advance
nitin


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to