Beispiel #1
0
static PedPartition *
_amiga_next_real_partition(const PedDisk *disk, PedPartition *part) {
	PedPartition *next;

	for (next = ped_disk_next_partition (disk, part);
		next != NULL && !ped_partition_is_active (next);
		next = ped_disk_next_partition (disk, next));
	return next;
}
// This function is different to PartitionList.print().
// print the PedPartition info directly.
void PartitionTable::print_part_list()
{
    fprintf(stderr, "PartitionTable::print_part_list:\n");
    PedPartition* temp_part = NULL;
    while( (temp_part = ped_disk_next_partition( disk_ , temp_part )) != NULL ) {
	printf ("%02d %02d Addr:%p\n", temp_part->num, temp_part->type, temp_part);
    }
}
Beispiel #3
0
int main(int argc, char *argv[])
{
	PedDevice *device;
	PedDisk *disk;
	PedPartition *part;
	char *name;

	if (argc != 2)
		error(EXIT_FAILURE, 0, "wrong number!");

	device = ped_device_get(argv[1]);
	if (!device)
		goto error_out;

	disk = ped_disk_new(device);
	if (!disk)
		goto error;

	printf("%3s %s %s %s %s\n", "NO.", "Start", "Size", "FS", "NAME");

	for (part = ped_disk_next_partition(disk, NULL); part;
		part = ped_disk_next_partition(disk, part) )
	{
		if (part->num <  0)
			continue;
		name = ped_partition_get_name(part);

		printf("%lld %lld %lld %s %s\n", part->num,
			part->geom.start, part->geom.length,
			(part->fs_type) ? part->fs_type->name : "",
			name ? name : "");
	}

	ped_disk_destroy(disk);
	ped_device_destroy(device);
	return 0;

error:
	ped_device_destroy(device);
error_out:
	return 1;
}
Beispiel #4
0
int listparts(PedDisk *disk, int noswap)
{
	PedPartition *part = NULL;
	PedPartition *extpart = NULL;

	if(ped_disk_next_partition(disk, NULL)==NULL)
		// no partition detected
		return(1);
	for(part=ped_disk_next_partition(disk, NULL);
		part!=NULL;part=part->next)
	{
		if((part->num>0) && (part->type != PED_PARTITION_EXTENDED) && !ped_partition_get_flag(part, PED_PARTITION_RAID))
			partdetails(part, noswap);
		if(part->type == PED_PARTITION_EXTENDED)
			for(extpart=part->part_list;
				extpart!=NULL;extpart=extpart->next)
				if(extpart->num>0 && !ped_partition_get_flag(extpart, PED_PARTITION_RAID))
					partdetails(extpart, noswap);
	}
	return(0);
}
Beispiel #5
0
int
main(int argc, char *argv[])
{
	PedDevice *dev;
	// use "-l" to list all prep partitions found (not just the first one).
	int list = (argc == 2 && !strncmp(argv[1], "-l", strlen("-l")));

	ped_exception_fetch_all();
	ped_device_probe_all();
	for (dev = ped_device_get_next(NULL); dev;
	     dev = ped_device_get_next(dev)) {
		PedDisk *disk;
		PedPartition *part;

		disk = ped_disk_new(dev);
		if (!disk)
			continue;

		for (part = ped_disk_next_partition(disk, NULL); part;
		     part = ped_disk_next_partition(disk, part)) {
			if (ped_partition_is_active(part) &&
			    ped_partition_get_flag(part, PED_PARTITION_PREP)) {
				char *path;

				path = ped_partition_get_path(part);
				if (path) {
					printf("%s\n", path);
					if (!list) {
						free(path);
						return 0;
					}
				}
				free(path);
			}
		}
	}

	return 0;
}
char* query_esp_path_by_disk(const char* path)
{
    g_message("[%s], path: %s\n", __func__, path);
    PedDevice* device = ped_device_get(path);
    PedDiskType *type = ped_disk_probe(device);
    if (type == 0) {
        return NULL;
    }
    if (strncmp(type->name, "loop", 5) == 0) {
        return NULL;
    }
    PedDisk* disk = ped_disk_new(device);
    if (disk == 0) {
        return NULL;
    }

    PedPartition* part = 0;
    for (part = ped_disk_next_partition(disk, NULL); part;
         part = ped_disk_next_partition(disk, part)) {
        if (part->num <  0) {
            continue;
        }

        if (part->fs_type == 0 ||
            strncmp(part->fs_type->name, "fat32", 5) != 0) {
            continue;
        }


        int is_esp = has_efi_directory(part);
        g_debug("[%s] %s is ESP ? : %d\n", __func__,
                ped_partition_get_path(part), is_esp);
        if (is_esp) {
            return ped_partition_get_path(part);
        }
    }

    return NULL;
}
int main (int argc, char* argv[])
{
    PedDevice* device = NULL;
    PedDisk* disk = NULL;
    PedDiskType* type = NULL;
    PedPartition* part = NULL;
    
    int return_code = EXIT_FAILURE;
    
        if (argc != 2){
            printf("wrong number of arguments\n");
            return EXIT_FAILURE;
        }
    
    
    device = ped_device_get (argv[1]);
    printf("device:%s\n",argv[1]);
    if (device == NULL)
        goto error_exit;
    
    type = ped_disk_probe (device);
    if (type == NULL) 
        goto error_destroy_device;
        
    printf("Disk Type:%s\n",type->name);
        
    
    disk = ped_disk_new (device);
    if (disk == NULL)
        goto error_destroy_device;
    
    do
    {
        part = ped_disk_next_partition (disk, part);
        if ((part != NULL) && (part->num > -1)){
                printf("%d %s %s\n",part->num,ped_partition_type_get_name(part->type),ped_unit_format (device,part->geom.length));
        }
        
    }while( part );
    
    ped_disk_destroy (disk);
    return_code = EXIT_SUCCESS;
    
// Fall through to clean up 
error_destroy_device:
    ped_device_destroy (device);

error_exit:
    return return_code;
}
PedPartition* find_partition(PedDisk* disk,  PartitionFilter filter,
                             gpointer user_data, GDestroyNotify notify)
{
    PedPartition* part = disk->part_list;
    gboolean found = false;
    while (part) {
        if (filter(part, user_data)) {
            found = true;
            break;
        }
        part = ped_disk_next_partition(disk, part);
    }
    if (notify) {
        notify(user_data);
    }
    return part;
}
Beispiel #9
0
int detect_raids()
{
	FILE *fp;
	char *line, *ptr;
	PedDevice *dev = NULL;
	PedDisk *disk = NULL;
	PedPartition *part = NULL;

	if ((fp = fopen("/proc/mdstat", "r"))== NULL)
	{
		//perror("Could not open output file for writing");
		return(-1);
	}
	MALLOC(line, PATH_MAX);
	while(!feof(fp))
	{
		if(fgets(line, PATH_MAX, fp) == NULL)
			break;
		if(strstr(line, "md")==line)
		{
			ptr = line;
			while(*ptr!=' ')
				ptr++;
			*ptr='\0';
			dev = ped_device_get(g_strdup_printf("/dev/%s", line));
			disk = ped_disk_new_fresh(dev, ped_disk_type_get ("loop"));
			if(disk)
			{
				part=ped_disk_next_partition(disk, NULL);
				partdetails(part, 0);
			}
		}
	}
	FREE(line);
	fclose(fp);
	return(0);
}
Beispiel #10
0
/* Return a new store in STORE which contains a remap store of partition
   PART from the contents of SOURCE; SOURCE is consumed.  */
error_t
store_part_create (struct store *source, int index, int flags,
		   struct store **store)
{
  static pthread_mutex_t parted_lock = PTHREAD_MUTEX_INITIALIZER;
  static int version_check;

  error_t err = 0;
  PedDevice *dev;
  PedDisk *disk;
  PedPartition *part;
  struct store_run run;

  if ((source->block_size < PED_SECTOR_SIZE
       && PED_SECTOR_SIZE % source->block_size != 0)
      || (source->block_size > PED_SECTOR_SIZE
	  && source->block_size % PED_SECTOR_SIZE != 0))
    return EINVAL;

  pthread_mutex_lock (&parted_lock);

  /* Since Parted provides no source-level information about
     version compatibility, we have to check at run time.  */
  if (version_check == 0)
    {
      const char *version = ped_get_version ();
      version_check = -1;
      if (version == 0)
	error (0, 0, "cannot get version of Parted library!");
      else if (strverscmp (version, NEED_PARTED_VERSION) < 0)
	error (0, 0, "Parted library version %s older than needed %s",
	       version, NEED_PARTED_VERSION);
      else
	version_check = 1;
    }
  if (version_check <= 0)
    {
      error (0, 0, "the `part' store type is not available");
      pthread_mutex_unlock (&parted_lock);
      return ENOTSUP;
    }

  ped_exception_fetch_all ();

  dev = ped_device_new_from_store (source);
  if (! dev)
    {
      ped_exception_catch ();
      err = EIO;
      goto out;
    }

  assert (ped_device_open (dev) != 0);

  disk = ped_disk_new (dev);
  if (! disk)
    {
      ped_exception_catch ();
      err = EIO;
      goto out_with_dev;
    }

  for (part = ped_disk_next_partition (disk, NULL); part;
       part = ped_disk_next_partition (disk, part))
    {
      if (part->type != PED_PARTITION_LOGICAL
	  && part->type != 0 /* PED_PARTITION_PRIMARY */)
	continue;

      assert (part->num);
      if (part->num == index)
        break;
    }

  if (! part)
    {
      err = EIO;
      goto out_with_disk;
    }

  if (source->block_size == PED_SECTOR_SIZE)
    {
      run.start = part->geom.start;
      run.length = part->geom.length;
    }
  else if (source->block_size < PED_SECTOR_SIZE)
    {
      run.start = part->geom.start * (PED_SECTOR_SIZE / source->block_size);
      run.length = part->geom.length * (PED_SECTOR_SIZE / source->block_size);
    }
  else
    /* source->block_size > PED_SECTOR_SIZE */
    {
      run.start = part->geom.start * PED_SECTOR_SIZE;
      if (run.start % source->block_size != 0)
	err = EIO;
      else
	{
	  run.start /= source->block_size;
          run.length = part->geom.length * PED_SECTOR_SIZE;
	  if (run.length % source->block_size != 0)
	    err = EIO;
	  else
	    run.length /= source->block_size;
	}
    }

out_with_disk:
  assert (ped_device_close (dev) != 0);
  ped_disk_destroy (disk);
out_with_dev:
  ped_device_destroy (dev);
out:
  ped_exception_leave_all ();
  pthread_mutex_unlock (&parted_lock);

  if (! err)
    err = store_remap (source, &run, 1, store);

  return err;
}
PartitionState do_test1(PedDevice *dev, label_type labelType) {
    PartitionState state;
    //PedGeometry geom;
    PedDisk *disk;
    PedPartition *part;
    PedPartition *grub_partition = 0, *boot_partition = 0, *root_partition = 0;
    PedDiskType *type = 0;
    PedFileSystemType *ext4 = ped_file_system_type_get("ext4");
    bool dirty = false;
    PedSector start = 0, end = 0;

    /*if (!ped_geometry_init(&geom,dev,0,dev->length)) {
        qDebug() << "unable to init geom";
        return;
    }*/

    disk = ped_disk_new(dev);
    /*type = ped_disk_probe(dev);
    if (type) {
        qDebug() << "current partition type:" << type->name;
        disk = type->ops->alloc(dev);
        if (!type->ops->read(disk)) {
            qDebug() << "failed to read gpt tables";
            return;
        }
    }*/
    if (!disk) {
        qDebug() << "no tables detected";
        if (labelType == label_type::gpt) {
            type = ped_disk_type_get("gpt");
        } else if (labelType == label_type::mbr) {
            type = ped_disk_type_get("msdos");
        }
        disk = ped_disk_new_fresh(dev,type);
        ped_disk_commit(disk);
    }
    if (disk) {
        for (part = ped_disk_next_partition(disk,NULL);
             part;
             part = ped_disk_next_partition(disk,part)) {
            if (!ped_partition_is_active(part)) continue;
            QString name(ped_partition_get_name(part));
            qDebug() << "partition" << part->num << name;
            if (name == "boot") boot_partition = part;
            if (name == "root") root_partition = part;
            if (ped_partition_get_flag(part,PED_PARTITION_BIOS_GRUB)) grub_partition = part;
            for (int f = PED_PARTITION_FIRST_FLAG; f < PED_PARTITION_LAST_FLAG; f++) {
                if (ped_partition_get_flag(part,(PedPartitionFlag)f)) {
                    QString flag_name(ped_partition_flag_get_name((PedPartitionFlag)f));
                    qDebug() << "flag" << flag_name << "is set";
                }
            }
        }

        PedConstraint *constraint = ped_constraint_any(dev);
        if (!grub_partition) {
            start = (1024*1024) / dev->sector_size;
            end = ((1024*1024) / dev->sector_size) + start;
            qDebug() << "creating" << start << end;
            grub_partition = ped_partition_new(disk,PED_PARTITION_NORMAL,ext4,start,end);
            if (labelType == label_type::gpt) {
                ped_partition_set_name(grub_partition,"bios boot");
                ped_partition_set_flag(grub_partition,PED_PARTITION_BIOS_GRUB,1);
            }
            if (!ped_disk_add_partition(disk,grub_partition,constraint)) {
                qDebug() << "error adding partition";
            }
            dirty = true;
        }

        if (!boot_partition) {
            start = (1024*1024*2) / dev->sector_size;
            end = ((1024*1024*128) / dev->sector_size) + start;
            qDebug() << "creating" << start << end;
            boot_partition = ped_partition_new(disk,PED_PARTITION_NORMAL,NULL,start,end);
            if (labelType == label_type::gpt) {
                ped_partition_set_name(boot_partition,"boot");
            }
            //ped_partition_set_flag(boot_partition,PED_PARTITION_BOOT,1);
            if (!ped_disk_add_partition(disk,boot_partition,constraint)) {
                qDebug() << "error adding partition";
            }
            dirty = true;
        }
        if (!root_partition) {
            start = (1024*1024*129) / dev->sector_size;
            end = dev->length;
            qDebug() << "creating" << start << end;
            root_partition = ped_partition_new(disk,PED_PARTITION_NORMAL,ext4,start,end);
            if (labelType == label_type::gpt) {
                ped_partition_set_name(root_partition,"root");
                //ped_partition_set_flag(root_partition,PED_PARTITION_ROOT,1);
            }
            if (!ped_disk_add_partition(disk,root_partition,constraint)) {
                qDebug() << "error adding partition";
            }
            dirty = true;
        }
        ped_constraint_destroy(constraint);
    }
    if (dirty) ped_disk_commit(disk);
    state.boot_path = ped_partition_get_path(boot_partition);
    state.root_path = ped_partition_get_path(root_partition);
    return state;
}
Beispiel #12
0
int
get_all_partitions(struct partition *parts[], const int max_parts, bool ignore_fs_type, PedPartitionFlag require_flag)
{
    struct partition *p;
    int part_count = 0;
    PedDevice *dev = NULL;
    PedDisk *disk;
    PedPartition *part;

    ped_device_probe_all();
    while ((dev = ped_device_get_next(dev)) != NULL) {
        if (dev->read_only)
            continue;
        if (strstr(dev->path, "/dev/mtd") == dev->path)
            continue;
        if (!ped_disk_probe(dev))
            continue;
        disk = ped_disk_new(dev);

        part = NULL;
        while ((part = ped_disk_next_partition(disk, part)) != NULL) {
            if (part->type & (PED_PARTITION_METADATA | PED_PARTITION_FREESPACE | PED_PARTITION_EXTENDED))
                continue;

            if (part_count >= max_parts)
                break;

#ifndef FIND_PARTS_MAIN
            /* allow other udebs to block partitions */
            if(block_partition(ped_partition_get_path(part)) != 0)
                continue;
#endif

            if (require_flag && !ped_partition_get_flag(part, require_flag))
                continue;

            p = malloc(sizeof(*p));
            p->path = ped_partition_get_path(part);
            if (strstr(p->path, "/dev/hd") == p->path) {
                static char *targets[] = { "master", "slave" };
                char drive;
                int part;

                if (sscanf(p->path, "/dev/hd%c%d", &drive, &part) == 2
                        && drive >= 'a' && drive <= 'z')
                    asprintf(&p->description, "IDE%d %s\\, part. %d",
                            (drive - 'a') / 2 + 1, targets[(drive - 'a') % 2],
                            part);
                else
                    p->description = strdup(p->path);
            } else if (strstr(p->path, "/dev/sd") == p->path) {
                char drive;
                int host, bus, target, lun, part;
                int done = 0;

                if (sscanf(p->path, "/dev/sd%c%d", &drive, &part) == 2
                        && drive >= 'a' && drive <= 'z') {
                    struct stat st;
                    char *disk, *disk_pos, *sys_device;
                    disk = strdup(p->path + 5);
                    for (disk_pos = disk + strlen(disk) - 1; disk_pos > disk;
                         --disk_pos) {
                        if (*disk_pos >= '0' && *disk_pos <= '9')
                            *disk_pos = 0;
                        else
                            break;
                    }
                    sys_device = malloc(strlen(disk) + 19);
                    sprintf(sys_device, "/sys/block/%s/device", disk);
                    /* TODO: device symlinks are allegedly slated to go
                     * away, but it's not entirely clear what their
                     * replacement will be yet ...
                     */
                    if (lstat(sys_device, &st) == 0 && S_ISLNK(st.st_mode)) {
                        char buf[512];
                        memset(buf, 0, 512);
                        if (readlink(sys_device, buf, 511) > 0) {
                            const char *bus_id = basename(buf);
                            if (sscanf(bus_id, "%d:%d:%d:%d",
                                        &host, &bus, &target, &lun) == 4) {
                                asprintf(&p->description, "SCSI%d (%d\\,%d\\,%d) part. %d",
                                        host + 1, bus, target, lun, part);
                                done = 1;
                            }
                        }
                    }
                }
                if (!done)
                    p->description = strdup(p->path);
            } else
                p->description = strdup(p->path);
            p->fstype = NULL;
            p->fsid = NULL;
            p->size = 0L;
            p->op.filesystem = NULL;
            p->op.mountpoint = NULL;
            p->op.done = 0;
            test_lvm(p);
            test_evms(p);
            test_raid(p);
            /* FIXME: Other tests? */

            get_partition_info(p, part, dev, ignore_fs_type);
            parts[part_count++] = p;
        }

        if (part_count >= max_parts)
            break;
    }

    return part_count;
}
Beispiel #13
0
/**
 * @brief GetPartitions
 * @param deviceName : dev name of the disk eg. '/dev/sdc'
 * @param partitions : a vector of partitions that this function will write to. 
 * @return true if partitions on disk(deviceName) was successfully read.
 */
bool GetPartitions(std::string deviceName, cPartitions& partitions)
{
    PedDevice* device = NULL;
    PedDisk* disk = NULL;
    PedPartition* part = NULL;
    bool result = false;
    cPartition partition;
    ped_device_probe_all ();
    
    device = ped_device_get(deviceName.c_str());
    if (device == NULL) 
    {
        LOG_PARTED_ERROR("ped_device_get('%s') returned NULL", deviceName.c_str());
        
        result = false;
        goto cleanup;
    } // if
    
    disk = ped_disk_new(device);
    if (disk == NULL) 
    {
        LOG_PARTED_ERROR("ped_disk_new(%p) returned NULL for device %s",
                  disk, deviceName.c_str());
        
        result = false;
        goto cleanup;
    } // if
    
    
    result = true;
    partitions.clear();
    
    // iterate over found paritions
    for (part = ped_disk_next_partition (disk, NULL); 
         part;
         part = ped_disk_next_partition (disk, part))
    {
        if (part->num < 0) 
        {
            LOG_PARTED_WARN("got negative partition number := %d! in device %s", 
                     part->num,
                     deviceName.c_str());
            continue;
        }
        
        /* device name to which this partition belongs */
        partition.deviceName = deviceName;
        
        partition.number = part->num;

        /* convert from number of blocks to number of Megabytes MiB*/
        partition.size = (part->geom.length * device->sector_size) /(1024 * 1024);
        
        partition.filesystem = (part->fs_type) ? part->fs_type->name : "";
        
        /* partition type , avoid extended partitions and freespace ...*/
        partition.mountable = ((part->type&PED_PARTITION_LOGICAL)
                ||(part->type==PED_PARTITION_NORMAL));
        
        /* add to partition list */
        partitions.push_back (partition);
    } // for
    
    
cleanup:
    /* clean up */
    if (disk)
        ped_disk_destroy (disk);
    
    if (device)
        ped_device_destroy (device);

    return result;
} // GetPartitions()
Beispiel #14
0
int main(int argc, char **argv)
{
    PedDevice *dev;
    PedDisk *disk;
    PedPartition *part;
    int cmd = DISK_LAYOUT;
    const char *path;
    const char *partsep;

    if (argc == 3 && STREQ(argv[2], "-g")) {
        cmd = DISK_GEOMETRY;
    } else if (argc != 2) {
        fprintf(stderr, "syntax: %s DEVICE [-g]\n", argv[0]);
        return 1;
    }

    path = argv[1];
    partsep = *path && c_isdigit(path[strlen(path)-1]) ? "p" : "";

    if ((dev = ped_device_get(path)) == NULL) {
        fprintf(stderr, "unable to access device %s\n", path);
        return 2;
    }

    /* return the geometry of the disk and then exit */
    if(cmd == DISK_GEOMETRY) {
        printf("%d%c%d%c%d%c",
               dev->hw_geom.cylinders, '\0',
               dev->hw_geom.heads, '\0',
               dev->hw_geom.sectors, '\0');
        return 0;
    }

    if ((disk = ped_disk_new(dev)) == NULL) {
        fprintf(stderr, "unable to access disk %s\n", argv[1]);
        return 2;
    }

    /* Get the first partition, and then iterate over all */
    part = ped_disk_next_partition(disk, NULL);
    while (part) {
        const char *type;
        const char *content;
        if (part->type & PED_PARTITION_LOGICAL) {
            type = "logical";
            if (part->type & PED_PARTITION_FREESPACE)
                content = "free";
            else if (part->type & PED_PARTITION_METADATA)
                content = "metadata";
            else if (part->type & PED_PARTITION_PROTECTED)
                content = "protected";
            else
                content = "data";
        } else if (part->type == PED_PARTITION_EXTENDED) {
            type = "extended";
            content = "metadata";
        } else {
            type = "normal";
            if (part->type & PED_PARTITION_FREESPACE)
                content = "free";
            else if (part->type & PED_PARTITION_METADATA)
                content = "metadata";
            else if (part->type & PED_PARTITION_PROTECTED)
                content = "protected";
            else
                content = "data";
        }

        /* We do +1 on geom.end, because we want end of the last sector
         * in bytes, not the last sector number
         */
        if (part->num != -1) {
            printf("%s%s%d%c%s%c%s%c%llu%c%llu%c%llu%c",
                   path, partsep,
                   part->num, '\0',
                   type, '\0',
                   content, '\0',
                   part->geom.start * 512llu, '\0',
                   (part->geom.end + 1 ) * 512llu, '\0',
                   part->geom.length * 512llu, '\0');
        } else {
            printf("%s%c%s%c%s%c%llu%c%llu%c%llu%c",
                   "-", '\0',
                   type, '\0',
                   content, '\0',
                   part->geom.start * 512llu, '\0',
                   (part->geom.end + 1 ) * 512llu, '\0',
                   part->geom.length * 512llu, '\0');
        }
        part = ped_disk_next_partition(disk, part);
    }

    return 0;
}
void MParted::MParted_Core::scanDevicePartitions(MParted::Device &device) {
    device.partitions.clear();

    // Initialise
    PedPartition *pedPartition = NULL;
    MParted::Partition *extendedPartition = NULL;

    while ((pedPartition = ped_disk_next_partition(pedDisk, pedPartition))) {
        //if there's no end, there's no partition ;)
        if (pedPartition->geom.end <= -1)
            continue;

        MParted::Partition partition;
        partition.devicePath = device.path;
        partition.sector_size = device.sector_size;
        partition.busy = ped_partition_is_busy(pedPartition);
        partition.partitionNumber = pedPartition->num;
        partition.sector_start = pedPartition->geom.start;
        partition.sector_end = pedPartition->geom.end;

        // Get partition path
        partition.path = Utils::charToStringFree(ped_partition_get_path(pedPartition)); // we have to free the result of ped_partition_get_path()
        if (partition.path.isEmpty())
            partition.path = "Partition path not found";


        switch (pedPartition->type) {
            case PED_PARTITION_LOGICAL:
                partition.insideExtended = true;

            case PED_PARTITION_NORMAL:
                partition.type = pedPartition->type == 0 ?	MParted::TYPE_PRIMARY : MParted::TYPE_LOGICAL;
                partition.filesystem = getFilesystem(pedPartition);

                // Find filesystem class and set used sectors, label and uuid
                for (int i = 0; i < filesystems.size(); i++) {
                    MParted::Filesystem *fs = filesystems[i];

                    if (fs->getFilesystemType() != partition.filesystem)
                        continue;

                    fs->setUsedSectors(partition);
                    fs->readLabel(partition);
                    fs->readUUID(partition);
                    break;
                }

                break ;
            case PED_PARTITION_EXTENDED:
                partition.type = MParted::TYPE_EXTENDED;
                partition.filesystem = MParted::FS_EXTENDED;

                break ;
            default:
                continue;
        }

        // Add partition to list
        if (partition.type == MParted::TYPE_LOGICAL && extendedPartition != NULL)
            extendedPartition->logicals.append(partition);
        else
            device.partitions.append(partition);

        // Save pointer of extended partition, if it is one
        if (partition.type == MParted::TYPE_EXTENDED)
            extendedPartition = &device.partitions.last();
    }

    // Update unallocated space
    UnallocatedUtils::updateUnallocated(device);
}