Implement g_delete_data() similar to g_read_data() and g_write_data().

OK'ed by:	phk
This commit is contained in:
Pawel Jakub Dawidek 2007-05-05 16:35:22 +00:00
parent d19dbf4a23
commit 2b17fb9514
2 changed files with 23 additions and 0 deletions

View File

@ -275,6 +275,7 @@ struct bio *g_new_bio(void);
struct bio *g_alloc_bio(void);
void * g_read_data(struct g_consumer *cp, off_t offset, off_t length, int *error);
int g_write_data(struct g_consumer *cp, off_t offset, void *ptr, off_t length);
int g_delete_data(struct g_consumer *cp, off_t offset, off_t length);
void g_print_bio(struct bio *bp);
/* geom_kern.c / geom_kernsim.c */

View File

@ -646,6 +646,28 @@ g_write_data(struct g_consumer *cp, off_t offset, void *ptr, off_t length)
return (error);
}
int
g_delete_data(struct g_consumer *cp, off_t offset, off_t length)
{
struct bio *bp;
int error;
KASSERT(length > 0 && length >= cp->provider->sectorsize &&
length <= MAXPHYS, ("g_delete_data(): invalid length %jd",
(intmax_t)length));
bp = g_alloc_bio();
bp->bio_cmd = BIO_DELETE;
bp->bio_done = NULL;
bp->bio_offset = offset;
bp->bio_length = length;
bp->bio_data = NULL;
g_io_request(bp, cp);
error = biowait(bp, "gdelete");
g_destroy_bio(bp);
return (error);
}
void
g_print_bio(struct bio *bp)
{