[Libguestfs] [PATCH 6/6] generator: Rename 'ntfsresize_opts' API to 'ntfsresize'.

Richard W.M. Jones rjones at redhat.com
Sat Jul 14 13:28:29 UTC 2012


From: "Richard W.M. Jones" <rjones at redhat.com>

By using the once_had_no_optargs flag, this change is backwards
compatible for callers.
---
 daemon/ntfs.c                  |   16 +++++-----------
 generator/generator_actions.ml |   27 ++++-----------------------
 gobject/Makefile.am            |    2 ++
 gobject/Makefile.inc           |    4 ++--
 po/POTFILES                    |    2 +-
 resize/resize.ml               |    2 +-
 6 files changed, 15 insertions(+), 38 deletions(-)

diff --git a/daemon/ntfs.c b/daemon/ntfs.c
index 235ecbc..2dedc26 100644
--- a/daemon/ntfs.c
+++ b/daemon/ntfs.c
@@ -64,7 +64,7 @@ do_ntfs_3g_probe (int rw, const char *device)
 
 /* Takes optional arguments, consult optargs_bitmask. */
 int
-do_ntfsresize_opts (const char *device, int64_t size, int force)
+do_ntfsresize (const char *device, int64_t size, int force)
 {
   char *err;
   int r;
@@ -75,7 +75,7 @@ do_ntfsresize_opts (const char *device, int64_t size, int force)
   ADD_ARG (argv, i, "ntfsresize");
   ADD_ARG (argv, i, "-P");
 
-  if (optargs_bitmask & GUESTFS_NTFSRESIZE_OPTS_SIZE_BITMASK) {
+  if (optargs_bitmask & GUESTFS_NTFSRESIZE_SIZE_BITMASK) {
     if (size <= 0) {
       reply_with_error ("size is zero or negative");
       return -1;
@@ -86,7 +86,7 @@ do_ntfsresize_opts (const char *device, int64_t size, int force)
     ADD_ARG (argv, i, size_str);
   }
 
-  if (optargs_bitmask & GUESTFS_NTFSRESIZE_OPTS_FORCE_BITMASK && force)
+  if (optargs_bitmask & GUESTFS_NTFSRESIZE_FORCE_BITMASK && force)
     ADD_ARG (argv, i, "--force");
 
   ADD_ARG (argv, i, device);
@@ -104,16 +104,10 @@ do_ntfsresize_opts (const char *device, int64_t size, int force)
 }
 
 int
-do_ntfsresize (const char *device)
-{
-  return do_ntfsresize_opts (device, 0, 0);
-}
-
-int
 do_ntfsresize_size (const char *device, int64_t size)
 {
-  optargs_bitmask = GUESTFS_NTFSRESIZE_OPTS_SIZE_BITMASK;
-  return do_ntfsresize_opts (device, size, 0);
+  optargs_bitmask = GUESTFS_NTFSRESIZE_SIZE_BITMASK;
+  return do_ntfsresize (device, size, 0);
 }
 
 /* Takes optional arguments, consult optargs_bitmask. */
diff --git a/generator/generator_actions.ml b/generator/generator_actions.ml
index b530f77..9322126 100644
--- a/generator/generator_actions.ml
+++ b/generator/generator_actions.ml
@@ -6710,26 +6710,6 @@ This command packs the contents of C<directory> and downloads
 it to local file C<tarball> (as an xz compressed tar archive)." };
 
   { defaults with
-    name = "ntfsresize";
-    style = RErr, [Device "device"], [];
-    proc_nr = Some 231;
-    optional = Some "ntfsprogs"; deprecated_by = Some "ntfsresize_opts";
-    shortdesc = "resize an NTFS filesystem";
-    longdesc = "\
-This command resizes an NTFS filesystem, expanding or
-shrinking it to the size of the underlying device.
-
-I<Note:> After the resize operation, the filesystem is marked
-as requiring a consistency check (for safety).  You have to boot
-into Windows to perform this check and clear this condition.
-Furthermore, ntfsresize refuses to resize filesystems
-which have been marked in this way.  So in effect it is
-not possible to call ntfsresize multiple times on a single
-filesystem without booting into Windows between each resize.
-
-See also L<ntfsresize(8)>." };
-
-  { defaults with
     name = "vgscan";
     style = RErr, [], [];
     proc_nr = Some 232;
@@ -7039,7 +7019,7 @@ allows you to specify the new size (in bytes) explicitly." };
     name = "ntfsresize_size";
     style = RErr, [Device "device"; Int64 "size"], [];
     proc_nr = Some 250;
-    optional = Some "ntfsprogs"; deprecated_by = Some "ntfsresize_opts";
+    optional = Some "ntfsprogs"; deprecated_by = Some "ntfsresize";
     shortdesc = "resize an NTFS filesystem (with size)";
     longdesc = "\
 This command is the same as C<guestfs_ntfsresize> except that it
@@ -7750,8 +7730,9 @@ returned in this list.  Call C<guestfs_lvs> if you want to list logical
 volumes." };
 
   { defaults with
-    name = "ntfsresize_opts";
+    name = "ntfsresize";
     style = RErr, [Device "device"], [OInt64 "size"; OBool "force"];
+    once_had_no_optargs = true;
     proc_nr = Some 288;
     optional = Some "ntfsprogs"; camel_name = "NTFSResizeOpts";
     shortdesc = "resize an NTFS filesystem";
@@ -7777,7 +7758,7 @@ After the resize operation, the filesystem is always marked
 as requiring a consistency check (for safety).  You have to boot
 into Windows to perform this check and clear this condition.
 If you I<don't> set the C<force> option then it is not
-possible to call C<guestfs_ntfsresize_opts> multiple times on a
+possible to call C<guestfs_ntfsresize> multiple times on a
 single filesystem without booting into Windows between each resize.
 
 =back
diff --git a/gobject/Makefile.am b/gobject/Makefile.am
index 60e4fb9..ce4a853 100644
--- a/gobject/Makefile.am
+++ b/gobject/Makefile.am
@@ -47,6 +47,8 @@ CLEANFILES += \
 	include/guestfs-gobject/optargs-add_drive_opts.h \
 	src/optargs-mkfs_opts.c \
 	include/guestfs-gobject/optargs-mkfs_opts.h \
+	src/optargs-ntfsresize_opts.c \
+	include/guestfs-gobject/optargs-ntfsresize_opts.h \
 	src/optargs-test0.c \
 	include/guestfs-gobject/optargs-test0.h
 
diff --git a/gobject/Makefile.inc b/gobject/Makefile.inc
index 543fd9b..4de56a9 100644
--- a/gobject/Makefile.inc
+++ b/gobject/Makefile.inc
@@ -46,7 +46,7 @@ guestfs_gobject_headers= \
   include/guestfs-gobject/optargs-umount_local.h \
   include/guestfs-gobject/optargs-mkfs.h \
   include/guestfs-gobject/optargs-mount_9p.h \
-  include/guestfs-gobject/optargs-ntfsresize_opts.h \
+  include/guestfs-gobject/optargs-ntfsresize.h \
   include/guestfs-gobject/optargs-btrfs_filesystem_resize.h \
   include/guestfs-gobject/optargs-compress_out.h \
   include/guestfs-gobject/optargs-compress_device_out.h \
@@ -90,7 +90,7 @@ guestfs_gobject_sources= \
   src/optargs-umount_local.c \
   src/optargs-mkfs.c \
   src/optargs-mount_9p.c \
-  src/optargs-ntfsresize_opts.c \
+  src/optargs-ntfsresize.c \
   src/optargs-btrfs_filesystem_resize.c \
   src/optargs-compress_out.c \
   src/optargs-compress_device_out.c \
diff --git a/po/POTFILES b/po/POTFILES
index d09a23c..7f67911 100644
--- a/po/POTFILES
+++ b/po/POTFILES
@@ -153,7 +153,7 @@ gobject/src/optargs-mount_9p.c
 gobject/src/optargs-mount_local.c
 gobject/src/optargs-ntfsclone_out.c
 gobject/src/optargs-ntfsfix.c
-gobject/src/optargs-ntfsresize_opts.c
+gobject/src/optargs-ntfsresize.c
 gobject/src/optargs-set_e2attrs.c
 gobject/src/optargs-tune2fs.c
 gobject/src/optargs-umount_local.c
diff --git a/resize/resize.ml b/resize/resize.ml
index 9ef2bbd..90b4e99 100644
--- a/resize/resize.ml
+++ b/resize/resize.ml
@@ -1139,7 +1139,7 @@ let () =
     let do_expand_content target = function
       | PVResize -> g#pvresize target
       | Resize2fs -> g#resize2fs target
-      | NTFSResize -> g#ntfsresize_opts ~force:ntfsresize_force target
+      | NTFSResize -> g#ntfsresize ~force:ntfsresize_force target
       | BtrfsFilesystemResize ->
           (* Complicated ...  Btrfs forces us to mount the filesystem
            * in order to resize it.
-- 
1.7.10.4




More information about the Libguestfs mailing list