1 /* libguestfs - the guestfsd daemon
2 * Copyright (C) 2009-2010 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 #include "optgroups.h"
34 optgroup_ntfs3g_available (void)
36 return prog_exists ("ntfs-3g.probe");
40 optgroup_ntfsprogs_available (void)
42 return prog_exists ("ntfsresize");
46 do_ntfs_3g_probe (int rw, const char *device)
52 rw_flag = rw ? "-w" : "-r";
54 r = commandr (NULL, &err, "ntfs-3g.probe", rw_flag, device, NULL);
56 reply_with_error ("%s: %s", device, err);
65 /* Takes optional arguments, consult optargs_bitmask. */
67 do_ntfsresize_opts (const char *device, int64_t size, int force)
71 const char *argv[MAX_ARGS];
75 ADD_ARG (argv, i, "ntfsresize");
76 ADD_ARG (argv, i, "-P");
78 if (optargs_bitmask & GUESTFS_NTFSRESIZE_OPTS_SIZE_BITMASK) {
80 reply_with_error ("size is zero or negative");
84 snprintf (size_str, sizeof size_str, "%" PRIi64, size);
85 ADD_ARG (argv, i, "--size");
86 ADD_ARG (argv, i, size_str);
89 if (optargs_bitmask & GUESTFS_NTFSRESIZE_OPTS_FORCE_BITMASK && force)
90 ADD_ARG (argv, i, "--force");
92 ADD_ARG (argv, i, device);
93 ADD_ARG (argv, i, NULL);
95 r = commandv (NULL, &err, argv);
97 reply_with_error ("%s: %s", device, err);
107 do_ntfsresize (const char *device)
109 return do_ntfsresize_opts (device, 0, 0);
113 do_ntfsresize_size (const char *device, int64_t size)
115 optargs_bitmask = GUESTFS_NTFSRESIZE_OPTS_SIZE_BITMASK;
116 return do_ntfsresize_opts (device, size, 0);