Date: Fri, 17 Aug 2001 11:05:15 +0400 (MSD) From: "Eugene L. Vorokov" <vel@bugz.infotecs.ru> To: lorenzo@linuxbe.org (Sansonetti Laurent) Cc: freebsd-hackers@freebsd.org Subject: Re: Getting filename from descriptor or vnode struct Message-ID: <200108170705.f7H75G728300@bugz.infotecs.ru> In-Reply-To: <no.id> from "Sansonetti Laurent" at Aug 16, 2001 07:24:43 PM
next in thread | previous in thread | raw e-mail | index | archive | help
> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200108170705.f7H75G728300>