How to detect if ubi volume is empty
Zhihao Cheng
chengzhihao1 at huawei.com
Tue May 21 04:08:29 PDT 2024
在 2024/5/20 18:22, Pintu Agarwal 写道:
> Hi,
>
> In Linux Kernel 5.15 is there a way to detect in runtime, if UBI
> volume (squashfs based, ubiblock, dynamic) is empty or not ?
There is a way to get the empty state of UBI volume by ioctl
UBI_IOCEBUNMAP, for example:
fd = open(UBI_VOLUME, O_EXCL)
check_volume_empty [1]
close(fd)
[1]
https://www.linux-mtd.infradead.org/?p=mtd-utils.git;a=blob;f=ubifs-utils/mkfs.ubifs/mkfs.ubifs.c;h=42a47f839e115567de58e8cdfcc50c4202fc7af1;hb=refs/heads/master#l2804
> Based on this we need to make some decisions at runtime.
>
> Currently, we are using a crude way to detect volume empty by reading
> the first 1K block using the "dd" command and checking if the contents
> are all FF.
>
> Is this good enough, or is there some other better way ?
>
> Thanks.
> Pintu
>
> .
More information about the linux-mtd
mailing list