PowerPC support.
submitted by: Suleiman Souhlal <refugee@segfaulted.com> approved by: phk, jhb
This commit is contained in:
parent
4173466ca4
commit
a76af532c5
@ -76,6 +76,15 @@ Find_Mother_Chunk(struct chunk *chunks, daddr_t offset, daddr_t end,
|
||||
return c2;
|
||||
}
|
||||
return 0;
|
||||
#ifdef __powerpc__
|
||||
case apple:
|
||||
for (c1 = chunks->part; c1; c1 = c1->next) {
|
||||
if (c1->type == type)
|
||||
if (Chunk_Inside(c1, &ct))
|
||||
return c1;
|
||||
}
|
||||
return 0;
|
||||
#endif
|
||||
default:
|
||||
warn("Unsupported mother type in Find_Mother_Chunk");
|
||||
return 0;
|
||||
@ -150,7 +159,7 @@ Insert_Chunk(struct chunk *c2, daddr_t offset, daddr_t size, const char *name,
|
||||
return __LINE__;
|
||||
}
|
||||
|
||||
if (type == freebsd || type == extended) {
|
||||
if ((type == freebsd || type == extended || type == apple)) {
|
||||
cs = New_Chunk();
|
||||
if (cs == NULL)
|
||||
return __LINE__;
|
||||
@ -303,6 +312,18 @@ Add_Chunk(struct disk *d, daddr_t offset, daddr_t size, const char *name,
|
||||
return(-1);
|
||||
}
|
||||
break;
|
||||
case p_ppc:
|
||||
switch (type) {
|
||||
case apple:
|
||||
c1 = Find_Mother_Chunk(d->chunks, offset, end, whole);
|
||||
break;
|
||||
case part:
|
||||
c1 = Find_Mother_Chunk(d->chunks, offset, end, apple);
|
||||
break;
|
||||
default:
|
||||
return (-1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return (-1);
|
||||
}
|
||||
@ -438,6 +459,11 @@ Delete_Chunk2(struct disk *d, struct chunk *c, int rflags)
|
||||
if (c1 == NULL)
|
||||
c1 = Find_Mother_Chunk(d->chunks, c->offset, c->end,
|
||||
whole);
|
||||
#endif
|
||||
#ifdef __powerpc__
|
||||
if (c1 == NULL)
|
||||
c1 = Find_Mother_Chunk(d->chunks, c->offset, c->end,
|
||||
apple);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
|
@ -134,6 +134,24 @@ Fixup_Extended_Names(struct chunk *c)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __powerpc__
|
||||
static int
|
||||
Fixup_Apple_Names(struct chunk *c)
|
||||
{
|
||||
struct chunk *c1;
|
||||
|
||||
for (c1 = c->part; c1; c1 = c1->next) {
|
||||
if (c1->type == unused)
|
||||
continue;
|
||||
free(c1->name);
|
||||
c1->name = strdup(c->name);
|
||||
if (!c1->name)
|
||||
return (-1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int
|
||||
Fixup_Names(struct disk *d)
|
||||
{
|
||||
@ -185,6 +203,10 @@ Fixup_Names(struct disk *d)
|
||||
for (c2 = c1->part; c2; c2 = c2->next) {
|
||||
if (c2->type == freebsd)
|
||||
Fixup_FreeBSD_Names(c2);
|
||||
#ifdef __powerpc__
|
||||
else if (c2->type == apple)
|
||||
Fixup_Apple_Names(c2);
|
||||
#endif
|
||||
#ifndef PC98
|
||||
else if (c2->type == extended)
|
||||
Fixup_Extended_Names(c2);
|
||||
@ -238,7 +260,8 @@ Create_Chunk_DWIM(struct disk *d, struct chunk *parent, daddr_t size,
|
||||
if (!parent)
|
||||
parent = d->chunks;
|
||||
|
||||
if (parent->type == freebsd && type == part && parent->part == NULL) {
|
||||
if ((parent->type == freebsd && type == part && parent->part == NULL)
|
||||
|| (parent->type == apple && type == part && parent->part == NULL)) {
|
||||
c1 = New_Chunk();
|
||||
if (c1 == NULL)
|
||||
return (NULL);
|
||||
|
@ -69,6 +69,7 @@ chunk_name(chunk_e type)
|
||||
case fat: return ("fat");
|
||||
case spare: return ("spare");
|
||||
case efi: return ("efi");
|
||||
case apple: return ("apple");
|
||||
default: return ("??");
|
||||
}
|
||||
};
|
||||
|
@ -47,7 +47,9 @@ typedef enum {
|
||||
extended,
|
||||
part,
|
||||
spare,
|
||||
unused
|
||||
unused,
|
||||
|
||||
apple
|
||||
} chunk_e;
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
@ -128,6 +128,8 @@ Int_Open_Disk(const char *name, char *conftxt)
|
||||
lo[0] = 0;
|
||||
|
||||
for (; p != NULL && *p; p = q) {
|
||||
if (sn)
|
||||
sn = NULL;
|
||||
q = strchr(p, '\n');
|
||||
if (q != NULL)
|
||||
*q++ = '\0';
|
||||
@ -164,7 +166,8 @@ Int_Open_Disk(const char *name, char *conftxt)
|
||||
}
|
||||
b = strsep(&p, " ");
|
||||
o = strtoimax(b, &r, 0);
|
||||
if (*r) {
|
||||
/* APPLE have ty as a string */
|
||||
if ((*r) && strcmp(t, "APPLE")) {
|
||||
printf("BARF %d <%d>\n", __LINE__, *r);
|
||||
exit (0);
|
||||
}
|
||||
@ -258,6 +261,8 @@ Int_Open_Disk(const char *name, char *conftxt)
|
||||
; /* nothing */
|
||||
else if (!strcmp(t, "CCD"))
|
||||
; /* nothing */
|
||||
else if (!strcmp(t, "APPLE"))
|
||||
i = Add_Chunk(d, off, len, n, apple, 0, 0, sn);
|
||||
else {
|
||||
printf("BARF %d\n", __LINE__);
|
||||
exit(0);
|
||||
|
64
lib/libdisk/write_powerpc_disk.c
Normal file
64
lib/libdisk/write_powerpc_disk.c
Normal file
@ -0,0 +1,64 @@
|
||||
/*-
|
||||
* Copyright (c) 2004 Suleiman Souhlal.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <err.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/disklabel.h>
|
||||
#include <paths.h>
|
||||
#include "libdisk.h"
|
||||
|
||||
int
|
||||
Write_Disk(const struct disk *d1)
|
||||
{
|
||||
/*
|
||||
* We don't have to write any label, so we only check that we can
|
||||
* open the disk.
|
||||
*/
|
||||
int fd;
|
||||
char device[64];
|
||||
|
||||
strcpy(device, _PATH_DEV);
|
||||
strcat(device, d1->name);
|
||||
|
||||
fd = open(device, O_RDWR);
|
||||
if (fd < 0) {
|
||||
close(fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user