mtd: Import libmtd with modifications to make it compile