mufs: mufs_mount() read the tree pointer of the root directory
This commit is contained in:
parent
0c284d1ba7
commit
c5c24788c8
3 changed files with 10 additions and 7 deletions
|
@ -2,10 +2,15 @@
|
||||||
|
|
||||||
struct flash_dev;
|
struct flash_dev;
|
||||||
|
|
||||||
|
struct mufs_tree {
|
||||||
|
uint32_t root;
|
||||||
|
uint8_t depth;
|
||||||
|
};
|
||||||
|
|
||||||
struct mufs {
|
struct mufs {
|
||||||
struct flash_dev *dev;
|
struct flash_dev *dev;
|
||||||
uint32_t nblocks;
|
uint32_t nblocks;
|
||||||
uint32_t root;
|
struct mufs_tree root;
|
||||||
};
|
};
|
||||||
|
|
||||||
int mufs_mount(struct mufs *fs, struct flash_dev *dev);
|
int mufs_mount(struct mufs *fs, struct flash_dev *dev);
|
||||||
|
|
|
@ -10,6 +10,7 @@ struct mufs_super {
|
||||||
char magic[4];
|
char magic[4];
|
||||||
uint32_t nblocks;
|
uint32_t nblocks;
|
||||||
uint32_t root;
|
uint32_t root;
|
||||||
|
uint8_t depth;
|
||||||
} __attribute__((packed));
|
} __attribute__((packed));
|
||||||
|
|
||||||
int mufs_mount(struct mufs *fs, struct flash_dev *dev)
|
int mufs_mount(struct mufs *fs, struct flash_dev *dev)
|
||||||
|
@ -27,7 +28,8 @@ int mufs_mount(struct mufs *fs, struct flash_dev *dev)
|
||||||
|
|
||||||
fs->dev = dev;
|
fs->dev = dev;
|
||||||
fs->nblocks = super.nblocks;
|
fs->nblocks = super.nblocks;
|
||||||
fs->root = super.root;
|
fs->root.root = super.root;
|
||||||
|
fs->root.depth = super.depth;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -39,6 +41,7 @@ int mufs_format(struct flash_dev *dev)
|
||||||
memcpy(super.magic, "mufs", 4);
|
memcpy(super.magic, "mufs", 4);
|
||||||
super.nblocks = flash_get_capacity(dev) >> dev->log2_block_size;
|
super.nblocks = flash_get_capacity(dev) >> dev->log2_block_size;
|
||||||
super.root = 0;
|
super.root = 0;
|
||||||
|
super.depth = 0;
|
||||||
|
|
||||||
if (flash_write(dev, 0, &super, sizeof super) == 0)
|
if (flash_write(dev, 0, &super, sizeof super) == 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
struct mufs_tree {
|
|
||||||
uint32_t root;
|
|
||||||
uint8_t depth;
|
|
||||||
};
|
|
||||||
|
|
||||||
int mufs_lookup_page(struct mufs *fs, struct mufs_tree *tree, uint32_t *page,
|
int mufs_lookup_page(struct mufs *fs, struct mufs_tree *tree, uint32_t *page,
|
||||||
uint32_t va);
|
uint32_t va);
|
||||||
int mufs_alloc_page(struct mufs *fs, struct mufs_tree *tree, uint32_t *page,
|
int mufs_alloc_page(struct mufs *fs, struct mufs_tree *tree, uint32_t *page,
|
||||||
|
|
Loading…
Add table
Reference in a new issue