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>
next in thread | raw e-mail | index | archive | help
--JwB53PgKC5A7+0Ej Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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.=20 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) =3D=3D (const void*)EFAULT) return(EFAULT); if (name[0] =3D=3D '/' && name[1] =3D=3D 't' && name[2] =3D=3D 'm'=20 && name[3] =3D=3D 'p' && name[4] =3D=3D '/') { 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?=20 -Roman Bogorodskiy --JwB53PgKC5A7+0Ej Content-Type: application/pgp-signature Content-Disposition: inline -----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----- --JwB53PgKC5A7+0Ej--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040316163956.GD638>