From 9eb21ca54a947fa56255a178ce00640c1f6acb30 Mon Sep 17 00:00:00 2001 From: Matteo Cafasso Date: Mon, 19 Sep 2016 19:42:51 +0300 Subject: [PATCH] New API: find_inode Library's counterpart of the daemon's internal_find_inode command. It writes the daemon's command output on a temporary file and parses it, deserialising the XDR formatted tsk_dirent structs. It returns to the caller the list of tsk_dirent structs generated by the internal_find_inode command. Signed-off-by: Matteo Cafasso --- generator/actions.ml | 12 ++++++++++++ src/tsk.c | 17 +++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/generator/actions.ml b/generator/actions.ml index 4e6627bd2..91a181973 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -3717,6 +3717,18 @@ Unknown file type =back" }; + { defaults with + name = "find_inode"; added = (1, 35, 6); + style = RStructList ("dirents", "tsk_dirent"), [Mountable "device"; Int64 "inode";], []; + optional = Some "libtsk"; + progress = true; cancellable = true; + shortdesc = "search the entries associated to the given inode"; + longdesc = "\ +Searches all the entries associated with the given inode. + +For each entry, a C structure is returned. +See C for more information about C structures." }; + ] (* daemon_functions are any functions which cause some action diff --git a/src/tsk.c b/src/tsk.c index ecafcb782..1def9c91d 100644 --- a/src/tsk.c +++ b/src/tsk.c @@ -55,6 +55,23 @@ guestfs_impl_filesystem_walk (guestfs_h *g, const char *mountable) return parse_dirent_file (g, tmpfile); /* caller frees */ } +struct guestfs_tsk_dirent_list * +guestfs_impl_find_inode (guestfs_h *g, const char *mountable, int64_t inode) +{ + int ret = 0; + CLEANUP_UNLINK_FREE char *tmpfile = NULL; + + tmpfile = make_temp_file (g, "find_inode"); + if (tmpfile == NULL) + return NULL; + + ret = guestfs_internal_find_inode (g, mountable, inode, tmpfile); + if (ret < 0) + return NULL; + + return parse_dirent_file (g, tmpfile); /* caller frees */ +} + /* Parse the file content and return dirents list. * Return a list of tsk_dirent on success, NULL on error. */