Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Mar 2004 19:39:56 +0300
From:      Roman Bogorodskiy <bogorodskiy@inbox.ru>
To:        freebsd-hackers@freebsd.org
Subject:   kernel modules programming: struct proc question
Message-ID:  <20040316163956.GD638@lame.novel.ru>

index | next in thread | raw e-mail

[-- Attachment #1 --]
Hi,

	I hope it's a right place for kernel module programming related
questions, in another case I'd be glad if you point me to the right
maillist. 

So, my aim is to log every file opening in `/tmp' dir. I've wrote a simple
"syscall" module which replaces open(2) syscall. My new open(2) looks
like this:

>---cut 8<---
static int
new_open(struct proc *p, register struct open_args *uap)
{
        char name[NAME_MAX];
	        size_t size;

	if((const void*)copyinstr(uap->path, name,
		NAME_MAX, &size) == (const void*)EFAULT)
			                return(EFAULT);

	if (name[0] == '/' && name[1] == 't' && name[2] == 'm' 
		&& name[3] == 'p' && name[4] == '/') {
		printf("open(2): %s pid: %i\n", name, (int)p->p_pid);
	}

	return (open(p,	uap));
}

>---cut 9<---<

But instead of a real pid I see something strange in logs, something
like this:

Mar 16 19:15:44 nov kernel: open(2): /tmp/asfdasfsaf pid: -1002890624

What am I doing wrong? 

-Roman Bogorodskiy


[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (FreeBSD)

iQEVAwUBQFct3CpMDQ8aPhy0AQLjFQf/Wgdxi5MA5jklV/+DJDo+IvgVtubKyaw1
HDGOX2kW90kWebElVRE2yciQDfvSeYAmLgZSNcG2l7UKS9ThcJVfwpipVrNx+p2g
OA+n4TDAy3sjyuiLKKVv6NnFSColh2cLX+Io74gwoC46JKOKoG+oIVN3VqwcVU+L
ApwbKoJVQFQiRlAI1xtc0YqEWVT+NK9zi/XzUPIWDg+oOSVq+k0q3x/tzOUaQIrW
1L5Zn7ugvNm9uXs8smqeBnLhxsRwcjZGSD1AFbOtNB6Q2YL+gG0fE1+y9vyY5brE
H3Fj9g00GCENPXeN9jBI0TbDBjaU0/OclA//lcx9UDDsZM1ybN+1Bg==
=kj+/
-----END PGP SIGNATURE-----
help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040316163956.GD638>