From owner-freebsd-hackers Fri Aug 17 9:10:42 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from InterJet.elischer.org (c421509-a.pinol1.sfba.home.com [24.7.86.9]) by hub.freebsd.org (Postfix) with ESMTP id E246A37B410 for ; Fri, 17 Aug 2001 09:10:30 -0700 (PDT) (envelope-from julian@elischer.org) Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id JAA22994; Fri, 17 Aug 2001 09:06:42 -0700 (PDT) Date: Fri, 17 Aug 2001 09:06:42 -0700 (PDT) From: Julian Elischer To: "Eugene L. Vorokov" Cc: Sansonetti Laurent , freebsd-hackers@freebsd.org Subject: Re: Getting filename from descriptor or vnode struct In-Reply-To: <200108170705.f7H75G728300@bugz.infotecs.ru> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG you are going to have to examine the name cache and find the inode of the directories in the full path. Most open directories will have their full path in the caches.. On Fri, 17 Aug 2001, Eugene L. Vorokov wrote: > > Hi hackers, > > > > I'm confronted to a problem when I try to hack getdirentries(2) in a kld > > module : > > > > To summarize, getdirentries() filled in a buffer a series of dirent struct, > > and the 'd_name' field represents the filename (without the full path). I > > must recover the full path because I've on disk a list of files to hide ... > > > > The field 'fd' in getdirentries_args is the file descriptor of the > > directory.. and I've discovered that the field 'p_fd' from struct proc is a > > filedesc struct which contains a vnode struct representing the current > > directory ('fd_cdir'). > > > > VOP_GETATTR() doesn't allow me to recover this.. > > > > If someone could help me, thanks in advance ! > > I think the best way would be to also hack open() and close(). You can have > some table where you store fd and full pathname of each opened directory. > You add an entry on open() and remove it on close(). Of course, open() > argument may be a path relative to current directory, so to get full path > you should simulate __getcwd() syscall; you must allocate userland buffer > for it with mmap() and then copyin() it (read my previous posting). Once > you have such table, you can find the path by fd in hacked getdirentries() > and see if you want to hide the file or not ... > > Regards, > Eugene > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message