|
|
@ -13,7 +13,8 @@ |
|
|
|
#include "path.h" |
|
|
|
#include "path.h" |
|
|
|
#include "tree.h" |
|
|
|
#include "tree.h" |
|
|
|
|
|
|
|
|
|
|
|
int mufs_mkpath(struct mufs *fs, const char *path, unsigned type) |
|
|
|
int mufs_mkpath(struct mufs *fs, const char *path, struct mufs_tree *subtree, |
|
|
|
|
|
|
|
unsigned type) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct mufs_stat stat; |
|
|
|
struct mufs_stat stat; |
|
|
|
struct mufs_dirent dirent; |
|
|
|
struct mufs_dirent dirent; |
|
|
@ -43,15 +44,20 @@ int mufs_mkpath(struct mufs *fs, const char *path, unsigned type) |
|
|
|
if (!(tree = resolve_path(fs, s, &stat)) || stat.type != MUFS_DIR) |
|
|
|
if (!(tree = resolve_path(fs, s, &stat)) || stat.type != MUFS_DIR) |
|
|
|
return -1; |
|
|
|
return -1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
memset(&dirent, 0, sizeof dirent); |
|
|
|
|
|
|
|
|
|
|
|
len = min(strlen(name), sizeof(dirent.path) - 1); |
|
|
|
len = min(strlen(name), sizeof(dirent.path) - 1); |
|
|
|
memcpy(dirent.path, name, len); |
|
|
|
memcpy(dirent.path, name, len); |
|
|
|
dirent.path[len] = '\0'; |
|
|
|
dirent.path[len] = '\0'; |
|
|
|
dirent.type = type; |
|
|
|
dirent.type = type; |
|
|
|
|
|
|
|
|
|
|
|
dirent.tree.fs = fs; |
|
|
|
dirent.tree.fs = fs; |
|
|
|
dirent.tree.file_size = 0; |
|
|
|
|
|
|
|
dirent.tree.root = 0; |
|
|
|
if (subtree) { |
|
|
|
dirent.tree.depth = 0; |
|
|
|
dirent.tree.file_size = subtree->file_size; |
|
|
|
|
|
|
|
dirent.tree.root = subtree->root; |
|
|
|
|
|
|
|
dirent.tree.depth = subtree->depth; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
tree->file_size = find_dirent_size(fs, tree, tree->file_size); |
|
|
|
tree->file_size = find_dirent_size(fs, tree, tree->file_size); |
|
|
|
|
|
|
|
|
|
|
|