diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-12-18 15:55:03 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-12-18 15:55:03 +0100 |
commit | 2777dfe050359c359233b2f00dfb5c3b2dba4ed6 (patch) | |
tree | e120ef9c10295c74dc8c3ec6dfa39aaa665e7f6b /lib/fstree/gen_inode_numbers.c | |
parent | caf350448c0020f95b9bfdd65770d86faf548549 (diff) |
Cleanup: merge the fstree post processing functions
Instead of having 3 different functions for sorting the tree, numbering
the nodes and generating a file list, that all have to be used in the
right order, this commit merges them into a single "fstree_post_process"
function.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/fstree/gen_inode_numbers.c')
-rw-r--r-- | lib/fstree/gen_inode_numbers.c | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/lib/fstree/gen_inode_numbers.c b/lib/fstree/gen_inode_numbers.c deleted file mode 100644 index 35dbc7a..0000000 --- a/lib/fstree/gen_inode_numbers.c +++ /dev/null @@ -1,49 +0,0 @@ -/* SPDX-License-Identifier: GPL-3.0-or-later */ -/* - * gen_inode_numbers.c - * - * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> - */ -#include "config.h" - -#include "fstree.h" - -#include <stdlib.h> -#include <stdio.h> - -static void map_child_nodes(fstree_t *fs, tree_node_t *root, size_t *counter) -{ - bool has_subdirs = false; - tree_node_t *it; - - for (it = root->data.dir.children; it != NULL; it = it->next) { - if (S_ISDIR(it->mode)) { - has_subdirs = true; - break; - } - } - - if (has_subdirs) { - for (it = root->data.dir.children; it != NULL; it = it->next) { - if (S_ISDIR(it->mode)) - map_child_nodes(fs, it, counter); - } - } - - for (it = root->data.dir.children; it != NULL; it = it->next) { - fs->unique_inode_count += 1; - - it->inode_num = *counter; - *counter += 1; - } -} - -void fstree_gen_inode_numbers(fstree_t *fs) -{ - size_t inum = 1; - - fs->unique_inode_count = 0; - map_child_nodes(fs, fs->root, &inum); - fs->root->inode_num = inum; - fs->unique_inode_count += 1; -} |