1 /* guestfish - the filesystem interactive shell
2 * Copyright (C) 2009 Red Hat Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
29 run_reopen (const char *cmd, size_t argc, char *argv[])
34 guestfs_error_handler_cb cb;
38 fprintf (stderr, _("'reopen' command takes no parameters\n"));
42 /* Open the new handle first, so we can copy the settings from the
43 * old one to the new one, and also so if it fails we still have an
46 g2 = guestfs_create ();
48 fprintf (stderr, _("reopen: guestfs_create: failed to create handle\n"));
52 /* Now copy some of the settings from the old handle. The settings
53 * we copy are those which are set by guestfish itself.
55 cb = guestfs_get_error_handler (g, &cb_data);
56 guestfs_set_error_handler (g2, cb, cb_data);
58 r = guestfs_get_verbose (g);
60 guestfs_set_verbose (g2, r);
62 r = guestfs_get_trace (g);
64 guestfs_set_trace (g2, r);
66 r = guestfs_get_autosync (g);
68 guestfs_set_autosync (g2, r);
70 p = guestfs_get_path (g);
72 guestfs_set_path (g2, p);
74 r = guestfs_get_pgroup (g);
76 guestfs_set_pgroup (g2, r);
79 guestfs_set_event_callback (g2, progress_callback,
80 GUESTFS_EVENT_PROGRESS, 0, NULL);
82 /* Close the original handle. */
86 /* We don't bother copying event handlers over to the new handle,
87 * but we have to reset the list because they were registered
88 * against the old handle.
90 free_event_handlers ();
91 init_event_handlers ();