From owner-freebsd-hackers Mon Jul 23 18:12:45 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from sneakerz.org (sneakerz.org [216.33.66.254]) by hub.freebsd.org (Postfix) with ESMTP id 1CBDE37B406 for ; Mon, 23 Jul 2001 18:12:43 -0700 (PDT) (envelope-from bright@sneakerz.org) Received: by sneakerz.org (Postfix, from userid 1092) id 913295D01F; Mon, 23 Jul 2001 20:12:32 -0500 (CDT) Date: Mon, 23 Jul 2001 20:12:32 -0500 From: Alfred Perlstein To: rootx11@xfreek.mindriot.net Cc: freebsd-hackers@freebsd.org Subject: Re: your mail Message-ID: <20010723201232.A68587@sneakerz.org> References: <20010723195219.315.qmail@xfreek.mindriot.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: <20010723195219.315.qmail@xfreek.mindriot.net>; from rootx11@xfreek.mindriot.net on Mon, Jul 23, 2001 at 07:52:19PM -0000 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 * rootx11@xfreek.mindriot.net [010723 19:47] wrote: > Hello > I am experimenting with kernel modules and am trying to write to a file. > This is the syscall function (sorry of my terminology is messed up) > > static int write_file(struct proc *p, void *arg) { > struct write_args *wstructure; > struct open_args *ostructure; > > ostructure->path="/tmp/blehfile"; > ostructure->flags = O_CREAT; > ostructure->mode = 0; > wstructure->fd = open(p, ostructure); > wstructure->buf = "Testing\n"; > wstructure->nbytes = 8; > return write(p, wstructure); > } > > Im not sure why, but that code crashes. Was created with: > echo Hi > /tmp/blehfile. Also, is there an official freebsd kernel hackers > guide? Kernel programming is very interesting. ;-) The args to open() in the kernel are expected to point to a user address, so you have a couple of options: a) point your in kernel vmspace at the kernel b) copy your args into userspace using copyout and use those addresses there's no official guide, however if you pick up a couple of non-vendor specific OS programming textbooks you should have more fun. please use a more descriptive subject line, using an empty subject is likely to get your mail skipped over, also please do not send to the list more than once if possible. and lastly... check your damn return values, honestly! :) -- -Alfred Perlstein [alfred@freebsd.org] Ok, who wrote this damn function called '??'? And why do my programs keep crashing in it? To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message