From owner-freebsd-hackers Sun Jun 18 17:47:14 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from po4.wam.umd.edu (po4.wam.umd.edu [128.8.10.166]) by hub.freebsd.org (Postfix) with ESMTP id 51A9237B73A for ; Sun, 18 Jun 2000 17:47:11 -0700 (PDT) (envelope-from howardjp@wam.umd.edu) Received: from rac9.wam.umd.edu (root@rac9.wam.umd.edu [128.8.10.149]) by po4.wam.umd.edu (8.9.3/8.9.3) with ESMTP id UAA20916 for ; Sun, 18 Jun 2000 20:47:12 -0400 (EDT) Received: from rac9.wam.umd.edu (sendmail@localhost [127.0.0.1]) by rac9.wam.umd.edu (8.9.3/8.9.3) with SMTP id UAA02835 for ; Sun, 18 Jun 2000 20:47:09 -0400 (EDT) Received: from rac9.wam.umd.edu (howardjp@localhost) by rac9.wam.umd.edu (8.9.3/8.9.3) with ESMTP id UAA02830 for ; Sun, 18 Jun 2000 20:47:09 -0400 (EDT) Message-Id: <200006190047.UAA02830@rac9.wam.umd.edu> X-Authentication-Warning: rac9.wam.umd.edu: howardjp owned process doing -bs To: freebsd-hackers@freebsd.org Subject: Why is this architecture dependent? Date: Sun, 18 Jun 2000 20:47:08 -0400 From: James Howard Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG We know I ask dumb questions a lot, but this one may not be so dumb. A friend of mine was joking about having a device called /dev/foo which would be like /dev/zero, except it would spit out the word "foo" over and over again. Well, we laughed about it, but today, I implemented it. (This was cool since this was the first time I've ever hacked the kernel and it worked right...) Needless to say, since this is so similar to /dev/zero, I just copied the code and modified it for foo in instead of 0s. But the file I had to modify was sys/i386/i386/mem.c. The relevant code for this is this: /* minor device 12 (/dev/zero) is source of nulls on read, rathole on write */ case 12: if (uio->uio_rw == UIO_WRITE) { c = iov->iov_len; break; } if (zbuf == NULL) { zbuf = (caddr_t) malloc(PAGE_SIZE, M_TEMP, M_WAITOK); bzero(zbuf, PAGE_SIZE); } c = min(iov->iov_len, PAGE_SIZE); error = uiomove(zbuf, (int)c, uio); continue; What makes this architecture dependent? The equivalent call from sys/alpha/alpha/mem.c is identical, except for this comment after the first if block: /* * On the first call, allocate and zero a page * of memory for use with /dev/zero. */ So why have this duplication? Why not implement it once and be done? Is there some subtle difference I am not seeing? Thanks, Jamie To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message