return r;
}
+
+int
+do_part_to_partnum (const char *part)
+{
+ int err = 1;
+ size_t n = strlen (part);
+
+ while (n >= 1 && c_isdigit (part[n-1])) {
+ err = 0;
+ n--;
+ }
+
+ if (err) {
+ reply_with_error ("device name is not a partition");
+ return -1;
+ }
+
+ int r;
+ if (sscanf (&part[n], "%d", &r) != 1) {
+ reply_with_error ("could not parse number");
+ return -1;
+ }
+
+ return r;
+}
(eg. \"/dev/sdb\").
The named partition must exist, for example as a string returned
-from C<guestfs_list_partitions>.");
+from C<guestfs_list_partitions>.
+
+See also C<guestfs_part_to_partnum>.");
("upload_offset", (RErr, [FileIn "filename"; Dev_or_Path "remotefilename"; Int64 "offset"], []), 273, [Progress],
(let md5 = Digest.to_hex (Digest.file "COPYING.LIB") in
The C<ctype> and optional C<level> parameters have the same meaning
as in C<guestfs_compress_out>.");
+ ("part_to_partnum", (RInt "partnum", [Device "partition"], []), 293, [],
+ [InitPartition, Always, TestOutputInt (
+ [["part_to_partnum"; "/dev/sda1"]], 1);
+ InitEmpty, Always, TestLastFail (
+ [["part_to_partnum"; "/dev/sda"]])],
+ "convert partition name to partition number",
+ "\
+This function takes a partition name (eg. \"/dev/sdb1\") and
+returns the partition number (eg. C<1>).
+
+The named partition must exist, for example as a string returned
+from C<guestfs_list_partitions>.
+
+See also C<guestfs_part_to_dev>.");
]
let all_functions = non_daemon_functions @ daemon_functions