GError *error;
char *offset_as_string;
char *size_as_string;
+ char *part_number_as_string;
PolKitCaller *pk_caller;
DevkitDisksDevice *enclosing_device;
offset_as_string = NULL;
size_as_string = NULL;
+ part_number_as_string = NULL;
if ((pk_caller = devkit_disks_damon_local_get_caller_for_context (device->priv->daemon, context)) == NULL)
goto out;
offset_as_string = g_strdup_printf ("%lld", device->priv->info.partition_offset);
size_as_string = g_strdup_printf ("%lld", device->priv->info.partition_size);
-
- /* TODO: options: quick, full, secure_gutmann_35pass etc. */
+ part_number_as_string = g_strdup_printf ("%d", device->priv->info.partition_number);
n = 0;
argv[n++] = PACKAGE_LIBEXEC_DIR "/devkit-disks-helper-delete-partition";
argv[n++] = device->priv->info.device_file;
argv[n++] = offset_as_string;
argv[n++] = size_as_string;
+ argv[n++] = part_number_as_string;
for (m = 0; options[m] != NULL; m++) {
if (n >= (int) sizeof (argv) - 1) {
throw_error (context,
out:
g_free (offset_as_string);
g_free (size_as_string);
+ g_free (part_number_as_string);
if (pk_caller != NULL)
polkit_caller_unref (pk_caller);
return TRUE;
PolKitCaller *pk_caller;
char *offset_as_string;
char *size_as_string;
+ char *max_number_as_string;
char *flags_as_string;
offset_as_string = NULL;
size_as_string = NULL;
+ max_number_as_string = NULL;
flags_as_string = NULL;
if ((pk_caller = devkit_disks_damon_local_get_caller_for_context (device->priv->daemon, context)) == NULL)
offset_as_string = g_strdup_printf ("%lld", offset);
size_as_string = g_strdup_printf ("%lld", size);
+ max_number_as_string = g_strdup_printf ("%d", device->priv->info.partition_table_max_number);
/* TODO: check that neither of the flags include ',' */
flags_as_string = g_strjoinv (",", flags);
argv[n++] = device->priv->info.device_file;;
argv[n++] = offset_as_string;
argv[n++] = size_as_string;
+ argv[n++] = max_number_as_string;
argv[n++] = (char *) type;
argv[n++] = (char *) label;
argv[n++] = (char *) flags_as_string;
out:
g_free (offset_as_string);
g_free (size_as_string);
+ g_free (max_number_as_string);
g_free (flags_as_string);
if (pk_caller != NULL)
polkit_caller_unref (pk_caller);
main (int argc, char **argv)
{
int n;
- int fd;
int ret;
const char *device;
char **options;
guint64 out_start;
guint64 out_size;
char *endp;
+ int max_number;
ret = 1;
flags = NULL;
- if (argc < 7) {
+ if (argc < 8) {
g_printerr ("wrong usage\n");
goto out;
}
g_printerr ("malformed size '%s'\n", argv[3]);
goto out;
}
- type = argv[4];
- label = argv[5];
- flags_as_string = argv[6];
- options = argv + 7;
+ max_number = strtol (argv[4], &endp, 10);
+ if (*endp != '\0') {
+ g_printerr ("malformed max number '%s'\n", argv[4]);
+ goto out;
+ }
+ type = argv[5];
+ label = argv[6];
+ flags_as_string = argv[7];
+ options = argv + 8;
flags = g_strsplit (flags_as_string, ",", 0);
g_print ("progress: %d %d -1 partitioning\n", 0, 2);
+ /* ask libparted to poke the kernel */
if (part_add_partition ((char *) device,
offset,
size,
flags,
-1,
-1,
- FALSE)) {
+ TRUE)) {
+
/* now clear out file system signatures in the newly created
* partition... Unless it's an extended partition!
*/
g_printerr ("job-create-partition-size: %lld\n", out_size);
}
- /* TODO: replace blkrrpart with partx-ish ioctls */
-
- /* either way, we've got this far.. signal the kernel to reread the partition table */
- fd = open (device, O_RDONLY);
- if (fd < 0) {
- g_printerr ("cannot open %s (for BLKRRPART): %m\n", device);
- ret = 1;
- goto out;
- }
-
- if (ioctl (fd, BLKRRPART) != 0) {
- close (fd);
- g_printerr ("BLKRRPART ioctl failed for %s: %m\n", device);
- ret = 1;
- goto out;
- }
- close (fd);
out:
g_strfreev (flags);
int
main (int argc, char **argv)
{
- int fd;
int ret;
const char *device;
const char *partition_device;
int n;
guint64 offset;
guint64 size;
+ int part_number;
char *endp;
ret = 1;
erase = NULL;
- if (argc < 4) {
+ if (argc < 5) {
g_printerr ("wrong usage\n");
goto out;
}
g_printerr ("malformed size '%s'\n", argv[4]);
goto out;
}
- options = argv + 5;
+ part_number = strtol (argv[5], &endp, 10);
+ if (*endp != '\0') {
+ g_printerr ("malformed partition number '%s'\n", argv[5]);
+ goto out;
+ }
+
+ options = argv + 6;
for (n = 0; options[n] != NULL; n++) {
if (g_str_has_prefix (options[n], "erase=")) {
g_print ("progress: %d %d -1 partitioning\n", num_erase_passes, num_erase_passes + 2);
- if (part_del_partition ((char *) device, offset, FALSE)) {
+ /* ask libparted to poke the kernel */
+ if (part_del_partition ((char *) device, offset, TRUE)) {
/* zero the contents of what was the _partition_
*
}
}
- /* TODO: replace blkrrpart with partx-ish ioctls */
-
- /* either way, we've got this far.. signal the kernel to reread the partition table */
- fd = open (device, O_RDONLY);
- if (fd < 0) {
- g_printerr ("cannot open %s (for BLKRRPART): %m\n", device);
- ret = 1;
- goto out;
- }
-
- if (ioctl (fd, BLKRRPART) != 0) {
- close (fd);
- g_printerr ("BLKRRPART ioctl failed for %s: %m\n", device);
- ret = 1;
- goto out;
- }
- close (fd);
-
out:
g_free (erase);
return ret;