summaryrefslogtreecommitdiffstats
path: root/fdisks/fdisk.c
diff options
context:
space:
mode:
authorKarel Zak2013-08-30 13:06:15 +0200
committerKarel Zak2013-09-16 16:47:08 +0200
commit6bcd192c7bc79539d80399be842cd68701955bf6 (patch)
tree49e41e68c2ece4cdacf7410d040d305500e80cd2 /fdisks/fdisk.c
parentfdisk: cleanup header file (diff)
downloadkernel-qcow2-util-linux-6bcd192c7bc79539d80399be842cd68701955bf6.tar.gz
kernel-qcow2-util-linux-6bcd192c7bc79539d80399be842cd68701955bf6.tar.xz
kernel-qcow2-util-linux-6bcd192c7bc79539d80399be842cd68701955bf6.zip
libfdisk: add fdisk_has_user_device_properties()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisks/fdisk.c')
-rw-r--r--fdisks/fdisk.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c
index a71815b04..92bacf623 100644
--- a/fdisks/fdisk.c
+++ b/fdisks/fdisk.c
@@ -348,7 +348,6 @@ static sector_t get_dev_blocks(char *dev)
int main(int argc, char **argv)
{
int c, optl = 0, opts = 0;
- unsigned long sector_size = 0;
struct fdisk_context *cxt;
struct fdisk_label *lb;
@@ -367,16 +366,14 @@ int main(int argc, char **argv)
while ((c = getopt(argc, argv, "b:c::C:hH:lsS:u::vV")) != -1) {
switch (c) {
case 'b':
- /* Ugly: this sector size is really per device,
- so cannot be combined with multiple disks,
- and te same goes for the C/H/S options.
- */
- sector_size = strtou32_or_err(optarg, _("invalid sector size argument"));
- if (sector_size != 512 && sector_size != 1024 &&
- sector_size != 2048 && sector_size != 4096)
+ {
+ size_t sz = strtou32_or_err(optarg,
+ _("invalid sector size argument"));
+ if (sz != 512 && sz != 1024 && sz != 2048 && sz != 4096)
usage(stderr);
- fdisk_save_user_sector_size(cxt, sector_size, sector_size);
+ fdisk_save_user_sector_size(cxt, sz, sz);
break;
+ }
case 'C':
fdisk_save_user_geometry(cxt,
strtou32_or_err(optarg,
@@ -434,9 +431,9 @@ int main(int argc, char **argv)
}
- if (sector_size && argc-optind != 1)
- printf(_("Warning: the -b (set sector size) option should"
- " be used with one specified device\n"));
+ if (argc-optind != 1 && fdisk_has_user_device_properties(cxt))
+ warnx(_("The device properties (sector size and geometry) should"
+ " be used with one specified device only."));
if (optl) {
fdisk_context_enable_listonly(cxt, 1);