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.
This commit is contained in:
parent
458c5c89e7
commit
b60eb39594
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=2810
@ -452,11 +452,10 @@ struct stat st;
|
|||||||
fprintf(stderr, "%s: Can't get file status of %s\n",
|
fprintf(stderr, "%s: Can't get file status of %s\n",
|
||||||
name, disk);
|
name, disk);
|
||||||
return -1;
|
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",
|
fprintf(stderr,"%s: Device %s is not character special\n",
|
||||||
name, disk);
|
name, disk);
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if ((fd = open(disk, u_flag?O_RDWR:O_RDONLY)) == -1) {
|
if ((fd = open(disk, u_flag?O_RDWR:O_RDONLY)) == -1) {
|
||||||
fprintf(stderr,"%s: Can't open device %s\n", name, disk);
|
fprintf(stderr,"%s: Can't open device %s\n", name, disk);
|
||||||
return -1;
|
return -1;
|
||||||
@ -486,7 +485,15 @@ get_params(verbose)
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
|
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;
|
dos_cyls = cyls = disklabel.d_ncylinders;
|
||||||
|
@ -452,11 +452,10 @@ struct stat st;
|
|||||||
fprintf(stderr, "%s: Can't get file status of %s\n",
|
fprintf(stderr, "%s: Can't get file status of %s\n",
|
||||||
name, disk);
|
name, disk);
|
||||||
return -1;
|
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",
|
fprintf(stderr,"%s: Device %s is not character special\n",
|
||||||
name, disk);
|
name, disk);
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if ((fd = open(disk, u_flag?O_RDWR:O_RDONLY)) == -1) {
|
if ((fd = open(disk, u_flag?O_RDWR:O_RDONLY)) == -1) {
|
||||||
fprintf(stderr,"%s: Can't open device %s\n", name, disk);
|
fprintf(stderr,"%s: Can't open device %s\n", name, disk);
|
||||||
return -1;
|
return -1;
|
||||||
@ -486,7 +485,15 @@ get_params(verbose)
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (ioctl(fd, DIOCGDINFO, &disklabel) == -1) {
|
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;
|
dos_cyls = cyls = disklabel.d_ncylinders;
|
||||||
|
Loading…
Reference in New Issue
Block a user