ubi_attach_mtd_dev(9)
β¨ ubi_attach_mtd_dev(9) β¨
okay so bestie, welcome to the kernel API manual page for ubi_attach_mtd_dev β yes that's a 9 in the parens, it's a kernel function, we're in the big leagues now π
π NAME π
ubi_attach_mtd_dev β attach an MTD device. literally what it says on the tin π«Ά
πΈ SYNOPSIS πΈ
int ubi_attach_mtd_dev (struct mtd_info *mtd , int ubi_num , int
vid_hdr_offset , int max_beb_per1024 , bool disable_fm , bool
need_resv_pool , int wl_threshold );
π ARGUMENTS π
so here's the whole cast of characters, no cap:
mtdβ the MTD device description object. this is the actual device bestie, the whole point of the operation π¦ubi_numβ the number you wanna assign to the brand new UBI device β¨vid_hdr_offsetβ the VID header offset. that's it, that's the vibe πmax_beb_per1024β the maximum expected number of bad PEB per 1024 PEBs. yeah, bad blocks happen, we plan for them πdisable_fmβ whether to disable fastmap. a lil boolean, lowkey important π₯need_resv_poolβ whether to reserve pebs to fillfm_poolπΈwl_thresholdβ the wear-leveling threshold for this UBI device;0means useCONFIG_MTD_UBI_WL_THRESHOLD; accepted range is 2-65536. numbers, bestie, we love a range π
π DESCRIPTION π
This function attaches MTD device mtd_dev to UBI and assigns ubi_num as the number of the newly created UBI device β unless ubi_num is UBI_DEV_NUM_AUTO, in which case this function goes looking for a vacant device number and assigns it automatically, main character energy fr fr β
It returns the new UBI device number in case of success, and a negative error code in case of failure. slay when it works, π when it doesn't.
If disable_fm is true, ubi doesn't create new fastmap β even the module param doing full scanning. not me pointing that out twice, it's literally in there π
β οΈ Note, the invocations of this function has to be serialized by the ubi_devices_mutex. do not skip this, bestie, that's a race condition waiting to happen π«Ά
π SEE ALSO π
- Kernel file
./drivers/mtd/ubi/build.cstruct mtd_dev_param(9) ubi_volume_notify(9)ubi_notify_all(9)ubi_enumerate_volumes(9)ubi_get_device(9)ubi_put_device(9)ubi_get_by_major(9)ubi_major2num(9)kill_volumes(9)uif_init(9)uif_close(9)ubi_free_volumes_from(9)ubi_free_all_volumes(9)ubi_free_internal_volumes(9)io_init(9)autoresize(9)ubi_detach_mtd_dev(9)open_mtd_by_chdev(9)open_mtd_device(9)bytes_str_to_int(9)ubi_mtd_param_parse(9)
like, go read them, they're all iconic in their own way π
and that's the page, bestie π§ this little love letter lives in ./drivers/mtd/ubi, dated October 2026, and it's brought to you by ubi_attach_mtd_dev(9) β periodt π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms