Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 3 Jul 2008 14:08:12 +0300
From:      "Uladzislau Rezki" <urezki@gmail.com>
To:        freebsd-hackers@freebsd.org
Subject:   how can i get file name knowing its descriptor?
Message-ID:  <e4957ae10807030408tad26e7co11f6e3fb69afb01b@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
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



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