[Libguestfs] [PATCH 1/9] New API: ntfsresize.

Richard W.M. Jones rjones at redhat.com
Sat Apr 10 12:50:12 UTC 2010


-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://et.redhat.com/~rjones/libguestfs/
See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html
-------------- next part --------------
>From f8210da95888f0060b25dcca2ae299d5c16ff814 Mon Sep 17 00:00:00 2001
From: Richard Jones <rjones at redhat.com>
Date: Sat, 10 Apr 2010 13:13:07 +0100
Subject: [PATCH 1/9] New API: ntfsresize.

This implements the ntfsresize operation, using the external
program from ntfsprogs.
---
 daemon/ntfs.c    |   23 +++++++++++++++++++++++
 src/generator.ml |    8 ++++++++
 2 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/daemon/ntfs.c b/daemon/ntfs.c
index 73ccbbc..8938dbd 100644
--- a/daemon/ntfs.c
+++ b/daemon/ntfs.c
@@ -35,6 +35,13 @@ optgroup_ntfs3g_available (void)
 }
 
 int
+optgroup_ntfsprogs_available (void)
+{
+  int r = access ("/usr/sbin/ntfsresize", X_OK);
+  return r == 0;
+}
+
+int
 do_ntfs_3g_probe (int rw, const char *device)
 {
   char *err;
@@ -52,3 +59,19 @@ do_ntfs_3g_probe (int rw, const char *device)
 
   return r;
 }
+
+int
+do_ntfsresize (const char *device)
+{
+  char *err;
+  int r;
+
+  r = command (NULL, &err, "ntfsresize", "-P", device, NULL);
+  if (r == -1) {
+    reply_with_error ("%s: %s", device, err);
+    free (err);
+    return -1;
+  }
+
+  return 0;
+}
diff --git a/src/generator.ml b/src/generator.ml
index 9d19097..24b9bc0 100755
--- a/src/generator.ml
+++ b/src/generator.ml
@@ -4373,6 +4373,14 @@ I<xz compressed> tar file) into C<directory>.");
 This command packs the contents of C<directory> and downloads
 it to local file C<tarball> (as an xz compressed tar archive).");
 
+  ("ntfsresize", (RErr, [Device "device"]), 231, [Optional "ntfsprogs"],
+   [],
+   "resize an NTFS filesystem",
+   "\
+This command resizes an NTFS filesystem, expanding or
+shrinking it to the size of the underlying device.
+See also L<ntfsresize(8)>.");
+
 ]
 
 let all_functions = non_daemon_functions @ daemon_functions
-- 
1.6.6.1



More information about the Libguestfs mailing list