-
-/*
- * Getfsx returns the index in the file system
- * table of the specified device. The swap device
- * is also assigned a pseudo-index. The index may
- * be used as a compressed indication of the location
- * of a block, recording
- * <getfsx(dev),blkno>
- * rather than
- * <dev, blkno>
- * provided the information need remain valid only
- * as long as the file system is mounted.
- */
-getfsx(dev)
- dev_t dev;
-{
- register struct mount *mp;
-
- if (dev == swapdev)
- return (MSWAPX);
- for(mp = &mount[0]; mp < &mount[NMOUNT]; mp++)
- if (mp->m_dev == dev)
- return (mp - &mount[0]);
- return (-1);
-}
-
-/*
- * Update is the internal name of 'sync'. It goes through the disk
- * queues to initiate sandbagged IO; goes through the inodes to write
- * modified nodes; and it goes through the mount table to initiate
- * the writing of the modified super blocks.
- */
-update()
-{
- register struct inode *ip;
- register struct mount *mp;
- struct fs *fs;
-
- if (updlock)
- return;
- updlock++;
- /*
- * Write back modified superblocks.
- * Consistency check that the superblock
- * of each file system is still in the buffer cache.
- */
- for (mp = &mount[0]; mp < &mount[NMOUNT]; mp++) {
- if (mp->m_bufp == NULL)
- continue;
- fs = mp->m_bufp->b_un.b_fs;
- if (fs->fs_fmod == 0)
- continue;
- if (fs->fs_ronly != 0) { /* XXX */
- printf("fs = %s\n", fs->fs_fsmnt);
- panic("update: rofs mod");
- }
- fs->fs_fmod = 0;
- fs->fs_time = time.tv_sec;
- sbupdate(mp);
- }
- /*
- * Write back each (modified) inode.
- */
- for (ip = inode; ip < inodeNINODE; ip++) {
- if ((ip->i_flag & ILOCKED) != 0 || ip->i_count == 0)
- continue;
- ip->i_flag |= ILOCKED;
- ip->i_count++;
- iupdat(ip, time, time, 0);
- iput(ip);
- }
- updlock = 0;
- /*
- * Force stale buffer cache information to be flushed,
- * for all devices.
- */
- bflush(NODEV);
-}
-