When using jffs2 on NAND flash, it stores its magic in the OOB data on
newly erased blocks. This change fixes identifying the filesystem type.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
{
struct mtd_volume *p = container_of(v, struct mtd_volume, v);;
__u32 deadc0de;
{
struct mtd_volume *p = container_of(v, struct mtd_volume, v);;
__u32 deadc0de;
size_t sz;
if (mtd_volume_load(p)) {
size_t sz;
if (mtd_volume_load(p)) {
+ if (deadc0de == ~0) {
+ struct mtd_oob_buf oob = {
+ .start = 0,
+ .length = sizeof(deadc0de),
+ .ptr = (void *)&deadc0de,
+ };
+
+ ioctl(p->fd, MEMREADOOB, &oob);
+ }
+
if (deadc0de == __be32_to_cpu(0x4f575254))
return FS_SNAPSHOT;
if (deadc0de == __be32_to_cpu(0x4f575254))
return FS_SNAPSHOT;
- jffs2 = __be16_to_cpu(deadc0de >> 16);
- if (jffs2 == 0x1985) {
+ if (__be16_to_cpu(deadc0de) == 0x1985 ||
+ __be16_to_cpu(deadc0de >> 16) == 0x1985)
if (v->type == UBIVOLUME && deadc0de == 0xffffffff) {
return FS_JFFS2;
if (v->type == UBIVOLUME && deadc0de == 0xffffffff) {
return FS_JFFS2;