From: Martin Mares Date: Mon, 15 Nov 1999 10:31:01 +0000 (+0000) Subject: Implemented pgc_get_zero(). X-Git-Tag: holmes-import~1649 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=302d2509b53224e828558f3f328be444adee77d6;p=libucw.git Implemented pgc_get_zero(). --- diff --git a/lib/pagecache.c b/lib/pagecache.c index 871babe3..67c1e713 100644 --- a/lib/pagecache.c +++ b/lib/pagecache.c @@ -278,6 +278,21 @@ pgc_get(struct page_cache *c, int fd, sh_off_t pos) return p; } +struct page * +pgc_get_zero(struct page_cache *c, int fd, sh_off_t pos) +{ + sh_off_t key; + struct page *p; + + ASSERT(!PAGE_OFFSET(pos)); + ASSERT(!PAGE_NUMBER(fd)); + key = pos | fd; + p = get_and_lock_page(c, key); + bzero(p->data, c->page_size); + p->flags |= PG_FLAG_VALID | PG_FLAG_DIRTY; + return p; +} + void pgc_put(struct page_cache *c, struct page *p) { diff --git a/lib/pagecache.h b/lib/pagecache.h index 7598f345..0c8b4d67 100644 --- a/lib/pagecache.h +++ b/lib/pagecache.h @@ -30,6 +30,7 @@ void pgc_flush(struct page_cache *); /* Write all unwritten pages */ void pgc_cleanup(struct page_cache *); /* Deallocate all unused buffers */ struct page *pgc_read(struct page_cache *, int fd, sh_off_t); /* Read page and lock it */ struct page *pgc_get(struct page_cache *, int fd, sh_off_t); /* Get page for writing */ +struct page *pgc_get_zero(struct page_cache *, int fd, sh_off_t); /* ... and clear it */ void pgc_put(struct page_cache *, struct page *); /* Release page */ void pgc_mark_dirty(struct page_cache *, struct page *); /* Mark locked page as dirty */ byte *pgc_read_data(struct page_cache *, int fd, sh_off_t, uns *); /* Partial reading */