From owner-freebsd-hackers Fri Aug 17 0: 5:37 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from bugz.infotecs.ru (bugz.infotecs.ru [195.210.139.22]) by hub.freebsd.org (Postfix) with ESMTP id DD00A37B407 for ; Fri, 17 Aug 2001 00:05:31 -0700 (PDT) (envelope-from vel@bugz.infotecs.ru) Received: (from root@localhost) by bugz.infotecs.ru (8.11.5/8.11.4) id f7H75G728300; Fri, 17 Aug 2001 11:05:16 +0400 (MSD) (envelope-from vel) From: "Eugene L. Vorokov" Message-Id: <200108170705.f7H75G728300@bugz.infotecs.ru> Subject: Re: Getting filename from descriptor or vnode struct To: lorenzo@linuxbe.org (Sansonetti Laurent) Date: Fri, 17 Aug 2001 11:05:15 +0400 (MSD) Cc: freebsd-hackers@freebsd.org In-Reply-To: from "Sansonetti Laurent" at Aug 16, 2001 07:24:43 PM X-Mailer: ELM [version 2.5 PL5] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 > 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