- /* Now, write the ifile */
- if ((wbytes = write(fd, ifile, lfsp->lfs_bsize)) < 0)
- fatal("%s: %s", special, strerror(errno));
- if (wbytes != lfsp->lfs_bsize)
- fatal("%s: short write (%d, not %d)",
- special, wbytes, lfsp->lfs_bsize);
+ /* Now, write the segment */
+
+ /* Compute a checksum across all the data you're writing */
+ dp = datasump = malloc (blocks_used * sizeof(u_long));
+ *dp++ = ((u_long *)dip)[0]; /* inode block */
+ for (i = 0; i < lfsp->lfs_cleansz; i++)
+ *dp++ = ((u_long *)cleaninfo)[(i << lfsp->lfs_bshift) /
+ sizeof(u_long)]; /* Cleaner info */
+ for (i = 0; i < lfsp->lfs_segtabsz; i++)
+ *dp++ = ((u_long *)segtable)[(i << lfsp->lfs_bshift) /
+ sizeof(u_long)]; /* Segusage table */
+ *dp++ = ((u_long *)ifile)[0]; /* Ifile */
+
+ /* Still need the root and l+f bytes; get them later */
+
+ /* Write out the inode block */
+ off = LFS_LABELPAD + LFS_SBPAD + LFS_SUMMARY_SIZE;
+ put(fd, off, dpagep, lfsp->lfs_bsize);
+ free(dpagep);
+ off += lfsp->lfs_bsize;
+
+ /* Write out the ifile */
+
+ put(fd, off, cleaninfo, lfsp->lfs_cleansz << lfsp->lfs_bshift);
+ off += (lfsp->lfs_cleansz << lfsp->lfs_bshift);
+ (void)free(cleaninfo);
+
+ put(fd, off, segtable, lfsp->lfs_segtabsz << lfsp->lfs_bshift);
+ off += (lfsp->lfs_segtabsz << lfsp->lfs_bshift);
+ (void)free(segtable);
+
+ put(fd, off, ifile, lfsp->lfs_bsize);
+ off += lfsp->lfs_bsize;
+
+ /*
+ * use ipagep for space for writing out other stuff. It used to
+ * contain the ifile, but we're done with it.
+ */