Subject: COMPAT_SUNOS and DEVZERO
To: None <mike@cs.utah.edu, deraadt@fsa.ca, glass@sun-lamp.cs.berkeley.edu>
From: Gordon W. Ross <gwr@jericho.mc.com>
List: tech-kern
Date: 04/26/1994 10:52:46
> Date: Mon, 25 Apr 94 16:13:50 -0600
> From: mike@cs.utah.edu (Mike Hibler)
>
> In 4.4 Lite (shipping now!) the /dev/zero mmap hack has been elevated to
> machine independent status. It uses a function, iszerodev(dev_t) defined
> in conf.c, to make the determination.
>
> Mike
OK, a function is fine with me. Will the 4.4 Lite changes be there
soon? If not, I'd like to put in the new iszerodev(dev_t) function.
Here are the changes re-done using iszerodev(dev_t):
diff -c compat/sunos/sun_misc.c.orig compat/sunos/sun_misc.c
*** compat/sunos/sun_misc.c.orig Mon Apr 25 06:27:24 1994
--- compat/sunos/sun_misc.c Tue Apr 26 10:36:22 1994
***************
*** 404,415 ****
return (error);
}
- #if defined(sparc)
- #define DEVZERO makedev(3, 12) /* major,minor of /dev/zero */
- #else /* all m68k architectures */
- #define DEVZERO makedev(2, 12) /* major,minor of /dev/zero */
- #endif
-
#define SUN__MAP_NEW 0x80000000 /* if not, old mmap & cannot handle */
struct sun_mmap_args {
--- 404,409 ----
***************
*** 453,459 ****
(fp = fdp->fd_ofiles[uap->fd]) != NULL && /*XXX*/
fp->f_type == DTYPE_VNODE && /*XXX*/
(vp = (struct vnode *)fp->f_data)->v_type == VCHR && /*XXX*/
! vp->v_rdev == DEVZERO) { /*XXX*/
uap->flags |= MAP_ANON;
uap->fd = -1;
}
--- 447,453 ----
(fp = fdp->fd_ofiles[uap->fd]) != NULL && /*XXX*/
fp->f_type == DTYPE_VNODE && /*XXX*/
(vp = (struct vnode *)fp->f_data)->v_type == VCHR && /*XXX*/
! iszerodev(vp->v_rdev) { /*XXX*/
uap->flags |= MAP_ANON;
uap->fd = -1;
}
diff -c arch/sun3/sun3/conf.c.orig arch/sun3/sun3/conf.c
*** arch/sun3/sun3/conf.c.orig Tue Mar 1 06:21:50 1994
--- arch/sun3/sun3/conf.c Tue Apr 26 10:41:56 1994
***************
*** 255,261 ****
--- 255,266 ----
int nchrdev = sizeof (cdevsw) / sizeof (cdevsw[0]);
+ /* I'd like to change this to 3 for SunOS 4.1.1 compatibility. -gwr */
int mem_no = 2; /* major device number of memory special file */
+ int iszerodev(dev_t dev)
+ {
+ return(dev == makedev(mem_no, 12));
+ }
/*
* Swapdev is a fake device implemented
diff -c arch/sparc/sparc/conf.c.orig arch/sparc/sparc/conf.c
*** arch/sparc/sparc/conf.c.orig Thu Mar 3 05:57:16 1994
--- arch/sparc/sparc/conf.c Tue Apr 26 10:43:08 1994
***************
*** 430,435 ****
--- 430,439 ----
int nchrdev = sizeof (cdevsw) / sizeof (cdevsw[0]);
int mem_no = 3; /* major device number of memory special file */
+ int iszerodev(dev_t dev)
+ {
+ return(dev == makedev(mem_no, 12));
+ }
/*
* Swapdev is a fake device implemented
diff -c arch/amiga/amiga/conf.c.orig arch/amiga/amiga/conf.c
*** arch/amiga/amiga/conf.c.orig Wed Apr 6 06:16:01 1994
--- arch/amiga/amiga/conf.c Tue Apr 26 10:44:06 1994
***************
*** 416,421 ****
--- 416,425 ----
#endif
int mem_no = 2; /* major device number of memory special file */
+ int iszerodev(dev_t dev)
+ {
+ return(dev == makedev(mem_no, 12));
+ }
/*
* Swapdev is a fake device implemented
diff -c arch/mac68k/mac68k/conf.c.orig arch/mac68k/mac68k/conf.c
*** arch/mac68k/mac68k/conf.c.orig Fri Feb 4 05:11:27 1994
--- arch/mac68k/mac68k/conf.c Tue Apr 26 10:44:42 1994
***************
*** 363,368 ****
--- 363,372 ----
int nchrdev = sizeof (cdevsw) / sizeof (cdevsw[0]);
int mem_no = 2; /* major device number of memory special file */
+ int iszerodev(dev_t dev)
+ {
+ return(dev == makedev(mem_no, 12));
+ }
/*
* Swapdev is a fake device implemented
------------------------------------------------------------------------------