# include <linux/blkpg.h>
#endif
-int nowarn = 0; /* no warnings for fdisk -l/-s */
-
static void __attribute__ ((__noreturn__)) usage(FILE *out)
{
fputs(USAGE_HEADER, out);
" be used with one specified device\n"));
if (optl) {
- nowarn = 1;
+ fdisk_context_enable_listonly(cxt, 1);
if (argc > optind) {
int k;
for (k = optind; k < argc; k++)
extern void toggle_dos_compatibility_flag(struct fdisk_context *cxt);
extern void warn_limits(struct fdisk_context *cxt);
-extern int nowarn;
-
/*
- * Many, many hands.
- * Specific DOS label file - Davidlohr Bueso <dave@gnu.org>
+ *
+ * Copyright (C) 2013 Karel Zak <kzak@redhat.com>
+ *
+ * This is re-written version for libfdisk, the original was fdiskdoslabel.c
+ * from util-linux fdisk.
*/
-
-#include <unistd.h>
-#include <ctype.h>
-
#include "c.h"
#include "nls.h"
#include "randutils.h"
#include "common.h"
#include "pt-mbr.h"
-#include "fdisk.h"
+#include "fdiskP.h"
+
#include "fdiskdoslabel.h"
#define MAXIMUM_PARTS 60
static void warn_alignment(struct fdisk_context *cxt)
{
- if (nowarn)
+ if (fdisk_context_listonly(cxt))
return;
if (cxt->sector_size != cxt->phy_sector_size)
warn_geometry(cxt);
warn_alignment(cxt);
- if (cxt->total_sectors > UINT_MAX && !nowarn) {
+ if (cxt->total_sectors > UINT_MAX && !fdisk_context_listonly(cxt)) {
unsigned long long bytes = cxt->total_sectors * cxt->sector_size;
int giga = bytes / 1000000000;
int hectogiga = (giga + 50) / 100;
return cxt->display_details == 1;
}
+/**
+ * fdisk_context_enable_listonly:
+ * cxt: context
+ * enable: true/flase
+ *
+ * Just list partition only, don't care about another details, mistakes, ...
+ *
+ * Returns: 0 on success, < 0 on error.
+ */
+int fdisk_context_enable_listonly(struct fdisk_context *cxt, int enable)
+{
+ assert(cxt);
+ cxt->listonly = enable ? 1 : 0;
+ return 0;
+}
+
+int fdisk_context_listonly(struct fdisk_context *cxt)
+{
+ assert(cxt);
+ return cxt->listonly == 1;
+}
+
+
/*
* @str: "cylinder" or "sector".
*
unsigned long alignment_offset;
unsigned int display_in_cyl_units : 1, /* for obscure labels */
- display_details : 1; /* expert display mode */
+ display_details : 1, /* expert display mode */
+ listonly : 1; /* list partition, nothing else */
/* alignment */
unsigned long grain; /* alignment unit */
extern int fdisk_context_use_cylinders(struct fdisk_context *cxt);
extern int fdisk_context_display_details(struct fdisk_context *cxt);
+extern int fdisk_context_enable_listonly(struct fdisk_context *cxt, int enable);
+extern int fdisk_context_listonly(struct fdisk_context *cxt);
/* alignment.c */