- leftover_bits = b->bit_cnt % ELEM_BITS;
- if (leftover_bits == 0)
- return b->bits[i] == (elem_type) -1;
- else
- return b->bits[i] == ((elem_type) 1 << leftover_bits) - 1;
+#ifdef FILESYS
+/* Returns the number of bytes needed to store B in a file. */
+size_t
+bitmap_file_size (const struct bitmap *b)
+{
+ return byte_cnt (b);
+}
+
+/* Reads FILE into B, ignoring errors. */
+void
+bitmap_read (struct bitmap *b, struct file *file)
+{
+ if (b->bit_cnt > 0)
+ {
+ file_read_at (file, b->bits, byte_cnt (b), 0);
+ b->bits[elem_cnt (b) - 1] &= last_mask (b);
+ }
+}
+
+/* Writes FILE to B, ignoring errors. */
+void
+bitmap_write (const struct bitmap *b, struct file *file)
+{
+ file_write_at (file, b->bits, byte_cnt (b), 0);
+}
+#endif /* FILESYS */
+
+/* Dumps the contents of B to the console as hexadecimal. */
+void
+bitmap_dump (const struct bitmap *b)
+{
+ hex_dump (b->bits, byte_cnt (b), false);