+ register struct inode *ip;
+ register struct ufsmount *ump = VFSTOUFS(mp);
+ register struct fs *fs;
+ int error = 0;
+ static int updlock = 0;
+
+ if (syncprt)
+ bufstats();
+ if (updlock)
+ return (EBUSY);
+ fs = ump->um_fs;
+ if (fs == (struct fs *)1)
+ return (0);
+ updlock++;
+ /*
+ * Write back modified superblock.
+ * Consistency check that the superblock
+ * is still in the buffer cache.
+ */
+ if (fs->fs_fmod != 0) {
+ 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;
+ error = sbupdate(ump, waitfor);
+ }
+ /*
+ * Write back each (modified) inode.
+ */
+ for (ip = inode; ip < inodeNINODE; ip++) {
+ if (ip->i_devvp != ump->um_devvp ||
+ (ip->i_flag & ILOCKED) != 0 || ITOV(ip)->v_count == 0 ||
+ (ip->i_flag & (IMOD|IACC|IUPD|ICHG)) == 0)
+ continue;
+ ip->i_flag |= ILOCKED;
+ ITOV(ip)->v_count++;
+ error = iupdat(ip, &time, &time, waitfor == MNT_WAIT);
+ iput(ip);
+ }
+ updlock = 0;
+ /*
+ * Force stale buffer cache information to be flushed.
+ */
+ bflush(ump->um_devvp->v_rdev);
+ return (error);
+}
+
+/*
+ * Write a superblock and associated information back to disk.
+ */
+sbupdate(mp, waitfor)
+ struct ufsmount *mp;
+ int waitfor;
+{
+ register struct fs *fs = mp->um_fs;