From 9ba41c4dc891e38c92126bfcc4c366d765841da0 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 26 Dec 2007 15:12:26 +0200 Subject: ubi-utils: add ubiattach and ubidetach Add 2 new utilities to attach and detach UBI devices. Signed-off-by: Artem Bityutskiy --- ubi-utils/inc/libubi.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'ubi-utils/inc') diff --git a/ubi-utils/inc/libubi.h b/ubi-utils/inc/libubi.h index b83f6c6..0cdb67c 100644 --- a/ubi-utils/inc/libubi.h +++ b/ubi-utils/inc/libubi.h @@ -38,6 +38,22 @@ extern "C" { /* UBI library descriptor */ typedef void * libubi_t; +/** + * struct ubi_attach_request - MTD device attachement request. + * @dev_num: number to assigne to the newly created UBI device + * (%UBI_DEV_NUM_AUTO should be used to automatically assign the + * number) + * @mtd_num: MTD device number to attach + * @vid_hdr_offset: VID header offset (%0 means default offset and this is what + * most of the users want) + */ +struct ubi_attach_request +{ + int dev_num; + int mtd_num; + int vid_hdr_offset; +}; + /** * struct ubi_mkvol_request - volume creation request. * @vol_id: ID to assign to the new volume (%UBI_VOL_NUM_AUTO should be used to @@ -167,14 +183,50 @@ void libubi_close(libubi_t desc); /** * ubi_get_info - get general UBI information. - * @info: pointer to the &struct ubi_info object to fill * @desc: UBI library descriptor + * @info: pointer to the &struct ubi_info object to fill * * This function fills the passed @info object with general UBI information and * returns %0 in case of success and %-1 in case of failure. */ int ubi_get_info(libubi_t desc, struct ubi_info *info); +/** + * ubi_attach_mtd - attach MTD device to UBI. + * @desc: UBI library descriptor + * @node: name of the UBI control character device node + * @req: MTD attach request. + * + * This function creates a new UBI device by attaching an MTD device as + * described by @req. Returns %0 in case of success and %-1 in case of failure. + * The newly created UBI device number is returned in @req->dev_num. + */ +int ubi_attach_mtd(libubi_t desc, const char *node, + struct ubi_attach_request *req); + +/** + * ubi_detach_mtd - detach an MTD device. + * @desc: UBI library descriptor + * @node: name of the UBI control character device node + * @mtd_num: MTD device number to detach + * + * This function detaches MTD device number @mtd_num from UBI, which means the + * corresponding UBI device is removed. Returns zero in case of success and %-1 + * in case of failure. + */ +int ubi_detach_mtd(libubi_t desc, const char *node, int mtd_num); + +/** + * ubi_remove_dev - remove an UBI device. + * @desc: UBI library descriptor + * @node: name of the UBI control character device node + * @ubi_dev: UBI device number to remove + * + * This function removes UBI device number @ubi_dev and returns zero in case of + * success and %-1 in case of failure. + */ +int ubi_remove_dev(libubi_t desc, const char *node, int ubi_dev); + /** * ubi_mkvol - create an UBI volume. * @desc: UBI library descriptor -- cgit v1.2.3