}
/*
- * Allocate a buffer for scratch use by the kernel. This buffer can then
- * be freed with tmpfree.
- *
- * API note: Nothing guarantees a connection between a bufcache entry
- * and tmpbuf in future. Always free with tmpfree.
+ * Allocate an empty _disk cache_ buffer. We use this when dealing with file
+ * holes. It would be nice if this API could go way and readi just use uzero()
*/
-void *tmpbuf(void)
+bufptr zerobuf(void)
{
regptr bufptr bp;
bp = freebuf();
bp->bf_dev = NO_DEVICE;
bp->bf_time = ++bufclock; /* Time stamp it */
- return bp->__bf_data;
+ blkzero(bp);
+ return bp;
}
+#ifndef CONFIG_BLKBUF_EXTERNAL
/*
- * Allocate an empty _disk cache_ buffer. We use this when dealing with file
- * holes. It would be nice if this API could go way and readi just use uzero()
+ * Allocate a buffer for scratch use by the kernel. This buffer can then
+ * be freed with tmpfree.
*
- * This won't be able to use tmpbuf if we split disk and temporary buffers.
+ * API note: Nothing guarantees a connection between a bufcache entry
+ * and tmpbuf in future. Always free with tmpfree.
*/
-void *zerobuf(void)
+
+void *tmpbuf(void)
{
- void *b = tmpbuf();
- memset(b, 0, 512);
+ regptr bufptr bp;
- return b;
+ bp = freebuf();
+ bp->bf_dev = NO_DEVICE;
+ bp->bf_time = ++bufclock; /* Time stamp it */
+ return bp->__bf_data;
}
+#endif
/*
* Write back a buffer doing the locking outselves. This is called when
uget((uaddr),(buf)->__bf_data + (off), (len))
#define blkptr(buf, off, len) ((void *)((buf)->__bf_data + (off)))
#define blkzero(buf) memset(buf->__bf_data, 0, BLKSIZE)
+#define tmpfree(x) brelse((void *)x)
#else
extern void blktok(void *kaddr, struct blkbuf *buf, uint16_t off, uint16_t len);
extern void blkfromk(void *kaddr, struct blkbuf *buf, uint16_t off, uint16_t len);
/* Worst case is needing to copy over about 64 bytes */
extern void *blkptr(struct blkbuf *buf, uint16_t offset, uint16_t len);
extern void blkzero(struct blkbuf *buf);
+extern void tmpfree(void *p);
#endif
/* TODO: consider smaller inodes or clever caching. 2BSD uses small
extern void bawrite(bufptr);
extern int bfree(bufptr bp, uint8_t dirty); /* dirty: 0=clean, 1=dirty (write back), 2=dirty+immediate write */
extern void *tmpbuf(void);
-extern void *zerobuf(void);
+extern bufptr zerobuf(void);
extern void bufsync(void);
extern bufptr bfind(uint16_t dev, blkno_t blk);
extern void bdrop(uint16_t dev);
extern bufptr freebuf(void);
-#define tmpfree(x) brelse((void *)x)
extern void bufinit(void);
extern void bufdiscard(bufptr bp);
extern void bufdump (void);