fs: remove old attempt

tags/0.1.0
S.J.R. van Schaik 7 years ago
parent 57f72ea5f5
commit e88435b3a6
  1. 3
      include/fs/block.h
  2. 3
      include/fs/part.h
  3. 28
      source/fs/block.c
  4. 40
      source/fs/part.c

@ -1,3 +0,0 @@
#pragma once
int block_is_erased(struct flash_dev *dev, uint32_t addr, uint32_t len);

@ -1,3 +0,0 @@
#pragma once
int part_create(struct flash_dev *dev);

@ -1,28 +0,0 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <flash.h>
#include <macros.h>
#include <fs/block.h>
int block_is_erased(struct flash_dev *dev, uint32_t addr, uint32_t len)
{
char buf[32], cmp[32];
size_t count;
memset(cmp, 0xff, sizeof cmp);
for (; len; addr += count, len -= count) {
count = min(len, sizeof buf);
if (flash_read(dev, addr, buf, count) < 0)
return -1;
if (memcmp(buf, cmp, count) != 0)
return -1;
}
return 0;
}

@ -1,40 +0,0 @@
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <flash.h>
#include <macros.h>
#include <fs/block.h>
#include <fs/part.h>
struct part_hdr {
char magic[8];
char rsv[24];
} __attribute__((packed));
struct part_entry {
char label[16];
uint32_t start, end;
uint32_t flags;
uint32_t rsv;
} __attribute__((packed));
#define PART_MAGIC "FL-PART\x7f"
int part_create(struct flash_dev *dev)
{
struct part_hdr hdr;
if (block_is_erased(dev, 0, 4 * KIB) != 0 &&
flash_erase(dev, 0, 4 * KIB) != 0)
return -1;
memset(&hdr, 0, sizeof hdr);
memcpy(hdr.magic, PART_MAGIC, sizeof hdr.magic);
if (flash_write(dev, 0, &hdr, sizeof hdr) != 0)
return -1;
return 0;
}
Loading…
Cancel
Save