diff options
author | pjd <pjd@FreeBSD.org> | 2007-05-05 16:35:22 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2007-05-05 16:35:22 +0000 |
commit | 835266e08861e25f33237e630f3095cc6ee3ee79 (patch) | |
tree | 798a84202a3b98f800224e5bfca306eec30270fd | |
parent | ddfa2416f5fd67d07e1e660be1dbdc2e15598197 (diff) | |
download | FreeBSD-src-835266e08861e25f33237e630f3095cc6ee3ee79.zip FreeBSD-src-835266e08861e25f33237e630f3095cc6ee3ee79.tar.gz |
Implement g_delete_data() similar to g_read_data() and g_write_data().
OK'ed by: phk
-rw-r--r-- | sys/geom/geom.h | 1 | ||||
-rw-r--r-- | sys/geom/geom_io.c | 22 |
2 files changed, 23 insertions, 0 deletions
diff --git a/sys/geom/geom.h b/sys/geom/geom.h index eb9b595..dea2272 100644 --- a/sys/geom/geom.h +++ b/sys/geom/geom.h @@ -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 */ diff --git a/sys/geom/geom_io.c b/sys/geom/geom_io.c index beb74fe..a69d764 100644 --- a/sys/geom/geom_io.c +++ b/sys/geom/geom_io.c @@ -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) { |