fputc('\n', stdout);
/* print warnings */
- while (itr && fdisk_table_next_partition(tb, itr, &pa) == 0)
- fdisk_warn_alignment(cxt, fdisk_partition_get_start(pa),
+ while (itr && fdisk_table_next_partition(tb, itr, &pa) == 0) {
+ if (!fdisk_lba_is_phy_aligned(cxt, fdisk_partition_get_start(pa)))
+ fdisk_warnx(cxt, _("Partition %zu does not start on physical sector boundary."),
fdisk_partition_get_partno(pa) + 1);
+ }
if (fdisk_table_wrong_order(tb))
fdisk_info(cxt, _("Partition table entries are not in disk order."));
return !((granularity + cxt->alignment_offset - offset) & (granularity - 1));
}
-/*
- * Align @lba in @direction FDISK_ALIGN_{UP,DOWN,NEAREST}
+/**
+ * fdisk_align_lba:
+ * @cxt: context
+ * @lba: address to align
+ * @direction: FDISK_ALIGN_{UP,DOWN,NEAREST}
+ *
+ * Returns: alignment LBA.
*/
sector_t fdisk_align_lba(struct fdisk_context *cxt, sector_t lba, int direction)
{
return res;
}
-/*
+/**
+ * fdisk_align_lba_in_range:
+ * @cxt: context
+ * @lba: LBA
+ * @start: range start
+ * @stop: range stop
+ *
* Align @lba, the result has to be between @start and @stop
+ *
+ * Returns: aligned LBA
*/
sector_t fdisk_align_lba_in_range(struct fdisk_context *cxt,
sector_t lba, sector_t start, sector_t stop)
return lba;
}
-/*
- * Print warning if the partition @lba (start of the @partition) is not
- * aligned to physical sector boundary.
+/**
+ * fdisk_lba_is_phy_aligned:
+ * @cxt: context
+ * @lba: LBA to check
+ *
+ * Check if the @lba is aligned.
+ *
+ * Returns: 1 if aligned.
*/
-void fdisk_warn_alignment(struct fdisk_context *cxt, sector_t lba, int partition)
+int fdisk_lba_is_phy_aligned(struct fdisk_context *cxt, sector_t lba)
{
- if (!lba_is_phy_aligned(cxt, lba))
- fdisk_warnx(cxt, _("Partition %i does not start on physical sector boundary.\n"),
- partition + 1);
+ return lba_is_phy_aligned(cxt, lba);
}
static unsigned long get_sector_size(int fd)
return 0;
}
+/**
+ * fdisk_save_user_geometry:
+ * @cxt: context
+ * @cylinders: C
+ * @head: H
+ * @sector: S
+ *
+ * Save user defined geometry to use it for partitioning.
+ *
+ * Returns: <0 on error, 0 on success.
+ */
int fdisk_save_user_geometry(struct fdisk_context *cxt,
unsigned int cylinders,
unsigned int heads,
return 0;
}
+/**
+ * fdisk_save_user_sector_size:
+ * @cxt: context
+ * @phy: physical sector size
+ * @log: logicla sector size
+ *
+ * Save user defined sector sizes to use it for partitioning.
+ *
+ * Returns: <0 on error, 0 on success.
+ */
int fdisk_save_user_sector_size(struct fdisk_context *cxt,
unsigned int phy,
unsigned int log)
return 0;
}
+/**
+ * fdisk_has_user_device_properties:
+ * @cxt: context
+ *
+ * Returns: 1 if user specified any properties
+ */
int fdisk_has_user_device_properties(struct fdisk_context *cxt)
{
return (cxt->user_pyh_sector
*
* Returns: 0 on error or number of logical sectors.
*/
-sector_t fdisk_topology_get_first_lba(struct fdisk_context *cxt)
+static sector_t topology_get_first_lba(struct fdisk_context *cxt)
{
sector_t x = 0, res;
*
* Returns: 0 on error or number of bytes.
*/
-unsigned long fdisk_topology_get_grain(struct fdisk_context *cxt)
+static unsigned long topology_get_grain(struct fdisk_context *cxt)
{
unsigned long res;
DBG(CXT, ul_debugobj(cxt, "reseting alignment..."));
/* default */
- cxt->grain = fdisk_topology_get_grain(cxt);
- cxt->first_lba = fdisk_topology_get_first_lba(cxt);
+ cxt->grain = topology_get_grain(cxt);
+ cxt->first_lba = topology_get_first_lba(cxt);
cxt->last_lba = cxt->total_sectors - 1;
/* overwrite default by label stuff */
(num / fdisk_get_units_per_sector(cxt)) + 1 : num;
}
+/**
+ * fdisk_reread_partition_table:
+ * @cxt: context
+ *
+ * Force *system kernel* to re-read partition table.
+ */
int fdisk_reread_partition_table(struct fdisk_context *cxt)
{
int i;
*
* Returns: first possible LBA on disk for data partitions.
*/
-unsigned long fdisk_get_first_lba(struct fdisk_context *cxt)
+sector_t fdisk_get_first_lba(struct fdisk_context *cxt)
{
assert(cxt);
return cxt->first_lba;
*
* Returns: size of the device in (real) sectors.
*/
-unsigned long fdisk_get_nsectors(struct fdisk_context *cxt)
+sector_t fdisk_get_nsectors(struct fdisk_context *cxt)
{
assert(cxt);
return cxt->total_sectors;
p = self_partition(cxt, i);
if (is_used_partition(p) && !IS_EXTENDED(p->sys_ind)) {
check_consistency(cxt, p, i);
- fdisk_warn_alignment(cxt, get_abs_partition_start(pe), i);
if (get_abs_partition_start(pe) < first[i])
fdisk_warnx(cxt, _(
"Partition %zu: bad start-of-data."),
#endif
-typedef unsigned long long sector_t;
-
-
/*
* Generic iterator
*/
struct fdisk_label *lb);
/* alignment.c */
-extern sector_t fdisk_scround(struct fdisk_context *cxt, sector_t num);
-extern sector_t fdisk_cround(struct fdisk_context *cxt, sector_t num);
-
-extern sector_t fdisk_topology_get_first_lba(struct fdisk_context *cxt);
-extern unsigned long fdisk_topology_get_grain(struct fdisk_context *cxt);
-
-extern void fdisk_warn_alignment(struct fdisk_context *cxt,
- sector_t lba, int partition);
-
-
-#define FDISK_ALIGN_UP 1
-#define FDISK_ALIGN_DOWN 2
-#define FDISK_ALIGN_NEAREST 3
-
-extern sector_t fdisk_align_lba(struct fdisk_context *cxt, sector_t lba, int direction);
-extern sector_t fdisk_align_lba_in_range(struct fdisk_context *cxt, sector_t lba,
- sector_t start, sector_t stop);
-
-
-extern int fdisk_override_geometry(struct fdisk_context *cxt,
- unsigned int cylinders, unsigned int heads,
- unsigned int sectors);
+sector_t fdisk_scround(struct fdisk_context *cxt, sector_t num);
+sector_t fdisk_cround(struct fdisk_context *cxt, sector_t num);
+int fdisk_reset_device_properties(struct fdisk_context *cxt);
extern int fdisk_discover_geometry(struct fdisk_context *cxt);
extern int fdisk_discover_topology(struct fdisk_context *cxt);
struct fdisk_table;
struct fdisk_field;
+typedef unsigned long long sector_t;
+
/*
* Supported partition table types (labels)
*/
unsigned long fdisk_get_sector_size(struct fdisk_context *cxt);
unsigned long fdisk_get_alignment_offset(struct fdisk_context *cxt);
unsigned long fdisk_get_grain_size(struct fdisk_context *cxt);
-unsigned long fdisk_get_first_lba(struct fdisk_context *cxt);
-unsigned long fdisk_get_nsectors(struct fdisk_context *cxt);
+sector_t fdisk_get_first_lba(struct fdisk_context *cxt);
+sector_t fdisk_get_nsectors(struct fdisk_context *cxt);
const char *fdisk_get_devname(struct fdisk_context *cxt);
/* parttype.c */
size_t n);
/* alignment.c */
-extern int fdisk_reset_alignment(struct fdisk_context *cxt);
-extern int fdisk_reset_device_properties(struct fdisk_context *cxt);
+#define FDISK_ALIGN_UP 1
+#define FDISK_ALIGN_DOWN 2
+#define FDISK_ALIGN_NEAREST 3
+
+sector_t fdisk_align_lba(struct fdisk_context *cxt, sector_t lba, int direction);
+sector_t fdisk_align_lba_in_range(struct fdisk_context *cxt,
+ sector_t lba, sector_t start, sector_t stop);
+int fdisk_lba_is_phy_aligned(struct fdisk_context *cxt, sector_t lba);
-extern int fdisk_save_user_geometry(struct fdisk_context *cxt,
+int fdisk_override_geometry(struct fdisk_context *cxt,
unsigned int cylinders,
unsigned int heads,
unsigned int sectors);
-
-extern int fdisk_save_user_sector_size(struct fdisk_context *cxt,
+int fdisk_save_user_geometry(struct fdisk_context *cxt,
+ unsigned int cylinders,
+ unsigned int heads,
+ unsigned int sectors);
+int fdisk_save_user_sector_size(struct fdisk_context *cxt,
unsigned int phy,
unsigned int log);
-
-extern int fdisk_has_user_device_properties(struct fdisk_context *cxt);
-
-extern int fdisk_reread_partition_table(struct fdisk_context *cxt);
+int fdisk_has_user_device_properties(struct fdisk_context *cxt);
+int fdisk_reset_alignment(struct fdisk_context *cxt);
+int fdisk_reread_partition_table(struct fdisk_context *cxt);
/* iter.c */
enum {