fdisks/fdiskmaclabel.h \
fdisks/fdisksgilabel.c \
fdisks/fdisksgilabel.h \
- fdisks/fdisksunlabel.c \
- fdisks/fdisksunlabel.h \
fdisks/partname.c \
fdisks/common.h
#include "strutils.h"
#include "closestream.h"
-#include "fdisksunlabel.h"
+#include "pt-sun.h" /* to toggle flags */
#include "fdisksgilabel.h"
#include "fdiskmaclabel.h"
#include "fdiskdoslabel.h"
fdisk_verify_disklabel(cxt);
}
-void print_partition_size(struct fdisk_context *cxt,
- int num, sector_t start, sector_t stop, int sysid)
-{
- char *str = size_to_human_string(SIZE_SUFFIX_3LETTER | SIZE_SUFFIX_SPACE,
- (uint64_t)(stop - start + 1) * cxt->sector_size);
- struct fdisk_parttype *t = fdisk_get_parttype_from_code(cxt, sysid);
-
- printf(_("Partition %d of type %s and of size %s is set\n"),
- num, t ? t->name : _("Unknown"), str);
- free(str);
-}
-
static void new_partition(struct fdisk_context *cxt)
{
assert(cxt);
unsigned int low, unsigned int dflt,
unsigned int high, unsigned int base, char *mesg);
extern void print_menu(struct fdisk_context *cxt, enum menutype menu);
-extern void print_partition_size(struct fdisk_context *cxt, int num, sector_t start, sector_t stop, int sysid);
extern char *partition_type(struct fdisk_context *cxt, unsigned char type);
extern char read_chars(struct fdisk_context *cxt, char *mesg);
unsigned int low, unsigned int dflt, unsigned int high,
unsigned int base, char *mesg, int *is_suffix_used);
-#define PLURAL 0
-#define SINGULAR 1
-
extern sector_t get_nr_sects(struct partition *p);
extern int nowarn;
set_start_sect(p, start - offset);
set_nr_sects(p, stop - start + 1);
- if (!doext)
- print_partition_size(cxt, i + 1, start, stop, sysid);
-
+ if (!doext) {
+ struct fdisk_parttype *t = fdisk_get_parttype_from_code(cxt, sysid);
+ fdisk_info_new_partition(cxt, i + 1, start, stop, t);
+ }
if (is_dos_compatible(cxt) && (start/(cxt->geom.sectors*cxt->geom.heads) > 1023))
start = cxt->geom.heads*cxt->geom.sectors*1024 - 1;
set_hsc(p->head, p->sector, p->cyl, start);
if (sgi_gaps(cxt) < 0) /* rebuild freelist */
printf(_("Partition overlap on the disk.\n"));
- if (length)
- print_partition_size(cxt, i + 1, start, start + length, sys);
+ if (length) {
+ struct fdisk_parttype *t = fdisk_get_parttype_from_code(cxt, sys);
+ fdisk_info_new_partition(cxt, i + 1, start, start + length, t);
+ }
return 0;
}
+++ /dev/null
-#ifndef FDISK_SUN_LABEL_H
-#define FDISK_SUN_LABEL_H
-
-#include "pt-sun.h"
-
-/* public SUN specific functions (TODO: move to libfdisk.h) */
-extern void fdisk_sun_set_alt_cyl(struct fdisk_context *cxt);
-extern void fdisk_sun_set_ncyl(struct fdisk_context *cxt, int cyl);
-extern void fdisk_sun_set_xcyl(struct fdisk_context *cxt);
-extern void fdisk_sun_set_ilfact(struct fdisk_context *cxt);
-extern void fdisk_sun_set_rspeed(struct fdisk_context *cxt);
-extern void fdisk_sun_set_pcylcount(struct fdisk_context *cxt);
-
-#endif /* FDISK_SUN_LABEL_H */
libfdisk/src/utils.c \
libfdisk/src/context.c \
libfdisk/src/parttype.c \
+ \
+ libfdisk/src/sun.c \
libfdisk/src/gpt.c
return rc;
}
+int fdisk_info_new_partition(
+ struct fdisk_context *cxt,
+ int num, sector_t start, sector_t stop,
+ struct fdisk_parttype *t)
+{
+ int rc;
+ char *str = size_to_human_string(SIZE_SUFFIX_3LETTER | SIZE_SUFFIX_SPACE,
+ (uint64_t)(stop - start + 1) * cxt->sector_size);
+
+ rc = fdisk_info(cxt, _("Partition %d of type %s and of size %s is set\n"),
+ num, t ? t->name : _("Unknown"), str);
+ free(str);
+ return rc;
+}
+
#ifdef TEST_PROGRAM
struct fdisk_label *fdisk_new_dos_label(struct fdisk_context *cxt) { return NULL; }
struct fdisk_label *fdisk_new_bsd_label(struct fdisk_context *cxt) { return NULL; }
extern void fdisk_deinit_label(struct fdisk_label *lb);
-/* gpt.c -- temporary bypass library API... */
-extern void gpt_list_table(struct fdisk_context *cxt, int xtra);
-
/* ask.c */
extern int fdisk_ask_partnum(struct fdisk_context *cxt, size_t *partnum, int wantnew);
extern struct tt *fdisk_ask_get_table(struct fdisk_ask *ask);
extern int fdisk_print_table(struct fdisk_context *cxt, struct tt *tb);
+extern int fdisk_info_new_partition(
+ struct fdisk_context *cxt,
+ int num, sector_t start, sector_t stop,
+ struct fdisk_parttype *t);
+
+/* sun.h */
+extern void fdisk_sun_set_alt_cyl(struct fdisk_context *cxt);
+extern void fdisk_sun_set_ncyl(struct fdisk_context *cxt, int cyl);
+extern void fdisk_sun_set_xcyl(struct fdisk_context *cxt);
+extern void fdisk_sun_set_ilfact(struct fdisk_context *cxt);
+extern void fdisk_sun_set_rspeed(struct fdisk_context *cxt);
+extern void fdisk_sun_set_pcylcount(struct fdisk_context *cxt);
+
+
#endif /* _LIBFDISK_PRIVATE_H */
const char *name);
extern int fdisk_context_set_unit(struct fdisk_context *cxt, const char *str);
+
+#define PLURAL 0
+#define SINGULAR 1
extern const char *fdisk_context_get_unit(struct fdisk_context *cxt, int n);
+
extern unsigned int fdisk_context_get_units_per_sector(struct fdisk_context *cxt);
extern int fdisk_context_enable_details(struct fdisk_context *cxt, int enable);
/*
- * fdisksunlabel.c
+ * Copyright (C) 2013 Karel Zak <kzak@redhat.com>
*
- * I think this is mostly, or entirely, due to
- * Jakub Jelinek (jj@sunsite.mff.cuni.cz), July 1996
- *
- * Merged with fdisk for other architectures, aeb, June 1998.
- *
- * Sat Mar 20 EST 1999 Arnaldo Carvalho de Melo <acme@conectiva.com.br>
- * Internationalization
+ * Based on original code from fdisk:
+ * Jakub Jelinek (jj@sunsite.mff.cuni.cz), July 1996
+ * Merged with fdisk for other architectures, aeb, June 1998.
+ * Arnaldo Carvalho de Melo <acme@conectiva.com.br> Mar 1999, Internationalization
*/
-
#include <stdio.h> /* stderr */
#include <stdlib.h> /* qsort */
#include <string.h> /* strstr */
#include "blkdev.h"
#include "bitops.h"
-#include "common.h"
-#include "fdisk.h"
-#include "fdiskdoslabel.h"
-#include "fdisksunlabel.h"
+#include "fdiskP.h"
+#include "pt-sun.h"
+#include "all-io.h"
/*
* in-memory fdisk SUN stuff
uint32_t start,uint32_t stop, uint16_t sysid)
{
struct sun_disklabel *sunlabel = self_disklabel(cxt);
+ struct fdisk_parttype *t = fdisk_get_parttype_from_code(cxt, sysid);
sunlabel->vtoc.infos[i].id = cpu_to_be16(sysid);
sunlabel->vtoc.infos[i].flags = cpu_to_be16(0);
cpu_to_be32(start / (cxt->geom.heads * cxt->geom.sectors));
sunlabel->partitions[i].num_sectors = cpu_to_be32(stop - start);
fdisk_label_set_changed(cxt->label, 1);
- print_partition_size(cxt, i + 1, start, stop, sysid);
+
+ fdisk_info_new_partition(cxt, i + 1, start, stop, t);
}
static size_t count_used_partitions(struct fdisk_context *cxt)
struct sun_disklabel *sunlabel;
unsigned short *ush;
unsigned short csum = 0;
+ const size_t sz = sizeof(struct sun_disklabel);
assert(cxt);
assert(cxt->label);
sunlabel->csum = csum;
if (lseek(cxt->dev_fd, 0, SEEK_SET) < 0)
return -errno;
- if (write(cxt->dev_fd, sunlabel, SECTOR_SIZE) != SECTOR_SIZE)
+ if (write_all(cxt->dev_fd, sunlabel, sz) != 0)
return -errno;
return 0;