From 3d1523b6002ddc063892ba1439f68c8035832603 Mon Sep 17 00:00:00 2001 From: pooka Date: Thu, 17 Dec 2009 14:27:49 +0000 Subject: [PATCH] Use implicit -F for regular files, much like disklabel(8). --- sbin/fdisk/fdisk.8 | 9 +++++++-- sbin/fdisk/fdisk.c | 7 +++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/sbin/fdisk/fdisk.8 b/sbin/fdisk/fdisk.8 index 9604cd981d08..8d9b7bf205bc 100644 --- a/sbin/fdisk/fdisk.8 +++ b/sbin/fdisk/fdisk.8 @@ -1,6 +1,6 @@ -.\" $NetBSD: fdisk.8,v 1.67 2009/12/05 16:29:11 pooka Exp $ +.\" $NetBSD: fdisk.8,v 1.68 2009/12/17 14:27:49 pooka Exp $ .\" -.Dd November 28, 2009 +.Dd December 17, 2009 .Dt FDISK 8 .Os .Sh NAME @@ -242,6 +242,11 @@ by will count the 512-byte sectors in .Ar device and produce a fake geometry. +If +.Ar device +is a regular file, +.Fl F +will be used implicitly. .It Fl i Explicitly request initialisation of the master boot code (similar to what diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c index b27e543cceef..0ff12b2186f3 100644 --- a/sbin/fdisk/fdisk.c +++ b/sbin/fdisk/fdisk.c @@ -1,4 +1,4 @@ -/* $NetBSD: fdisk.c,v 1.125 2009/11/04 22:25:56 dsl Exp $ */ +/* $NetBSD: fdisk.c,v 1.126 2009/12/17 14:27:49 pooka Exp $ */ /* * Mach Operating System @@ -39,7 +39,7 @@ #include #ifndef lint -__RCSID("$NetBSD: fdisk.c,v 1.125 2009/11/04 22:25:56 dsl Exp $"); +__RCSID("$NetBSD: fdisk.c,v 1.126 2009/12/17 14:27:49 pooka Exp $"); #endif /* not lint */ #define MBRPTYPENAMES @@ -438,6 +438,9 @@ main(int argc, char *argv[]) initvar_disk(&disk); } + if (!F_flag && stat(disk, &sb) == 0 && S_ISREG(sb.st_mode)) + F_flag = 1; + if (open_disk(B_flag || a_flag || i_flag || u_flag) < 0) exit(1);