aboutsummaryrefslogtreecommitdiff
path: root/sbin/fdisk/fdisk.c
diff options
context:
space:
mode:
authorBruce Evans <bde@FreeBSD.org>1994-09-15 20:19:51 +0000
committerBruce Evans <bde@FreeBSD.org>1994-09-15 20:19:51 +0000
commitb60eb39594edad8415871dd887a946622b33a60b (patch)
tree003422fc84def86ed88e6f7e0a32e51666128156 /sbin/fdisk/fdisk.c
parent458c5c89e756152b4ef8ef7312e43bad1ef0ca62 (diff)
downloadsrc-b60eb39594edad8415871dd887a946622b33a60b.tar.gz
src-b60eb39594edad8415871dd887a946622b33a60b.zip
Don't exit early if the device is not character special or if the
device driver cannot supply a label (real or faked). This allows you to practice using fdisk on disposable media (e.g., "dd count=1 <dev/zero >/tmp/junk; fdisk /tmp/junk", "dd count=1 </etc/passwd >/tmp/fix-up-the-mess; fdisk /tmp/fix-up-the-mess") and allows me to test DOSpartitioning and labelling on floppies.
Notes
Notes: svn path=/head/; revision=2810
Diffstat (limited to 'sbin/fdisk/fdisk.c')
-rw-r--r--sbin/fdisk/fdisk.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c
index 7fb728d67d20..933906056f9f 100644
--- a/sbin/fdisk/fdisk.c
+++ b/sbin/fdisk/fdisk.c
@@ -452,11 +452,10 @@ struct stat st;
fprintf(stderr, "%s: Can't get file status of %s\n",
name, disk);
return -1;
- } else if ( !(st.st_mode & S_IFCHR) ) {
+ }
+ if ( !(st.st_mode & S_IFCHR) )
fprintf(stderr,"%s: Device %s is not character special\n",
name, disk);
- return -1;
- }
if ((fd = open(disk, u_flag?O_RDWR:O_RDONLY)) == -1) {
fprintf(stderr,"%s: Can't open device %s\n", name, disk);
return -1;
@@ -486,7 +485,15 @@ get_params(verbose)
{
if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
- return -1;
+ fprintf(stderr,
+ "%s: Can't get disk parameters on %s; supplying dummy ones\n",
+ name, disk);
+ dos_cyls = cyls = 1;
+ dos_heads = heads = 1;
+ dos_sectors = sectors = 1;
+ dos_cylsecs = cylsecs = heads * sectors;
+ disksecs = cyls * heads * sectors;
+ return disksecs;
}
dos_cyls = cyls = disklabel.d_ncylinders;