Support For Creating / Removing UBI Blocks

Baruch Siach baruch at tkos.co.il
Mon Aug 1 17:31:25 UTC 2016


Hi Metin Kaya,

On Mon, Aug 01, 2016 at 01:54:38PM +0300, Metin Kaya wrote:
> The attached patch supports -c and -r command line arguments like ubiblock
> of mtd-utils.

> @@ -68,6 +77,7 @@
>  
>  #define do_attach (ENABLE_UBIATTACH && applet_name[3] == 'a')
>  #define do_detach (ENABLE_UBIDETACH && applet_name[3] == 'd')
> +#define do_block  (ENABLE_UBIBLOCK  && applet_name[3] == 'b')
>  #define do_mkvol  (ENABLE_UBIMKVOL  && applet_name[3] == 'm')
>  #define do_rmvol  (ENABLE_UBIRMVOL  && applet_name[4] == 'm')
>  #define do_rsvol  (ENABLE_UBIRSVOL  && applet_name[4] == 's')
> @@ -133,9 +143,11 @@
>  #define OPTION_s  (1 << 4)
>  #define OPTION_a  (1 << 5)
>  #define OPTION_t  (1 << 6)
> +#define OPTION_c  (1 << 7)
> +#define OPTION_r  (1 << 8)
>  	if (do_mkvol) {
>  		opt_complementary = "-1:d+:n+:a+:O+";
> -		opts = getopt32(argv, "md:n:N:s:a:t:O:",
> +		opts = getopt32(argv, "md:n:N:s:a:t:O:cr",

This part is not needed.

>  				&dev_num, &vol_id,
>  				&vol_name, &size_bytes_str, &alignment, &type,
>  				&vid_hdr_offset
> @@ -147,7 +159,7 @@
>  		opts *= OPTION_s;
>  	} else {
>  		opt_complementary = "-1:m+:d+:n+:a+";
> -		opts = getopt32(argv, "m:d:n:N:s:a:t:",
> +		opts = getopt32(argv, "m:d:n:N:s:a:t:cr",
>  				&mtd_num, &dev_num, &vol_id,
>  				&vol_name, &size_bytes_str, &alignment, &type
>  		);
> @@ -194,6 +206,19 @@
>  		xioctl(fd, UBI_IOCDET, &dev_num);
>  	} else
>  
> +//usage:#define ubiblock_trivial_usage
> +//usage:       "-c / -r UBI_CTRL_DEV"

Following the usual convention it should be: "-c | -r UBI_CTRL_DEV".

> +//usage:#define ubiblock_full_usage "\n\n"
> +//usage:       "Create or remove an MTD block\n"
> +//usage:     "\n	-c UBI_CTRL_DEV	create an MTD block"
> +//usage:     "\n	-r UBI_CTRL_DEV	remove an MTD block"
> +	if (do_block) {
> +		if (opts & OPTION_c)
> +			xioctl(fd, UBI_IOCVOLCRBLK, NULL);
> +		else if (opts & OPTION_r)
> +			xioctl(fd, UBI_IOCVOLRMBLK, NULL);
> +	} else
> +
>  //usage:#define ubimkvol_trivial_usage
>  //usage:       "-N NAME [-s SIZE | -m] UBI_DEVICE"
>  //usage:#define ubimkvol_full_usage "\n\n"

baruch

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -


More information about the busybox mailing list