From owner-freebsd-hackers@FreeBSD.ORG Thu Jul 3 11:35:01 2008 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AD7D31065678 for ; Thu, 3 Jul 2008 11:35:01 +0000 (UTC) (envelope-from urezki@gmail.com) Received: from fk-out-0910.google.com (fk-out-0910.google.com [209.85.128.185]) by mx1.freebsd.org (Postfix) with ESMTP id 33B4A8FC29 for ; Thu, 3 Jul 2008 11:35:00 +0000 (UTC) (envelope-from urezki@gmail.com) Received: by fk-out-0910.google.com with SMTP id k31so583246fkk.11 for ; Thu, 03 Jul 2008 04:34:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type:content-transfer-encoding :content-disposition; bh=BSCfcAt1P7bCoyWkqmXj4epy64YPR2d5OwApfm5HzTE=; b=Ifz9bFyMH6pb83azo0Wdjw0pJ2I2PM3r8/8GMBt/TQtPE7qy+bAqoPLL1bDg8x09xB YQ3Pa/LkEpZnp+UsMPAQpPJWu8bobe+drfUW0B2PbvEttYLOgVbtWusHIf5rnfdMqRGA +WMIPxfx+16z//1N48NT71qAPk57w9UY83xQ0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition; b=SRRS/1IMoyiG45QdbfEgDPrXVOgJHPv0isi10vM6rkR65NiZ0hzgeOBGaU4SLGl0fL Vmx+gtGRkvIDHvrvGmY3py6KiEXzzPmqdXxrzwKPFFyuUQcwHOdD5pRvBx3booe5mOD6 rMhQMjUy62rKZDVlXfJGK4LRt1pSxxb3SsFm0= Received: by 10.86.94.11 with SMTP id r11mr113436fgb.0.1215083292572; Thu, 03 Jul 2008 04:08:12 -0700 (PDT) Received: by 10.86.49.9 with HTTP; Thu, 3 Jul 2008 04:08:12 -0700 (PDT) Message-ID: Date: Thu, 3 Jul 2008 14:08:12 +0300 From: "Uladzislau Rezki" To: freebsd-hackers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Mailman-Approved-At: Thu, 03 Jul 2008 11:40:05 +0000 Subject: how can i get file name knowing its descriptor? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jul 2008 11:35:01 -0000 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