repofs kinda working

This commit is contained in:
2023-06-08 23:54:49 +02:00
parent f7a5c4af48
commit a70ca528e0
4 changed files with 21 additions and 10 deletions

View File

@@ -3,13 +3,13 @@ cmake_minimum_required(VERSION 3.22)
#add_compile_options(-Ofast)
#add_link_options(-Ofast)
# add_compile_options(-Ofast -flto)
# add_link_options(-Ofast -flto)
add_compile_options(-Ofast -flto)
add_link_options(-Ofast -flto)
add_compile_options(-Wall -O0 -Wextra -pedantic -Wshadow -Wformat=2 -Wfloat-equal -D_GLIBCXX_DEBUG -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -g -rdynamic)
add_compile_options(-fsanitize=address -fsanitize=undefined -fno-sanitize-recover)
add_link_options(-fsanitize=address -fsanitize=undefined -fno-sanitize-recover)
add_link_options(-rdynamic)
#add_compile_options(-Wall -O0 -Wextra -pedantic -Wshadow -Wformat=2 -Wfloat-equal -D_GLIBCXX_DEBUG -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -g -rdynamic)
#add_compile_options(-fsanitize=address -fsanitize=undefined -fno-sanitize-recover)
#add_link_options(-fsanitize=address -fsanitize=undefined -fno-sanitize-recover)
#add_link_options(-rdynamic)
project(backup)

View File

@@ -9,5 +9,5 @@ CommandMount::CommandMount() : Command("mount") {
}
void CommandMount::run(Context ctx) {
RepoFS::start(ctx.repo, "./hi");
RepoFS::start(ctx.repo, ctx.repo->getConfig().getStr("to"));
}

View File

@@ -38,7 +38,7 @@ static int rfsGetattr(const char *path, struct stat *stbuf) {
e = getf(path);
if (e->isFakeDir || e->file->fileType == File::Type::Directory) {
stbuf->st_mode = S_IFDIR | 0755;
stbuf->st_nlink = 1;
stbuf->st_nlink = 2;
} else if (e->file->fileType == File::Type::Normal) {
stbuf->st_mode = S_IFREG | 0444;
stbuf->st_nlink = 1;
@@ -137,9 +137,9 @@ void RepoFS::start(Repository *repo, std::string path) {
for (auto const &f: a.files) {
auto file = Serialize::deserialize<File>(repo->getObject(f));
auto path = std::filesystem::u8path(file.name);
DirEntry *entry = &(root.children[r.first]);
DirEntry *entry = &(root.children[std::to_string(a.id)]);
entry->isFakeDir = true;
entry->name = a.name;
entry->name = std::to_string(a.id);
for (auto const &subp: path) {
entry = &entry->children[subp];
}

View File

@@ -120,6 +120,9 @@ AIDS=()
OUT=$($CMD list --repo testdir/to1 --password asdff)
echo "$OUT"
mkdir testmount
$CMD mount --repo testdir/to1 --password asdff --to testmount &
while IFS= read -r l; do
((i++))
aid=$(echo $l | grep -Eo '[0-9]+' | tail -1)
@@ -129,9 +132,16 @@ while IFS= read -r l; do
echo "Archive not restored properly!"
exit 1
fi
if ! diff --no-dereference -r testmount/$((aid)) testdir/res$((i)); then
echo "Archive not mounted properly!"
exit 1
fi
echo "Restore $((i)) OK"
done <<< "$OUT"
umount testmount
OUT=$($CMD diff --from testdata/4 --repo testdir/to1 --password asdff --progress none --verbose 1 --aid ${AIDS[0]} --aid2 ${AIDS[1]})
echo "$OUT"
if ! ( ( echo "$OUT" | grep -q 'c is different' ) && ! ( echo "$OUT" | grep -q 'a is different' ) && ! ( echo "$OUT" | grep -q 'l is different' )\
@@ -290,5 +300,6 @@ echo "Backup 11 ok"
rm -rf testdata
rm -rf testdir
rm -rf testmount
exit 0