Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Jun 2002 20:58:19 -0500 (CDT)
From:      Nitin Bahadur <bnitin@cs.wisc.edu>
To:        hackers@freebsd.org
Subject:   kernel file creation query...
Message-ID:  <Pine.GSO.4.21.0206212052130.16911-100000@alumni.cs.wisc.edu>

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

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 majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.21.0206212052130.16911-100000>