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