diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-11-09 18:47:57 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-11-09 19:51:08 +0000 |
commit | b460d9f32eb527bc7aad4894a5f85c4e69366104 (patch) | |
tree | aeacce4c04338d8327f2df1a7154e2e4677eb71d /src/inspect-fs.c | |
parent | a3b6751863b4e7e620dd1b75b4a8d8187d2069a5 (diff) | |
download | libguestfs-b460d9f32eb527bc7aad4894a5f85c4e69366104.tar.gz libguestfs-b460d9f32eb527bc7aad4894a5f85c4e69366104.tar.xz libguestfs-b460d9f32eb527bc7aad4894a5f85c4e69366104.zip |
lib: Modify library code to use guestfs_{push,pop}_error_handler.
This is less efficient than directly manipulating g->error_cb, but
easier to maintain.
Diffstat (limited to 'src/inspect-fs.c')
-rw-r--r-- | src/inspect-fs.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/inspect-fs.c b/src/inspect-fs.c index 2dbafb5d..ffcd0d68 100644 --- a/src/inspect-fs.c +++ b/src/inspect-fs.c @@ -91,14 +91,15 @@ int guestfs___check_for_filesystem_on (guestfs_h *g, const char *device, int is_block, int is_partnum) { + char *vfs_type; + /* Get vfs-type in order to check if it's a Linux(?) swap device. * If there's an error we should ignore it, so to do that we have to * temporarily replace the error handler with a null one. */ - guestfs_error_handler_cb old_error_cb = g->error_cb; - g->error_cb = NULL; - char *vfs_type = guestfs_vfs_type (g, device); - g->error_cb = old_error_cb; + guestfs_push_error_handler (g, NULL, NULL); + vfs_type = guestfs_vfs_type (g, device); + guestfs_pop_error_handler (g); int is_swap = vfs_type && STREQ (vfs_type, "swap"); @@ -115,8 +116,8 @@ guestfs___check_for_filesystem_on (guestfs_h *g, const char *device, } /* Try mounting the device. As above, ignore errors. */ - g->error_cb = NULL; int r; + guestfs_push_error_handler (g, NULL, NULL); if (vfs_type && STREQ (vfs_type, "ufs")) { /* Hack for the *BSDs. */ /* FreeBSD fs is a variant of ufs called ufs2 ... */ r = guestfs_mount_vfs (g, "ro,ufstype=ufs2", "ufs", device, "/"); @@ -127,7 +128,7 @@ guestfs___check_for_filesystem_on (guestfs_h *g, const char *device, r = guestfs_mount_ro (g, device, "/"); } free (vfs_type); - g->error_cb = old_error_cb; + guestfs_pop_error_handler (g); if (r == -1) return 0; |