diff options
author | Sven Eisenberg <sven.eisenberg@novero.com> | 2016-04-03 21:53:12 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-04-03 22:01:43 +0200 |
commit | b068cf2a7e036da8d0b3533b41886c5605c8139d (patch) | |
tree | 0c29bccfabd054c5cafc5dd68e9d161d70bf1286 /miscutils/ubi_tools.c | |
parent | cb9264099822505dc2930cfea0b1f9027a02dc06 (diff) | |
download | busybox-w32-b068cf2a7e036da8d0b3533b41886c5605c8139d.tar.gz busybox-w32-b068cf2a7e036da8d0b3533b41886c5605c8139d.tar.bz2 busybox-w32-b068cf2a7e036da8d0b3533b41886c5605c8139d.zip |
ubirmvol: Implement -N switch for ubirmvol
function old new delta
get_volid_by_name - 125 +125
ubi_devnum_from_devname - 43 +43
ubi_tools_main 1215 1220 +5
packed_usage 30674 30655 -19
ubirename_main 394 221 -173
------------------------------------------------------------------------------
(add/remove: 3/0 grow/shrink: 1/2 up/down: 173/-192) Total: -19 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils/ubi_tools.c')
-rw-r--r-- | miscutils/ubi_tools.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/miscutils/ubi_tools.c b/miscutils/ubi_tools.c index dd1bda300..ac0c56d6b 100644 --- a/miscutils/ubi_tools.c +++ b/miscutils/ubi_tools.c | |||
@@ -195,7 +195,7 @@ int ubi_tools_main(int argc UNUSED_PARAM, char **argv) | |||
195 | } else | 195 | } else |
196 | 196 | ||
197 | //usage:#define ubimkvol_trivial_usage | 197 | //usage:#define ubimkvol_trivial_usage |
198 | //usage: "UBI_DEVICE -N NAME [-s SIZE | -m]" | 198 | //usage: "-N NAME [-s SIZE | -m] UBI_DEVICE" |
199 | //usage:#define ubimkvol_full_usage "\n\n" | 199 | //usage:#define ubimkvol_full_usage "\n\n" |
200 | //usage: "Create UBI volume\n" | 200 | //usage: "Create UBI volume\n" |
201 | //usage: "\n -a ALIGNMENT Volume alignment (default 1)" | 201 | //usage: "\n -a ALIGNMENT Volume alignment (default 1)" |
@@ -212,9 +212,7 @@ int ubi_tools_main(int argc UNUSED_PARAM, char **argv) | |||
212 | unsigned num; | 212 | unsigned num; |
213 | char *p; | 213 | char *p; |
214 | 214 | ||
215 | if (sscanf(ubi_ctrl, "/dev/ubi%u", &num) != 1) | 215 | num = ubi_devnum_from_devname(ubi_ctrl); |
216 | bb_error_msg_and_die("wrong format of UBI device name"); | ||
217 | |||
218 | p = path_sys_class_ubi_ubi + sprintf(path_sys_class_ubi_ubi, "%u/", num); | 216 | p = path_sys_class_ubi_ubi + sprintf(path_sys_class_ubi_ubi, "%u/", num); |
219 | 217 | ||
220 | strcpy(p, "avail_eraseblocks"); | 218 | strcpy(p, "avail_eraseblocks"); |
@@ -248,20 +246,31 @@ int ubi_tools_main(int argc UNUSED_PARAM, char **argv) | |||
248 | } else | 246 | } else |
249 | 247 | ||
250 | //usage:#define ubirmvol_trivial_usage | 248 | //usage:#define ubirmvol_trivial_usage |
251 | //usage: "UBI_DEVICE -n VOLID" | 249 | //usage: "-n VOLID / -N VOLNAME UBI_DEVICE" |
252 | //usage:#define ubirmvol_full_usage "\n\n" | 250 | //usage:#define ubirmvol_full_usage "\n\n" |
253 | //usage: "Remove UBI volume\n" | 251 | //usage: "Remove UBI volume\n" |
254 | //usage: "\n -n VOLID Volume ID" | 252 | //usage: "\n -n VOLID Volume ID" |
253 | //usage: "\n -N VOLNAME Volume name" | ||
255 | if (do_rmvol) { | 254 | if (do_rmvol) { |
256 | if (!(opts & OPTION_n)) | 255 | if (!(opts & (OPTION_n|OPTION_N))) |
257 | bb_error_msg_and_die("volume id not specified"); | 256 | bb_error_msg_and_die("volume id not specified"); |
258 | 257 | ||
259 | /* FIXME? kernel expects int32_t* here: */ | 258 | if (opts & OPTION_N) { |
260 | xioctl(fd, UBI_IOCRMVOL, &vol_id); | 259 | unsigned num = ubi_devnum_from_devname(ubi_ctrl); |
260 | vol_id = get_volid_by_name(num, vol_name); | ||
261 | } | ||
262 | |||
263 | if (sizeof(vol_id) != 4) { | ||
264 | /* kernel expects int32_t* in this ioctl */ | ||
265 | int32_t t = vol_id; | ||
266 | xioctl(fd, UBI_IOCRMVOL, &t); | ||
267 | } else { | ||
268 | xioctl(fd, UBI_IOCRMVOL, &vol_id); | ||
269 | } | ||
261 | } else | 270 | } else |
262 | 271 | ||
263 | //usage:#define ubirsvol_trivial_usage | 272 | //usage:#define ubirsvol_trivial_usage |
264 | //usage: "UBI_DEVICE -n VOLID -s SIZE" | 273 | //usage: "-n VOLID -s SIZE UBI_DEVICE" |
265 | //usage:#define ubirsvol_full_usage "\n\n" | 274 | //usage:#define ubirsvol_full_usage "\n\n" |
266 | //usage: "Resize UBI volume\n" | 275 | //usage: "Resize UBI volume\n" |
267 | //usage: "\n -n VOLID Volume ID" | 276 | //usage: "\n -n VOLID Volume ID" |
@@ -279,7 +288,7 @@ int ubi_tools_main(int argc UNUSED_PARAM, char **argv) | |||
279 | } else | 288 | } else |
280 | 289 | ||
281 | //usage:#define ubiupdatevol_trivial_usage | 290 | //usage:#define ubiupdatevol_trivial_usage |
282 | //usage: "UBI_DEVICE [-t | [-s SIZE] IMG_FILE]" | 291 | //usage: "[-t | [-s SIZE] IMG_FILE] UBI_DEVICE" |
283 | //usage:#define ubiupdatevol_full_usage "\n\n" | 292 | //usage:#define ubiupdatevol_full_usage "\n\n" |
284 | //usage: "Update UBI volume\n" | 293 | //usage: "Update UBI volume\n" |
285 | //usage: "\n -t Truncate to zero size" | 294 | //usage: "\n -t Truncate to zero size" |