Lines Matching refs:bch
2 * drivers/bch/bchlib_setup.c
32 #include "bch.h"
49 struct bchlib_s *bch;
58 bch = (struct bchlib_s *)zalloc(sizeof(struct bchlib_s));
59 if (!bch)
67 ret = open_blockdriver(blkdev, readonly ? MS_RDONLY : 0, &bch->vnode);
74 struct drv_data *drv = (struct drv_data *)bch->vnode->data;
77 DEBUGASSERT(bch->vnode && bops && bops->geometry);
79 ret = bops->geometry(bch->vnode, &geo);
102 (void)sem_init(&bch->sem, 0, 1);
103 bch->nsectors = geo.geo_nsectors;
104 bch->sectsize = geo.geo_sectorsize;
105 bch->sector = (size_t)-1;
106 bch->readonly = readonly;
107 bch->dirty = false;
108 bch->unlinked = false;
110 part = los_part_find(bch->vnode);
113 bch->sectstart = part->sector_start;
114 bch->nsectors = part->sector_count;
115 bch->disk = get_disk(part->disk_id);
126 bch->buffer = (uint8_t *)malloc(bch->sectsize);
127 if (!bch->buffer)
134 *handle = bch;
138 (void)sem_destroy(&bch->sem);
139 free(bch);