From: Ben Pfaff Date: Mon, 30 Aug 2004 22:55:58 +0000 (+0000) Subject: Add bitmap_read(), bitmap_write(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af8e2a61dcde1dfb4d25178e2e193861a2173032;p=pintos-anon Add bitmap_read(), bitmap_write(). --- diff --git a/src/lib/bitmap.c b/src/lib/bitmap.c index 46235b2..593e509 100644 --- a/src/lib/bitmap.c +++ b/src/lib/bitmap.c @@ -4,6 +4,9 @@ #include "debug.h" #include "lib.h" #include "malloc.h" +#ifdef FILESYS +#include "file.h" +#endif #define ELEM_BITS (sizeof (elem_type) * CHAR_BIT) #define ELEM_IDX(BIT_IDX) ((BIT_IDX) / ELEM_BITS) @@ -218,3 +221,17 @@ bitmap_all (const struct bitmap *b) else return b->bits[i] == ((elem_type) 1 << leftover_bits) - 1; } + +#ifdef FILESYS +void +bitmap_read (struct bitmap *b, struct file *file) +{ + file_read_at (file, b->bits, byte_cnt (b), 0); +} + +void +bitmap_write (const struct bitmap *b, struct file *file) +{ + file_write_at (file, b->bits, byte_cnt (b), 0); +} +#endif /* FILESYS */ diff --git a/src/lib/bitmap.h b/src/lib/bitmap.h index 896a1e8..d3bda40 100644 --- a/src/lib/bitmap.h +++ b/src/lib/bitmap.h @@ -39,4 +39,10 @@ bool bitmap_any (const struct bitmap *); bool bitmap_none (const struct bitmap *); bool bitmap_all (const struct bitmap *); +#ifdef FILESYS +struct file; +void bitmap_read (struct bitmap *, struct file *); +void bitmap_write (const struct bitmap *, struct file *); +#endif + #endif /* bitmap.h */