Re: how can i get file name knowing its descriptor?

2008-07-04 Thread Peter Jeremy
On 2008-Jul-03 14:08:12 +0300, Uladzislau Rezki <[EMAIL PROTECTED]> wrote:
>I've been writing a small kernel module, that provides information about
>modification of the filesystem to user_land/userspace through the
>character device. I'm using FreeBSD 4.10

4.10 has not been supported for several years now.  I strongly recommend
you look at upgrading to at least 6.3.

>So, my question is: Is there any way to get file name knowing its descriptor?

The simple answer is no.  That said, you could try having a look at
how lsof works (whilst it runs in userland, it needs to grovel around
in the kernel datastructures much the same as your module would need to.

-- 
Peter Jeremy
Please excuse any delays as the result of my ISP's inability to implement
an MTA that is either RFC2821-compliant or matches their claimed behaviour.


pgpvMoGfEnFHe.pgp
Description: PGP signature


how can i get file name knowing its descriptor?

2008-07-03 Thread Uladzislau Rezki
Hi all,

I've been writing a small kernel module, that provides information about
modification of the filesystem to user_land/userspace through the
character device. I'm using FreeBSD 4.10

So, my question is: Is there any way to get file name knowing its descriptor?

static int
xxx_write (struct proc *p, struct write_args *uap)
{
struct vnode *vn;
struct file *file;
int sys_error;

/* do system call */
sys_error = write(p, uap);
if (sys_error != 0)
goto leave_call;

/* get the file */
file = curproc->p_fd->fd_ofiles[uap->fd];
/* get the vnode */
vn = (struct vnode *) file->f_data;

/* do we have a regular */
if (vn->v_type == VREG) {
...
...
...
}

As you can see we just know uap->fd.

BTW, it would be fine to get a few web resources concerning FreeBSD
kernel programming.

Thanks.

--
Uladzislau Rezki
___
freebsd-hackers@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "[EMAIL PROTECTED]"