]> mj.ucw.cz Git - libucw.git/commitdiff
Implemented pgc_get_zero().
authorMartin Mares <mj@ucw.cz>
Mon, 15 Nov 1999 10:31:01 +0000 (10:31 +0000)
committerMartin Mares <mj@ucw.cz>
Mon, 15 Nov 1999 10:31:01 +0000 (10:31 +0000)
lib/pagecache.c
lib/pagecache.h

index 871babe3d91297582c97d92dd2454de8ea7ba8fc..67c1e71399835dc79c36ec258aae20b027bec7c7 100644 (file)
@@ -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)
 {
index 7598f3459b80eedf9256cf738c3347e0a4c0bbd8..0c8b4d673a8e1499115749378d8fca53660c8f56 100644 (file)
@@ -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 */