static PedConstraint* _primary_constraint (PedDisk* disk) { PedAlignment start_align; PedAlignment end_align; PedGeometry max_geom; PedSector sector_size; LinuxSpecific* arch_specific; DasdDiskSpecific* disk_specific; PedSector start; PDEBUG; arch_specific = LINUX_SPECIFIC (disk->dev); disk_specific = disk->disk_specific; sector_size = arch_specific->real_sector_size / disk->dev->sector_size; if (!ped_alignment_init (&start_align, 0, disk->dev->hw_geom.sectors * sector_size)) return NULL; if (!ped_alignment_init (&end_align, -1, disk->dev->hw_geom.sectors * sector_size)) return NULL; start = (FIRST_USABLE_TRK * (long long) disk->dev->hw_geom.sectors * (long long) arch_specific->real_sector_size / (long long) disk->dev->sector_size); if (!ped_geometry_init (&max_geom, disk->dev, start, disk->dev->length)) return NULL; return ped_constraint_new(&start_align, &end_align, &max_geom, &max_geom, 1, disk->dev->length); }
/** * Return a constraint that only the given region will satisfy. */ PedConstraint* ped_constraint_exact (const PedGeometry* geom) { PedAlignment start_align; PedAlignment end_align; PedGeometry start_sector; PedGeometry end_sector; int ok; /* With grain size of 0, it always succeeds. */ ok = ped_alignment_init (&start_align, geom->start, 0); assert (ok); ok = ped_alignment_init (&end_align, geom->end, 0); assert (ok); ok = ped_geometry_init (&start_sector, geom->dev, geom->start, 1); if (!ok) return NULL; ok = ped_geometry_init (&end_sector, geom->dev, geom->end, 1); if (!ok) return NULL; return ped_constraint_new (&start_align, &end_align, &start_sector, &end_sector, 1, geom->dev->length); }
static PedConstraint *reiserfs_get_resize_constraint(const PedFileSystem * fs) { PedDevice *dev; PedSector min_size; PedGeometry full_disk; reiserfs_fs_t *fs_info; PedAlignment start_align; PedGeometry start_sector; PED_ASSERT(fs != NULL); fs_info = fs->type_specific; dev = fs->geom->dev; if (!ped_alignment_init(&start_align, fs->geom->start, 0)) return NULL; if (!ped_geometry_init(&full_disk, dev, 0, dev->length - 1)) return NULL; if (!ped_geometry_init(&start_sector, dev, fs->geom->start, 1)) return NULL; /* Minsize for reiserfs is area occupied by data blocks and metadata blocks minus free space blocks and minus bitmap blocks which describes free space blocks. */ min_size = reiserfs_fs_min_size(fs_info) * (reiserfs_fs_block_size(fs_info) / PED_SECTOR_SIZE_DEFAULT); return ped_constraint_new(&start_align, ped_alignment_any, &start_sector, &full_disk, min_size, dev->length); }
/** * Return a constraint that only the given region will satisfy. */ PedConstraint* ped_constraint_exact (const PedGeometry* geom) { PedAlignment start_align; PedAlignment end_align; PedGeometry start_sector; PedGeometry end_sector; ped_alignment_init (&start_align, geom->start, 0); ped_alignment_init (&end_align, geom->end, 0); ped_geometry_init (&start_sector, geom->dev, geom->start, 1); ped_geometry_init (&end_sector, geom->dev, geom->end, 1); return ped_constraint_new (&start_align, &end_align, &start_sector, &end_sector, 1, geom->dev->length); }
static PedConstraint* _amiga_get_constraint (const PedDisk *disk) { PedDevice *dev = disk->dev; PedAlignment start_align, end_align; PedGeometry max_geom; PedSector cyl_size = dev->hw_geom.sectors * dev->hw_geom.heads; if (!ped_alignment_init(&start_align, 0, cyl_size)) return NULL; if (!ped_alignment_init(&end_align, -1, cyl_size)) return NULL; if (!ped_geometry_init(&max_geom, dev, MAX_RDB_BLOCK + 1, dev->length - MAX_RDB_BLOCK - 1)) return NULL; return ped_constraint_new (&start_align, &end_align, &max_geom, &max_geom, 1, dev->length); }
static PedConstraint* _primary_constraint (PedDisk* disk) { PedDevice* dev = disk->dev; PedAlignment start_align; PedAlignment end_align; PedGeometry max_geom; PedSector cylinder_size; cylinder_size = dev->hw_geom.sectors * dev->hw_geom.heads; if (!ped_alignment_init (&start_align, 0, cylinder_size)) return NULL; if (!ped_alignment_init (&end_align, -1, cylinder_size)) return NULL; if (!ped_geometry_init (&max_geom, dev, cylinder_size, dev->length - cylinder_size)) return NULL; return ped_constraint_new (&start_align, &end_align, &max_geom, &max_geom, 1, dev->length); }
PedConstraint * hfsplus_get_resize_constraint (const PedFileSystem *fs) { PedDevice* dev = fs->geom->dev; PedAlignment start_align; PedGeometry start_sector; PedGeometry full_dev; PedSector min_size; if (!ped_alignment_init (&start_align, fs->geom->start, 0)) return NULL; if (!ped_geometry_init (&start_sector, dev, fs->geom->start, 1)) return NULL; if (!ped_geometry_init (&full_dev, dev, 0, dev->length - 1)) return NULL; min_size = hfsplus_get_min_size (fs); if (!min_size) return NULL; return ped_constraint_new (&start_align, ped_alignment_any, &start_sector, &full_dev, min_size, fs->geom->length); }
PedConstraint * hfs_get_resize_constraint (const PedFileSystem *fs) { PedDevice* dev = fs->geom->dev; PedAlignment start_align; PedGeometry start_sector; PedGeometry full_dev; PedSector min_size; if (!ped_alignment_init (&start_align, fs->geom->start, 0)) return NULL; if (!ped_geometry_init (&start_sector, dev, fs->geom->start, 1)) return NULL; if (!ped_geometry_init (&full_dev, dev, 0, dev->length - 1)) return NULL; /* 2 = last two sectors (alternate MDB and unused sector) */ min_size = hfs_get_empty_end(fs) + 2; if (min_size == 2) return NULL; return ped_constraint_new (&start_align, ped_alignment_any, &start_sector, &full_dev, min_size, fs->geom->length); }