From 540f80dbe8f71649767b675b810f53e65053018b Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Tue, 6 Oct 2020 09:40:59 +0200 Subject: [PATCH] main: record how many objects are in memory Signed-off-by: Giuseppe Scrivano --- main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/main.c b/main.c index 37abd8a..a1b264d 100644 --- a/main.c +++ b/main.c @@ -168,6 +168,14 @@ static gid_t overflow_gid; static struct ovl_ino dummy_ino; +struct stats_s +{ + size_t nodes; + size_t inodes; +}; + +static struct stats_s stats; + static double get_timeout (struct ovl_data *lo) { @@ -905,6 +913,7 @@ node_free (void *p) if (n->do_rmdir) unlinkat (n->hidden_dirfd, n->path, AT_REMOVEDIR); + stats.nodes--; free (n->name); free (n->path); free (n); @@ -926,6 +935,7 @@ inode_free (void *p) node_free (tmp); } + stats.inodes--; free (i); } @@ -1143,6 +1153,7 @@ register_inode (struct ovl_data *lo, struct ovl_node *n, mode_t mode) return NULL; } + stats.inodes++; return ino->node; } @@ -1248,6 +1259,7 @@ make_whiteout_node (const char *path, const char *name) ret_xchg = ret; ret = NULL; + stats.nodes++; return ret_xchg; } @@ -1460,6 +1472,7 @@ no_fd: ret_xchg = ret; ret = NULL; + stats.nodes++; return register_inode (lo, ret_xchg, mode); }