Thanks
d
I'm actively working on a Windows port currently, but the going is
slow so FreeBSD is certainly not going to be released in the next
month (I'm pretty certain Windows won't be either).
I'm happy to help you if you start writing the code for it tough.
Almost a year ago I actually started with a FreeBSD port (7.1) as a
small experiment. Most stuff seemed fairly easy IIRC so it shouldn't
be too hard. Attached are the diffs/files I have of that, I doubt
they can be cleanly applied to the current trunk but might give
pointers or a starting point (or just be plain embarrasing since
you're probably a lot more familiar with FreeBSD then me).
Regards
Floris
--
Debian GNU/Linux -- The Power of Freedom
www.debian.org | www.gnu.org | www.kernel.org
Almost a year ago I actually started with a FreeBSD port (7.1) as a
small experiment. Most stuff seemed fairly easy IIRC so it shouldn't
be too hard. Attached are the diffs/files I have of that, I doubt
they can be cleanly applied to the current trunk but might give
pointers or a starting point (or just be plain embarrasing since
you're probably a lot more familiar with FreeBSD then me).
On Fri, Jan 15, 2010 at 09:40:28AM +0100, Davide Cittaro wrote:
> BTW, I've looked at your code and I agree that kinfo_proc is an
> interesting struct. Yesterday, before your answer, I've started and
> had something woking just filling the psi_process struct with data
> directly from kinfo_proc struct. I still have to figure how to get
> proci->exe and args as the procfs filesystem is not mounted by
> default and I don't want to use it at all. Nevertheless there's this
> in kinfo_proc:
> struct kinfo_proc {
> […]
> struct pargs *ki_args; /* address of command arguments */
> struct proc *ki_paddr; /* address of proc */
> struct user *ki_addr; /* kernel virtual addr of u-area */
> struct vnode *ki_tracep; /* pointer to trace file */
> struct vnode *ki_textvp; /* pointer to executable file */
> struct filedesc *ki_fd; /* pointer to open file info */
> struct vmspace *ki_vmspace; /* pointer to kernel vmspace struct */
> […]
>
> which could be exploited to fill the PSI process object.
Sounds like you should be able to use this ki_args to read the
arguments, but only if you have permission to read the process memory.
Maybe the best solution is to try /proc first as that's always
readable (is it?) and fall back to this method if it's not mounted,
but with the gotcha that you need to be able to read the process
memory (the solaris code does something similar, only there /proc
contains a chopped version of the args).
As for .exe, again going by the name, ki_textvp should contain this
info.
> Just an additional question: suppose I'm able to write everything,
> how can I test everything needed is working properly? Will setup.py
> test be enough?
If it's not we'll have to adapt it! It actually very likely will need
adapting since it uses "ps" to check the correctness of process
information and the ways to invoke "ps" tends to be different on OSs.
> python setup.py test --all
> running test
> running build
> running build_py
> running build_ext
> compiling helper apps for tests
> Traceback (most recent call last):
> File "setup.py", line 536, in <module>
> cmdclass = COMMANDS)
> File "/usr/local/lib/python2.6/distutils/core.py", line 152, in setup
> dist.run_commands()
> File "/usr/local/lib/python2.6/distutils/dist.py", line 975, in run_commands
> self.run_command(cmd)
> File "/usr/local/lib/python2.6/distutils/dist.py", line 995, in run_command
> cmd_obj.run()
> File "setup.py", line 342, in run
> self.compile_ctests()
> File "setup.py", line 389, in compile_ctests
> sys.exit('Unkown compiler: %s' % cc.compiler)
> NameError: global name 'cc' is not defined
That's a bug in setup.py! But I also think this is from a fairly old
version, could you use the latest version from bitbucket
(http://bitbucket.org/chrismiles/psi) before we try to find out if
this needs adapting for FreeBSD?
Sounds like you should be able to use this ki_args to read the
arguments, but only if you have permission to read the process memory.
Maybe the best solution is to try /proc first as that's always
readable (is it?) and fall back to this method if it's not mounted,
but with the gotcha that you need to be able to read the process
memory (the solaris code does something similar, only there /proc
contains a chopped version of the args).
As for .exe, again going by the name, ki_textvp should contain this
info.
That's a bug in setup.py! But I also think this is from a fairly old
version, could you use the latest version from bitbucket
(http://bitbucket.org/chrismiles/psi) before we try to find out if
this needs adapting for FreeBSD?