summaryrefslogtreecommitdiffstats
path: root/sbin/fdisk_pc98
diff options
context:
space:
mode:
authornyan <nyan@FreeBSD.org>2005-05-01 05:04:05 +0000
committernyan <nyan@FreeBSD.org>2005-05-01 05:04:05 +0000
commit09a70338b7c55bbade2bb9361c51fe9a81bc601a (patch)
treef557a4754957b0283886f54c4f64a709726e76db /sbin/fdisk_pc98
parentfa2fcbedc1aeeab07a47a833fb481458d0049b9b (diff)
downloadFreeBSD-src-09a70338b7c55bbade2bb9361c51fe9a81bc601a.zip
FreeBSD-src-09a70338b7c55bbade2bb9361c51fe9a81bc601a.tar.gz
Merged more changes from fdisk/fdisk.c.
Diffstat (limited to 'sbin/fdisk_pc98')
-rw-r--r--sbin/fdisk_pc98/fdisk.c33
1 files changed, 7 insertions, 26 deletions
diff --git a/sbin/fdisk_pc98/fdisk.c b/sbin/fdisk_pc98/fdisk.c
index b90a473..1737f1e 100644
--- a/sbin/fdisk_pc98/fdisk.c
+++ b/sbin/fdisk_pc98/fdisk.c
@@ -24,10 +24,8 @@
* the rights to redistribute these changes.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
#include <sys/disk.h>
#include <sys/disklabel.h>
@@ -810,8 +808,8 @@ static int
open_disk(int flag)
{
struct stat st;
- int rwmode, i;
- char buf[MAXPATHLEN];
+ int rwmode, p;
+ char *s;
fdw = -1;
if (stat(disk, &st) == -1) {
@@ -824,25 +822,9 @@ open_disk(int flag)
warnx("device %s is not character special", disk);
#ifdef PC98
rwmode = a_flag || B_flag || flag ? O_RDWR : O_RDONLY;
- fd = open(disk, rwmode);
- if (fd == -1 && errno == ENXIO)
- return -2;
- if (fd == -1 && errno == EPERM && rwmode == O_RDWR) {
- fd = open(disk, O_RDONLY);
- if (fd == -1)
- return -3;
- for (i = 0; i < NDOSPART; i++) {
- snprintf(buf, sizeof(buf), "%ss%d", disk, i + 1);
- fdw = open(buf, rwmode);
- if (fdw == -1)
- continue;
- break;
- }
- if (fdw == -1)
- return -4;
- }
#else
rwmode = a_flag || I_flag || B_flag || flag ? O_RDWR : O_RDONLY;
+#endif
fd = open(disk, rwmode);
if (fd == -1 && errno == ENXIO)
return -2;
@@ -850,8 +832,8 @@ open_disk(int flag)
fd = open(disk, O_RDONLY);
if (fd == -1)
return -3;
- for (p = 1; p < 5; p++) {
- asprintf(&s, "%ss%d", disk, p);
+ for (p = 0; p < NDOSPART; p++) {
+ asprintf(&s, "%ss%d", disk, p + 1);
fdw = open(s, rwmode);
free(s);
if (fdw == -1)
@@ -861,7 +843,6 @@ open_disk(int flag)
if (fdw == -1)
return -4;
}
-#endif
if (fd == -1) {
warnx("can't open device %s", disk);
return -1;
OpenPOWER on IntegriCloud