summaryrefslogtreecommitdiff
path: root/sbin/fdisk/disk.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-10-19 23:29:39 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-10-19 23:29:39 +0000
commitb1cde0eec4935fd55bc897a58a62e6051bfad4b5 (patch)
tree8e37ae48d60f0fd227071d2b0e3d0888279fbaf7 /sbin/fdisk/disk.c
parent2d7e6d16f81ec181aa182685b9d5508f89219c17 (diff)
indent
Diffstat (limited to 'sbin/fdisk/disk.c')
-rw-r--r--sbin/fdisk/disk.c45
1 files changed, 22 insertions, 23 deletions
diff --git a/sbin/fdisk/disk.c b/sbin/fdisk/disk.c
index 0fcced3170a..7c3a9b2b962 100644
--- a/sbin/fdisk/disk.c
+++ b/sbin/fdisk/disk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disk.c,v 1.4 1997/10/16 01:47:09 deraadt Exp $ */
+/* $OpenBSD: disk.c,v 1.5 1997/10/19 23:29:36 deraadt Exp $ */
/*
* Copyright (c) 1997 Tobias Weingartner
@@ -48,7 +48,6 @@
#endif
#include "disk.h"
-
int
DISK_open(disk, mode)
char *disk;
@@ -58,12 +57,12 @@ DISK_open(disk, mode)
struct stat st;
fd = opendev(disk, mode, OPENDEV_PART, NULL);
- if(fd < 0) err(1, "%s", disk);
- if(fstat(fd, &st) < 0) err(1, "%s", disk);
-
- if(!S_ISCHR(st.st_mode) && !S_ISREG(st.st_mode))
+ if (fd < 0)
+ err(1, "%s", disk);
+ if (fstat(fd, &st) < 0)
+ err(1, "%s", disk);
+ if (!S_ISCHR(st.st_mode) && !S_ISREG(st.st_mode))
err(1, "%s is not a character device or a regular file", disk);
-
return(fd);
}
@@ -89,14 +88,14 @@ DISK_getlabelmetrics(name)
int fd;
/* Get label metrics */
- if((fd = DISK_open(name, O_RDONLY)) >= 0){
+ if ((fd = DISK_open(name, O_RDONLY)) >= 0) {
lm = malloc(sizeof(DISK_metrics));
- if(ioctl(fd, DIOCGDINFO, &dl) < 0){
+ if (ioctl(fd, DIOCGDINFO, &dl) < 0) {
warn("DIOCGDINFO");
free(lm);
lm = NULL;
- }else{
+ } else {
lm->cylinders = dl.d_ncylinders;
lm->heads = dl.d_ntracks;
lm->sectors = dl.d_nsectors;
@@ -131,7 +130,7 @@ DISK_getbiosmetrics(name)
mib[2] = BIOS_DEV;
size = sizeof(biosdev);
- if(sysctl(mib, 3, &biosdev, &size, NULL, 0) < 0){
+ if (sysctl(mib, 3, &biosdev, &size, NULL, 0) < 0) {
warn("sysctl");
return (NULL);
}
@@ -139,7 +138,7 @@ DISK_getbiosmetrics(name)
mib[2] = BIOS_GEOMETRY;
size = sizeof(biosgeo);
- if(sysctl(mib, 3, &biosgeo, &size, NULL, 0) < 0){
+ if (sysctl(mib, 3, &biosgeo, &size, NULL, 0) < 0) {
warn("sysctl");
return (NULL);
}
@@ -184,18 +183,18 @@ DISK_getmetrics(disk, user)
disk->bios = DISK_getbiosmetrics(disk->name);
/* If user supplied, use that */
- if(user){
+ if (user) {
disk->real = user;
- return(0);
+ return (0);
}
/* If we have a label, use that */
- if(!disk->real && disk->label)
+ if (!disk->real && disk->label)
disk->real = disk->label;
/* Can not get geometry, punt */
- if(disk->real == NULL)
- return(1);
+ if (disk->real == NULL)
+ return (1);
/* If we have a bios, use that (if label looks bogus)
*
@@ -204,12 +203,12 @@ DISK_getmetrics(disk, user)
* It needs to be, at least, a BSD device.
* Or we need a mapping from biosdev -> BSD universe.
*/
- if(disk->bios)
- if(disk->real->cylinders > 1024 || disk->real->heads > 255
- || disk->real->sectors > 63)
+ if (disk->bios)
+ if (disk->real->cylinders > 1024 || disk->real->heads > 255 ||
+ disk->real->sectors > 63)
disk->real = disk->bios;
- return(0);
+ return (0);
}
int
@@ -218,9 +217,9 @@ DISK_printmetrics(disk)
{
printf("Disk: %s\t", disk->name);
- if(disk->real)
+ if (disk->real)
printf("geometry: %d/%d/%d [%d sectors]\n", disk->real->cylinders,
- disk->real->heads, disk->real->sectors, disk->real->size);
+ disk->real->heads, disk->real->sectors, disk->real->size);
else
printf("geometry: <none>\n");