summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Reindl <martin@cvs.openbsd.org>2006-04-29 00:43:42 +0000
committerMartin Reindl <martin@cvs.openbsd.org>2006-04-29 00:43:42 +0000
commit8ac9fb4b6c1cc6109dc775de04f45a936214658d (patch)
treeac11af7bf96bc7f95653f033846501a15b73f68c
parentfd3f0a642065cad1f17911968d816570db48a488 (diff)
With last pdisk and full functionality for mac68k now in place, start
cleaning the maze of ifdef's not relevant for us. This round wipes most linux and/or MacOS-only bits, more to come.
-rw-r--r--sbin/pdisk/dump.c5
-rw-r--r--sbin/pdisk/errors.c2
-rw-r--r--sbin/pdisk/file_media.c53
-rw-r--r--sbin/pdisk/hfs_misc.c4
-rw-r--r--sbin/pdisk/io.c6
-rw-r--r--sbin/pdisk/media.c6
-rw-r--r--sbin/pdisk/partition_map.c19
-rw-r--r--sbin/pdisk/pathname.c105
-rw-r--r--sbin/pdisk/pdisk.c69
-rw-r--r--sbin/pdisk/util.c23
-rw-r--r--sbin/pdisk/util.h3
-rw-r--r--sbin/pdisk/validate.c4
12 files changed, 3 insertions, 296 deletions
diff --git a/sbin/pdisk/dump.c b/sbin/pdisk/dump.c
index d5b25cd22a4..8d330cf74e5 100644
--- a/sbin/pdisk/dump.c
+++ b/sbin/pdisk/dump.c
@@ -29,12 +29,7 @@
#include <stdio.h>
// for malloc() & free()
-#ifndef __linux__
#include <stdlib.h>
-//#include <unistd.h>
-#else
-#include <malloc.h>
-#endif
// for strcmp()
#include <string.h>
diff --git a/sbin/pdisk/errors.c b/sbin/pdisk/errors.c
index 257e95fd179..d4441613dee 100644
--- a/sbin/pdisk/errors.c
+++ b/sbin/pdisk/errors.c
@@ -30,9 +30,7 @@
#include <errno.h>
// for exit()
-#ifndef __linux__
#include <stdlib.h>
-#endif
// for strrchr
#include <string.h>
diff --git a/sbin/pdisk/file_media.c b/sbin/pdisk/file_media.c
index f516fe60ff5..2041477d85c 100644
--- a/sbin/pdisk/file_media.c
+++ b/sbin/pdisk/file_media.c
@@ -38,17 +38,8 @@
// for errno
#include <errno.h>
-#ifdef __linux__
-#include <sys/ioctl.h>
-#include <linux/fs.h>
-#include <linux/hdreg.h>
-#include <sys/stat.h>
-#else
-#ifdef __unix__
#include <sys/ioctl.h>
#include <sys/stat.h>
-#endif
-#endif
#include "file_media.h"
#include "errors.h"
@@ -220,11 +211,6 @@ open_file_as_media(char *file, int oflag)
a->m.kind = file_info.kind;
a->m.grain = compute_block_size(fd);
off = llseek(fd, (loff_t)0, SEEK_END); /* seek to end of media */
-#if !defined(__linux__) && !defined(__unix__)
- if (off <= 0) {
- off = 1; /* XXX not right? */
- }
-#endif
//printf("file size = %Ld\n", off);
a->m.size_in_bytes = (long long) off;
a->m.do_read = read_file_media;
@@ -300,7 +286,7 @@ write_file_media(MEDIA m, long long offset, unsigned long count, void *address)
long rtn_value;
loff_t off;
int t;
-
+
a = (FILE_MEDIA) m;
rtn_value = 0;
if (a == 0) {
@@ -352,11 +338,7 @@ os_reload_file_media(MEDIA m)
{
FILE_MEDIA a;
long rtn_value;
-#if defined(__linux__)
- int i;
- int saved_errno;
-#endif
-
+
a = (FILE_MEDIA) m;
rtn_value = 0;
if (a == 0) {
@@ -367,43 +349,12 @@ os_reload_file_media(MEDIA m)
/* okay - nothing to do */
rtn_value = 1;
} else {
-#ifdef __linux__
- sync();
- sleep(2);
- if ((i = ioctl(a->fd, BLKRRPART)) != 0) {
- saved_errno = errno;
- } else {
- // some kernel versions (1.2.x) seem to have trouble
- // rereading the partition table, but if asked to do it
- // twice, the second time works. - biro@yggdrasil.com */
- sync();
- sleep(2);
- if ((i = ioctl(a->fd, BLKRRPART)) != 0) {
- saved_errno = errno;
- }
- }
-
- // printf("Syncing disks.\n");
- sync();
- sleep(4); /* for sync() */
-
- if (i < 0) {
- error(saved_errno, "Re-read of partition table failed");
- printf("Reboot your system to ensure the "
- "partition table is updated.\n");
- }
-#endif
rtn_value = 1;
}
return rtn_value;
}
-#if !defined(__linux__) && !defined(__unix__)
-#pragma mark -
-#endif
-
-
FILE_MEDIA_ITERATOR
new_file_iterator(void)
{
diff --git a/sbin/pdisk/hfs_misc.c b/sbin/pdisk/hfs_misc.c
index f87ce52c4cc..594ed7f9714 100644
--- a/sbin/pdisk/hfs_misc.c
+++ b/sbin/pdisk/hfs_misc.c
@@ -12,11 +12,7 @@
#include <stdio.h>
// for malloc(), calloc() & free()
-#ifndef __linux__
#include <stdlib.h>
-#else
-#include <malloc.h>
-#endif
// for strncpy() & strcmp()
#include <string.h>
diff --git a/sbin/pdisk/io.c b/sbin/pdisk/io.c
index 00b9640a08a..806f84a6959 100644
--- a/sbin/pdisk/io.c
+++ b/sbin/pdisk/io.c
@@ -29,11 +29,7 @@
#include <stdio.h>
// for malloc() & free()
-#if !defined(__linux__)
#include <stdlib.h>
-#else
-#include <malloc.h>
-#endif
// for strncpy()
#include <string.h>
// for va_start(), etc.
@@ -51,7 +47,6 @@
#define BAD_DIGIT 17 /* must be greater than any base */
#define STRING_CHUNK 16
#define UNGET_MAX_COUNT 10
-#ifndef __linux__
#ifndef __unix__
#define SCSI_FD 8
#endif
@@ -62,7 +57,6 @@
#define loff_t long
#define llseek lseek
#endif
-#endif
//
diff --git a/sbin/pdisk/media.c b/sbin/pdisk/media.c
index 31b999d22cd..183d991df71 100644
--- a/sbin/pdisk/media.c
+++ b/sbin/pdisk/media.c
@@ -166,12 +166,6 @@ os_reload_media(MEDIA m)
}
-#if !defined(__linux__) && !defined(__unix__)
-#pragma mark -
-#endif
-
-
-
MEDIA_ITERATOR
new_media_iterator(long size)
{
diff --git a/sbin/pdisk/partition_map.c b/sbin/pdisk/partition_map.c
index bddff40ee83..f28abc2ce7d 100644
--- a/sbin/pdisk/partition_map.c
+++ b/sbin/pdisk/partition_map.c
@@ -29,11 +29,7 @@
#include <stdio.h>
// for malloc(), calloc() & free()
-#ifndef __linux__
#include <stdlib.h>
-#else
-#include <malloc.h>
-#endif
// for strncpy() & strcmp()
#include <string.h>
@@ -350,21 +346,6 @@ write_partition_map(partition_map_header *map)
}
}
-#ifdef __linux__
- // zap the block after the map (if possible) to get around a bug.
- if (map->maximum_in_map > 0 && i < map->maximum_in_map) {
- i += 1;
- block = (char *) malloc(PBLOCK_SIZE);
- if (block != NULL) {
- if (read_block(map, i, block)) {
- block[0] = 0;
- write_block(map, i, block);
- }
- free(block);
- }
- }
-#endif
-
if (interactive)
printf("The partition table has been altered!\n\n");
diff --git a/sbin/pdisk/pathname.c b/sbin/pdisk/pathname.c
index 16d2bd73003..5dab3587397 100644
--- a/sbin/pdisk/pathname.c
+++ b/sbin/pdisk/pathname.c
@@ -69,68 +69,8 @@ MEDIA
open_pathname_as_media(char *path, int oflag)
{
MEDIA m = 0;
-#if !defined(__linux__) && !defined(__unix__)
- long id;
- long bus;
-
- if (strncmp("/dev/", path, 5) == 0) {
- if (strncmp("/dev/scsi", path, 9) == 0) {
- if (path[9] >= '0' && path[9] <= '7' && path[10] == 0) {
- // scsi[0-7]
- id = path[9] - '0';
- m = open_old_scsi_as_media(id);
- } else if (path[9] >= '0' && path[9] <= '7' && path[10] == '.'
- && path[11] >= '0' && path[11] <= '7' && path[12] == 0) {
- // scsi[0-7].[0-7]
- id = path[11] - '0';
- bus = path[9] - '0';
- m = open_scsi_as_media(bus, id);
- }
- } else if (strncmp("/dev/ata", path, 8) == 0
- || strncmp("/dev/ide", path, 8) == 0) {
- if (path[8] >= '0' && path[8] <= '7' && path[9] == 0) {
- // ata[0-7], ide[0-7]
- bus = path[8] - '0';
- m = open_ata_as_media(bus, 0);
- } else if (path[8] >= '0' && path[8] <= '7' && path[9] == '.'
- && path[10] >= '0' && path[10] <= '1' && path[11] == 0) {
- // ata[0-7].[0-1], ide[0-7].[0-1]
- id = path[10] - '0';
- bus = path[8] - '0';
- m = open_ata_as_media(bus, id);
- }
- } else if (strncmp("/dev/sd", path, 7) == 0) {
- if (path[7] >= 'a' && path[7] <= 'z' && path[8] == 0) {
- // sd[a-z]
- id = path[7] - 'a';
- m = open_linux_scsi_as_media(id, 0);
- } else if (path[7] >= 'a' && path[7] <= 'z' && path[8] == '.'
- && path[9] >= 'a' && path[9] <= 'z' && path[10] == 0) {
- // sd[a-z][a-z]
- bus = path[7] - 'a';
- id = path[9] - 'a';
- id += bus * 26;
- m = open_linux_scsi_as_media(id, 0);
- }
- } else if (strncmp("/dev/scd", path, 8) == 0) {
- if (path[8] >= '0' && path[8] <= '9' && path[9] == 0) {
- // scd[0-9]
- id = path[8] - '0';
- m = open_linux_scsi_as_media(id, 1);
- }
- } else if (strncmp("/dev/hd", path, 7) == 0) {
- if (path[7] >= 'a' && path[7] <= 'z' && path[8] == 0) {
- // hd[a-z]
- id = path[7] - 'a';
- m = open_linux_ata_as_media(id);
- }
- }
- } else
-#endif
- {
- m = open_file_as_media(path, oflag);
- }
+ m = open_file_as_media(path, oflag);
return m;
}
@@ -139,43 +79,6 @@ char *
get_linux_name(char *path)
{
char *result = 0;
-#if !defined(__linux__) && !defined(__unix__)
- long id;
- long bus;
-
- if (strncmp("/dev/", path, 5) == 0) {
- if (strncmp("/dev/scsi", path, 9) == 0) {
- if (path[9] >= '0' && path[9] <= '7' && path[10] == 0) {
- /* old scsi */
- // scsi[0-7]
- id = path[9] - '0';
- result = linux_old_scsi_name(id);
- } else if (path[9] >= '0' && path[9] <= '7' && path[10] == '.'
- && path[11] >= '0' && path[11] <= '7' && path[12] == 0) {
- /* new scsi */
- // scsi[0-7].[0-7]
- id = path[11] - '0';
- bus = path[9] - '0';
- result = linux_scsi_name(bus, id);
- }
- } else if (strncmp("/dev/ata", path, 8) == 0
- || strncmp("/dev/ide", path, 8) == 0) {
- if (path[8] >= '0' && path[8] <= '7' && path[9] == 0) {
- /* ata/ide - master device */
- // ata[0-7], ide[0-7]
- bus = path[8] - '0';
- result = linux_ata_name(bus, 0);
- } else if (path[8] >= '0' && path[8] <= '7' && path[9] == '.'
- && path[10] >= '0' && path[10] <= '1' && path[11] == 0) {
- /* ata/ide */
- // ata[0-7].[0-1], ide[0-7].[0-1]
- id = path[10] - '0';
- bus = path[8] - '0';
- result = linux_ata_name(bus, id);
- }
- }
- }
-#endif
return result;
}
@@ -210,9 +113,6 @@ next_media_kind(long *state)
/* fall through to next interface */
case 1:
-#if !defined(__linux__) && !defined(__unix__)
- result = create_ata_iterator();
-#endif
ix = 2;
if (result != 0) {
break;
@@ -220,9 +120,6 @@ next_media_kind(long *state)
/* fall through to next interface */
case 2:
-#if !defined(__linux__) && !defined(__unix__)
- result = create_scsi_iterator();
-#endif
ix = 3;
if (result != 0) {
break;
diff --git a/sbin/pdisk/pdisk.c b/sbin/pdisk/pdisk.c
index c8cbafb772c..83092d21917 100644
--- a/sbin/pdisk/pdisk.c
+++ b/sbin/pdisk/pdisk.c
@@ -33,16 +33,8 @@
#if defined(__linux__) || defined(__OpenBSD__)
#include <getopt.h>
#endif
-#ifdef __linux__
-#include <malloc.h>
-#else
// for malloc() & free()
#include <stdlib.h>
-#if !defined(__unix__)
-// for SIOUXsettings
-#include <SIOUX.h>
-#endif
-#endif
#ifdef __unix__
#include <unistd.h>
@@ -55,12 +47,6 @@
// for errno
#include <errno.h>
-#ifdef __linux__
-#include <sys/ioctl.h>
-#include <linux/fs.h>
-#include <linux/hdreg.h>
-#endif
-
#include "pdisk.h"
#include "io.h"
#include "partition_map.h"
@@ -143,9 +129,6 @@ int get_options(int argc, char **argv);
void interact(void);
void print_edit_notes(void);
void print_expert_notes(void);
-#ifdef __linux__
-void print_top_notes(void);
-#endif
//
@@ -206,12 +189,8 @@ main(int argc, char **argv)
dump(argv[name_index++]);
}
} else {
-#ifdef __linux__
- list_all_disks();
-#else
usage("no device argument");
do_help();
-#endif
}
} else if (name_index < argc) {
while (name_index < argc) {
@@ -234,21 +213,6 @@ main(int argc, char **argv)
}
-#ifdef __linux__
-void
-print_top_notes()
-{
- printf("Notes:\n");
- printf(" Disks have fake names of the form /dev/scsi<bus>.<id>\n");
- printf(" For example, /dev/scsi0.1, /dev/scsi1.3, and so on.\n");
- printf(" Linux style names are also allowed (i.e /dev/sda or /dev/hda).\n");
- printf(" Due to some technical problems these names may not match\n");
- printf(" the 'real' linux names.\n");
- printf("\n");
-}
-#endif
-
-
void
interact()
{
@@ -262,9 +226,6 @@ interact()
switch (command) {
case '?':
-#ifdef __linux__
- print_top_notes();
-#endif
// fall through
case 'H':
case 'h':
@@ -272,9 +233,6 @@ interact()
printf(" h print help\n");
printf(" v print the version number and release date\n");
printf(" l list device's map\n");
-#ifdef __linux__
- printf(" L list all devices' maps\n");
-#endif
printf(" e edit device's map\n");
printf(" E (edit map with specified block size)\n");
printf(" r toggle readonly flag\n");
@@ -296,11 +254,6 @@ interact()
case 'v':
printf("version " VERSION " (" RELEASE_DATE ")\n");
break;
-#ifdef __linux__
- case 'L':
- list_all_disks();
- break;
-#endif
case 'l':
if (get_string_argument("Name of device: ", &name, 1) == 0) {
bad_input("Bad name");
@@ -549,12 +502,6 @@ edit(char *name, int ask_logical_size)
printf("Edit %s -\n", name);
-#if 0 /* this check is not found in linux fdisk-0.1 */
- if (map != NULL && map->blocks_in_map > MAX_LINUX_MAP) {
- error(-1, "Map contains more than %d blocks - Linux may have trouble", MAX_LINUX_MAP);
- }
-#endif
-
while (get_command("Command (? for help): ", first_get, &command)) {
first_get = 0;
order = 1;
@@ -711,12 +658,6 @@ do_create_partition(partition_map_header *map, int get_type)
}
if (get_type == 0) {
add_partition_to_map(name, kUnixType, base, length, map);
-#if 0 /* this check is not found in linux fdisk-0.1 */
- if (map->blocks_in_map > MAX_LINUX_MAP) {
- error(-1, "Map contains more than %d blocks - Linux may have trouble", MAX_LINUX_MAP);
- }
- goto xit1;
-#endif
} else if (get_string_argument("Type of partition: ", &type_name, 1) == 0) {
bad_input("Bad type");
goto xit1;
@@ -730,11 +671,6 @@ do_create_partition(partition_map_header *map, int get_type)
goto xit2;
}
add_partition_to_map(name, type_name, base, length, map);
-#if 0 /* this check is not found in linux fdisk-0.1 */
- if (map->blocks_in_map > MAX_LINUX_MAP) {
- error(-1, "Map contains more than %d blocks - Linux may have trouble", MAX_LINUX_MAP);
- }
-#endif
}
#ifdef __m68k__
do_update_dpme(find_entry_by_base(base,map));
@@ -957,11 +893,6 @@ do_write_partition_map(partition_map_header *map)
bad_input("The map is not writable.");
return;
}
-#if 0 /* this check is not found in linux fdisk-0.1 */
- if (map->blocks_in_map > MAX_LINUX_MAP) {
- error(-1, "Map contains more than %d blocks - Linux may have trouble", MAX_LINUX_MAP);
- }
-#endif
printf("Writing the map destroys what was there before. ");
if (get_okay("Is that okay? [n/y]: ", 0) != 1) {
return;
diff --git a/sbin/pdisk/util.c b/sbin/pdisk/util.c
index be983546a03..fc43c750c89 100644
--- a/sbin/pdisk/util.c
+++ b/sbin/pdisk/util.c
@@ -78,29 +78,6 @@ clear_memory(void *dataPtr, unsigned long size)
}
-#if !defined(__linux__) && !defined(__unix__)
-/* (see Inside Mac VI 3-8) */
-int
-TrapAvailable(short theTrap)
-{
- TrapType trapType;
-
- trapType = GetTrapType(theTrap);
-
- if (trapType == ToolTrap) {
- theTrap &= 0x07FF;
- if (theTrap >= NumToolboxTraps())
- theTrap = _Unimplemented;
- }
-
- return (
- NGetTrapAddress(theTrap, trapType)
- != NGetTrapAddress(_Unimplemented, ToolTrap)
- );
-}
-#endif
-
-
/* Ascii case-insensitive string comparison */
int
istrncmp(const char *x, const char *y, long len)
diff --git a/sbin/pdisk/util.h b/sbin/pdisk/util.h
index b0569f2b9a4..93c2234bd3b 100644
--- a/sbin/pdisk/util.h
+++ b/sbin/pdisk/util.h
@@ -53,9 +53,6 @@
* Forward declarations
*/
void clear_memory(void *dataPtr, unsigned long size);
-#if !defined(__linux__) && !defined(__unix__)
-int TrapAvailable(short theTrap);
-#endif
int istrncmp(const char *x, const char *y, long len);
const char *get_version_string(void);
diff --git a/sbin/pdisk/validate.c b/sbin/pdisk/validate.c
index e25165f9408..1bf05672ca9 100644
--- a/sbin/pdisk/validate.c
+++ b/sbin/pdisk/validate.c
@@ -29,11 +29,7 @@
// for *printf()
#include <stdio.h>
// for malloc(), free()
-#ifndef __linux__
#include <stdlib.h>
-#else
-#include <malloc.h>
-#endif
// for O_RDONLY
#include <fcntl.h>
// for errno