Bug 13061

Summary: ubiattach -O option for VID header offset does not work
Product: Busybox Reporter: Mark Doyle <mark.doyle>
Component: OtherAssignee: unassigned
Status: NEW ---    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: 1.30.x   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

Description Mark Doyle 2020-07-07 13:10:22 UTC
BusyBox v1.30.1 (2020-07-05 19:34:29 EDT) multi-call binary.

Example of bug:

/ # ubiattach -m 11 -d 0 -O 4096 /dev/ubi_ctrl

ubiattach: invalid option -- 'O'


Description:
ubiattach advertises an O option to set the VID header offset, but fails to recognize the option. 

Possible Bug Fix:
I need this for my embedded system so on my copy of busybox, I changed miscutils/ubi_tools line 158 from

	opts = getopt32(argv, "^" "m:+d:+n:+N:s:a:+t:" "\0" "-1",

to
opts = getopt32(argv, "^" "m:+d:+n:+N:s:a:+t:O:+" "\0" "-1",

That is, I added the O:+ to the end of the format string in getopt32.

After the above fix I successfully attached:
/ # ubiattach -m 11 -O 4096 /dev/ubi_ctrl
[   58.465623] ubi0: attaching mtd11
[   59.327799] ubi0: scanning is finished
[   59.378294] ubi0: attached mtd11 (name "NAND.es-file-system", size 398 MiB)
[   59.385354] ubi0: PEB size: 262144 bytes (256 KiB), LEB size: 253952 bytes
[   59.397168] ubi0: min./max. I/O unit sizes: 4096/4096, sub-page size 1024
[   59.404389] ubi0: VID header offset: 4096 (aligned 4096), data offset: 8192