From 852fe0131d1647bb89cf6d894348091d8a8c68be Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Wed, 6 Dec 2017 09:17:08 -0600 Subject: [PATCH] libhandle: add missing destructor Make it so that we can tear down the file descriptor hash table. Signed-off-by: Darrick J. Wong Reviewed-by: Eric Sandeen Signed-off-by: Eric Sandeen --- include/handle.h | 2 ++ libhandle/handle.c | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/handle.h b/include/handle.h index ee69a11da..49f14410c 100644 --- a/include/handle.h +++ b/include/handle.h @@ -50,6 +50,8 @@ extern int parentpaths_by_handle(void *__hanp, size_t __hlen, extern int fssetdm_by_handle (void *__hanp, size_t __hlen, struct fsdmidata *__fsdmi); +void fshandle_destroy(void); + #ifdef __cplusplus } #endif diff --git a/libhandle/handle.c b/libhandle/handle.c index 00127b3c3..e6971dd30 100644 --- a/libhandle/handle.c +++ b/libhandle/handle.c @@ -62,6 +62,19 @@ struct fdhash { static struct fdhash *fdhash_head = NULL; +void +fshandle_destroy(void) +{ + struct fdhash *nexth; + struct fdhash *h = fdhash_head; + + while (h) { + nexth = h->fnxt; + free(h); + h = nexth; + } +} + int path_to_fshandle( char *path, /* input, path to convert */ -- 2.47.2