Hello

You will find in the joined file a new version of the patch including the missing code.

The automatic disclaimer automatically added to end of this e-mail does not apply to the patch file as seen with our legal team.

Regards

Philippe

On 20/06/2023 14:30, Richard W.M. Jones wrote:
On Tue, Jun 20, 2023 at 02:09:36PM +0200, Philippe Midol-Monnet wrote:
Hello

We are using libguestfs with nested partitions: One partition
encrypted with LUKS include a GPT and several partition.
In order to make the nested partition available to the system after
the cryptsetup-open, partprobe need to be run.
I guess it is true for all kind of nested partitions (encrypted or not).

This patch add a partprobe call in the API.

Regards

Philippe



--


*This email and any attachment contains EasyMile’s confidential
information, and must not be modified or circulated without
EasyMile’s prior written consent. It is intended exclusively for
their recipient.s. If you received this message by mistake, please
notify us promptly and immediately delete this email and any of its
attachments.*
(You might want to change this warning, as it may prevent us from
including this code upstream ...)

diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index bb2e58d01..8c34f3634 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -164,6 +164,7 @@ guestfsd_SOURCES = \
        optgroups.c \
        optgroups.h \
        parted.c \
+       partprobe.c \
        pingdaemon.c \
        proto.c \
        readdir.c \
diff --git a/docs/C_SOURCE_FILES b/docs/C_SOURCE_FILES
index 7a20e5594..0e845dcec 100644
--- a/docs/C_SOURCE_FILES
+++ b/docs/C_SOURCE_FILES
@@ -125,6 +125,7 @@ daemon/ntfsclone.c
  daemon/optgroups.c
  daemon/optgroups.h
  daemon/parted.c
+daemon/partprobe.c
  daemon/pingdaemon.c
  daemon/proto.c
  daemon/readdir.c
diff --git a/generator/actions_core.ml b/generator/actions_core.ml
index addbe4ec1..f63065426 100644
--- a/generator/actions_core.ml
+++ b/generator/actions_core.ml
@@ -5110,6 +5110,16 @@ partition table), C<gpt> (a GPT/EFI-style partition 
table).  Other
  values are possible, although unusual.  See C<guestfs_part_init>
  for a full list." };
+ { defaults with
+    name = "partprobe"; added = (1, 0, 54);
This should be the next version, ie. (1, 51, 4)

+    style =  RErr, [String (Device, "device")], [];
+    tests = [];
+    shortdesc = "run partprobe";
+    longdesc = "\
+This command runs the C<partprobe> on a device in order to inform
+the OS of partition table change
+usage for C<path>.It is neede in case of nested partition."};
+
    { defaults with
      name = "fill"; added = (1, 0, 79);
      style = RErr, [Int "c"; Int "len"; String (Pathname, "path")], [];
diff --git a/generator/proc_nr.ml b/generator/proc_nr.ml
index f71a849c9..342ba6e82 100644
--- a/generator/proc_nr.ml
+++ b/generator/proc_nr.ml
@@ -516,6 +516,7 @@ let proc_nr = [
  511, "internal_readdir";
  512, "clevis_luks_unlock";
  513, "inspect_get_build_id";
+514, "partprobe";
  ]
(* End of list. If adding a new entry, add it at the end of the list
diff --git a/lib/MAX_PROC_NR b/lib/MAX_PROC_NR
index 31cf34b8d..a08796291 100644
--- a/lib/MAX_PROC_NR
+++ b/lib/MAX_PROC_NR
@@ -1 +1 @@
-513
+514
The patch is fine as far as it goes, but you'll need to include the
new partprobe.c file :-)

Rich.


--


*This email and any attachment contains EasyMile’s confidential information, and must not be modified or circulated without EasyMile’s prior written consent. It is intended exclusively for their recipient.s. If you received this message by mistake, please notify us promptly and immediately delete this email and any of its attachments.*

*As data controller, EasyMile processes personal data, in compliance with the European GDPR (EU) 2016/679 of 27 April 2016. To exercise your rights, you can contact EasyMile at priv...@easymile.com, and if necessary, you may contact the local competent supervisory authority.”*

*Cet e-mail et toute pièce jointe contiennent des informations confidentielles d'EasyMile et ne doivent pas être modifiés ou diffusés sans le consentement écrit préalable d'EasyMile. Ils sont destinés exclusivement à leur destinataire.s. Si vous avez reçu ce message par erreur, veuillez nous en informer rapidement et supprimer immédiatement cet e-mail et toutes ses pièces jointes.  *

*En tant que responsable de traitement, EasyMile traite des données personnelles, conformément au RGPD européen (UE) 2016/679 du 27 avril 2016. Pour exercer vos droits, vous pouvez contacter EasyMile à  priv...@easymile.com <mailto:priv...@easymile.com>, et si nécessaire, vous pouvez contacter l'autorité de contrôle locale compétente.*
diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index bb2e58d01..8c34f3634 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -164,6 +164,7 @@ guestfsd_SOURCES = \
 	optgroups.c \
 	optgroups.h \
 	parted.c \
+	partprobe.c \
 	pingdaemon.c \
 	proto.c \
 	readdir.c \
diff --git a/daemon/partprobe.c b/daemon/partprobe.c
new file mode 100644
index 000000000..343d8f8ea
--- /dev/null
+++ b/daemon/partprobe.c
@@ -0,0 +1,44 @@
+/* libguestfs - the guestfsd daemon
+ * Copyright (C) 2009-2023 Red Hat Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <inttypes.h>
+
+#include "guestfs_protocol.h"
+#include "daemon.h"
+#include "actions.h"
+
+int
+do_partprobe (const char *path)
+{
+  int r;
+  CLEANUP_FREE char *out = NULL, *err = NULL;
+
+  r = command (&out, &err, "partprobe", path, NULL);
+  if (r == -1) {
+    reply_with_error ("%s: %s", path, err);
+    return -1;
+  }
+
+  return r;
+}
diff --git a/docs/C_SOURCE_FILES b/docs/C_SOURCE_FILES
index 7a20e5594..0e845dcec 100644
--- a/docs/C_SOURCE_FILES
+++ b/docs/C_SOURCE_FILES
@@ -125,6 +125,7 @@ daemon/ntfsclone.c
 daemon/optgroups.c
 daemon/optgroups.h
 daemon/parted.c
+daemon/partprobe.c
 daemon/pingdaemon.c
 daemon/proto.c
 daemon/readdir.c
diff --git a/generator/actions_core.ml b/generator/actions_core.ml
index addbe4ec1..0cfdb9d42 100644
--- a/generator/actions_core.ml
+++ b/generator/actions_core.ml
@@ -5110,6 +5110,16 @@ partition table), C<gpt> (a GPT/EFI-style partition table).  Other
 values are possible, although unusual.  See C<guestfs_part_init>
 for a full list." };
 
+  { defaults with
+    name = "partprobe"; added = (1, 51, 4);
+    style =  RErr, [String (Device, "device")], [];
+    tests = [];
+    shortdesc = "run partprobe";
+    longdesc = "\
+This command runs C<partprobe> on a device in order to inform
+the OS of partition table change.
+It is needed in case of nested partition."};
+
   { defaults with
     name = "fill"; added = (1, 0, 79);
     style = RErr, [Int "c"; Int "len"; String (Pathname, "path")], [];
diff --git a/generator/proc_nr.ml b/generator/proc_nr.ml
index f71a849c9..342ba6e82 100644
--- a/generator/proc_nr.ml
+++ b/generator/proc_nr.ml
@@ -516,6 +516,7 @@ let proc_nr = [
 511, "internal_readdir";
 512, "clevis_luks_unlock";
 513, "inspect_get_build_id";
+514, "partprobe";
 ]
 
 (* End of list.  If adding a new entry, add it at the end of the list
diff --git a/lib/MAX_PROC_NR b/lib/MAX_PROC_NR
index 31cf34b8d..a08796291 100644
--- a/lib/MAX_PROC_NR
+++ b/lib/MAX_PROC_NR
@@ -1 +1 @@
-513
+514
_______________________________________________
Libguestfs mailing list
Libguestfs@redhat.com
https://listman.redhat.com/mailman/listinfo/libguestfs

Reply via email to