Subject: iinit() in-lined, /netnix messages shortened Index: sys/init_main.c 2.11BSD Description: The routine iinit() needed be a separate function, it should be inlined as 4.3's is. Also the funtion mountfs() can be called to do the actual mounting of the root filesystem with care being taken to make m_inodp nonzero upon return. These steps save text space (the time savings are immaterial since these are once only routines). Some of the error messages in netinit() were trimmed back to offset the increased size of cdevsw[]. With the changes to the error messages the overall D-space growth was held to 30 bytes. Repeat-By: Examine the source. Fix: Apply the following patch and recompile the kernel when convenient. ------------------------------------------------------------------------ *** /usr/src/sys/sys/init_main.c.old Sun Apr 8 02:39:53 1990 --- /usr/src/sys/sys/init_main.c Sun Sep 22 12:50:36 1991 *************** *** 3,9 **** * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)init_main.c 1.2 (2.10BSD Berkeley) 1/26/90 */ #include "param.h" --- 3,9 ---- * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. * ! * @(#)init_main.c 1.3 (2.11BSD Berkeley) 9/22/91 */ #include "param.h" *************** *** 48,53 **** --- 48,54 ---- { register struct proc *p; register int i; + register struct fs *fs; startup(); *************** *** 92,99 **** #endif nchinit(); clkstart(); - iinit(); /* kick off timeout driven events by calling first time */ schedcpu(); --- 93,111 ---- #endif nchinit(); clkstart(); + for (i = 0; i < nblkdev; i++) + (void)(*bdevsw[i].d_root)(); + (*bdevsw[major(swapdev)].d_open)(swapdev, B_READ); + fs = mountfs(rootdev, boothowto & RB_RDONLY, (struct inode *)0); + if (!fs) + panic("iinit"); + mount[0].m_inodp = (struct inode *)1; /* XXX */ + fs->fs_fsmnt[0] = '/'; + fs->fs_fsmnt[1] = '\0'; + time.tv_sec = fs->fs_time; + boottime = time; + /* kick off timeout driven events by calling first time */ schedcpu(); *************** *** 198,248 **** #endif } - /* - * Iinit is called once (from main) very early in initialization. - * It reads the root's super block and initializes the current date - * from the last modified date. - * - * panic: iinit -- cannot read the super block - * (usually because of an IO error). - */ - static - iinit() - { - register struct bdevsw *bdp; - register struct buf *bp; - register struct fs *fp; - - for (bdp = bdevsw; bdp < bdevsw + nblkdev; bdp++) - (void)(*bdp->d_root)(); - (*bdevsw[major(rootdev)].d_open)(rootdev, B_READ); - (*bdevsw[major(swapdev)].d_open)(swapdev, B_READ); - bp = bread(rootdev, SUPERB); - if (u.u_error) - panic("iinit"); - fp = &mount[0].m_filsys; - bcopy(mapin(bp), (caddr_t)fp, sizeof(struct fs)); - mapout(bp); - mount[0].m_inodp = (struct inode *)1; - brelse(bp); - mount[0].m_dev = rootdev; - fp->fs_flock = fp->fs_ilock = fp->fs_ronly = 0; - fp->fs_lasti = 1; - fp->fs_nbehind = 0; - fp->fs_fsmnt[0] = '/'; - fp->fs_fsmnt[1] = '\0'; - fp->fs_ronly = boothowto&RB_RDONLY ? 1 : 0; - time.tv_sec = fp->fs_time; - boottime = time; - } - #ifdef UCB_NET memaddr netdata; /* click address of start of net data */ /* * We are called here after all the other init routines (clist, inode, ! * unibusmap, etc...) have been called. 'init' is probably running, but ! * other than that we can allocate memory without fragmenting. Open the * file NETNIX and read the a.out header, based on that go allocate * memory and read the text+data into the memory. Set up supervisor page * registers, SDSA6 and SDSA7 have already been set up in mch_start.s. --- 210,221 ---- #endif } #ifdef UCB_NET memaddr netdata; /* click address of start of net data */ /* * We are called here after all the other init routines (clist, inode, ! * unibusmap, etc...) have been called. Open the * file NETNIX and read the a.out header, based on that go allocate * memory and read the text+data into the memory. Set up supervisor page * registers, SDSA6 and SDSA7 have already been set up in mch_start.s. *************** *** 269,294 **** ndp->ni_segflg = UIO_SYSSPACE; ndp->ni_dirp = NETNIX; if (!(ip = namei(ndp))) { ! printf("%s: not found.\n", NETNIX); goto leave; } if ((ip->i_mode & IFMT) != IFREG || !ip->i_size) { ! printf("%s: bad inode\n", NETNIX); goto leave; } err = rdwri(UIO_READ, ip, &ex, sizeof (ex), (off_t)0, UIO_SYSSPACE, &resid); if (err || resid) { ! printf("%s: header err %d\n", NETNIX, ret); goto leave; } if (ex.a_magic != A_MAGIC3) { ! printf("%s: bad magic %o.\n", NETNIX, ex.a_magic); goto leave; } lsize = (long)ex.a_data + (long)ex.a_bss; if (lsize > 48L * 1024L) { ! printf("%s: too big, %ld\n", NETNIX, lsize); goto leave; } nettsize = btoc(ex.a_text); --- 242,267 ---- ndp->ni_segflg = UIO_SYSSPACE; ndp->ni_dirp = NETNIX; if (!(ip = namei(ndp))) { ! printf("%s not found\n", NETNIX); goto leave; } if ((ip->i_mode & IFMT) != IFREG || !ip->i_size) { ! printf("%s bad inode\n", NETNIX); goto leave; } err = rdwri(UIO_READ, ip, &ex, sizeof (ex), (off_t)0, UIO_SYSSPACE, &resid); if (err || resid) { ! printf("%s header err %d\n", NETNIX, ret); goto leave; } if (ex.a_magic != A_MAGIC3) { ! printf("%s bad magic %o\n", NETNIX, ex.a_magic); goto leave; } lsize = (long)ex.a_data + (long)ex.a_bss; if (lsize > 48L * 1024L) { ! printf("%s too big %ld\n", NETNIX, lsize); goto leave; } nettsize = btoc(ex.a_text); *************** *** 321,327 **** err = rdwri(UIO_READ, ip, oneclick, ex.a_data & 077, off, UIO_SYSSPACE, &resid); if (err || resid) { ! release: printf("%s: err %d resid %d\n", NETNIX, err, resid); mfree(coremap, nettsize, nettext); mfree(coremap, netdsize, netdata); nettsize = netdsize = 0; --- 294,300 ---- err = rdwri(UIO_READ, ip, oneclick, ex.a_data & 077, off, UIO_SYSSPACE, &resid); if (err || resid) { ! release: printf("%s err %d\n", NETNIX, err); mfree(coremap, nettsize, nettext); mfree(coremap, netdsize, netdata); nettsize = netdsize = 0;