fdisk: remove nowarn global variable
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
f8ad389986
commit
c10937dcaf
|
@ -47,8 +47,6 @@
|
||||||
# include <linux/blkpg.h>
|
# include <linux/blkpg.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int nowarn = 0; /* no warnings for fdisk -l/-s */
|
|
||||||
|
|
||||||
static void __attribute__ ((__noreturn__)) usage(FILE *out)
|
static void __attribute__ ((__noreturn__)) usage(FILE *out)
|
||||||
{
|
{
|
||||||
fputs(USAGE_HEADER, out);
|
fputs(USAGE_HEADER, out);
|
||||||
|
@ -716,7 +714,7 @@ int main(int argc, char **argv)
|
||||||
" be used with one specified device\n"));
|
" be used with one specified device\n"));
|
||||||
|
|
||||||
if (optl) {
|
if (optl) {
|
||||||
nowarn = 1;
|
fdisk_context_enable_listonly(cxt, 1);
|
||||||
if (argc > optind) {
|
if (argc > optind) {
|
||||||
int k;
|
int k;
|
||||||
for (k = optind; k < argc; k++)
|
for (k = optind; k < argc; k++)
|
||||||
|
|
|
@ -40,5 +40,3 @@ extern int warn_geometry(struct fdisk_context *cxt);
|
||||||
extern void toggle_dos_compatibility_flag(struct fdisk_context *cxt);
|
extern void toggle_dos_compatibility_flag(struct fdisk_context *cxt);
|
||||||
extern void warn_limits(struct fdisk_context *cxt);
|
extern void warn_limits(struct fdisk_context *cxt);
|
||||||
|
|
||||||
extern int nowarn;
|
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
/*
|
/*
|
||||||
* 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 "c.h"
|
||||||
#include "nls.h"
|
#include "nls.h"
|
||||||
#include "randutils.h"
|
#include "randutils.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "pt-mbr.h"
|
#include "pt-mbr.h"
|
||||||
|
|
||||||
#include "fdisk.h"
|
#include "fdiskP.h"
|
||||||
|
|
||||||
#include "fdiskdoslabel.h"
|
#include "fdiskdoslabel.h"
|
||||||
|
|
||||||
#define MAXIMUM_PARTS 60
|
#define MAXIMUM_PARTS 60
|
||||||
|
@ -147,7 +147,7 @@ static int is_cleared_partition(struct dos_partition *p)
|
||||||
|
|
||||||
static void warn_alignment(struct fdisk_context *cxt)
|
static void warn_alignment(struct fdisk_context *cxt)
|
||||||
{
|
{
|
||||||
if (nowarn)
|
if (fdisk_context_listonly(cxt))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (cxt->sector_size != cxt->phy_sector_size)
|
if (cxt->sector_size != cxt->phy_sector_size)
|
||||||
|
@ -269,7 +269,7 @@ static void dos_init(struct fdisk_context *cxt)
|
||||||
warn_geometry(cxt);
|
warn_geometry(cxt);
|
||||||
warn_alignment(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;
|
unsigned long long bytes = cxt->total_sectors * cxt->sector_size;
|
||||||
int giga = bytes / 1000000000;
|
int giga = bytes / 1000000000;
|
||||||
int hectogiga = (giga + 50) / 100;
|
int hectogiga = (giga + 50) / 100;
|
||||||
|
|
|
@ -255,6 +255,29 @@ int fdisk_context_display_details(struct fdisk_context *cxt)
|
||||||
return cxt->display_details == 1;
|
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".
|
* @str: "cylinder" or "sector".
|
||||||
*
|
*
|
||||||
|
|
|
@ -269,7 +269,8 @@ struct fdisk_context {
|
||||||
unsigned long alignment_offset;
|
unsigned long alignment_offset;
|
||||||
|
|
||||||
unsigned int display_in_cyl_units : 1, /* for obscure labels */
|
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 */
|
/* alignment */
|
||||||
unsigned long grain; /* alignment unit */
|
unsigned long grain; /* alignment unit */
|
||||||
|
@ -302,6 +303,8 @@ extern int __fdisk_context_switch_label(struct fdisk_context *cxt,
|
||||||
|
|
||||||
extern int fdisk_context_use_cylinders(struct fdisk_context *cxt);
|
extern int fdisk_context_use_cylinders(struct fdisk_context *cxt);
|
||||||
extern int fdisk_context_display_details(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 */
|
/* alignment.c */
|
||||||
|
|
Loading…
Reference in New Issue