diff options
author | Jeremy Katz <katzj@redhat.com> | 2002-10-23 16:40:35 +0000 |
---|---|---|
committer | Jeremy Katz <katzj@redhat.com> | 2002-10-23 16:40:35 +0000 |
commit | ab76ae268d8b78cad2f71908770e4b967e29ed37 (patch) | |
tree | f153fdfb3e99c6e075f47628172a7d9beb63c502 | |
parent | 28a42efbdbc9bcf42a4b749b4636664dd3fa7ccd (diff) | |
download | anaconda-ab76ae268d8b78cad2f71908770e4b967e29ed37.tar.gz anaconda-ab76ae268d8b78cad2f71908770e4b967e29ed37.tar.xz anaconda-ab76ae268d8b78cad2f71908770e4b967e29ed37.zip |
* build with diet on ppc
* support for determining smp for pSeries and mac
patches from dan burcaw (dburcaw@terrasoftsolutions.com)
-rw-r--r-- | isys/Makefile | 6 | ||||
-rw-r--r-- | isys/minifind.c | 79 | ||||
-rw-r--r-- | isys/minifind.h | 42 | ||||
-rw-r--r-- | isys/smp.c | 41 |
4 files changed, 163 insertions, 5 deletions
diff --git a/isys/Makefile b/isys/Makefile index 7bc9c5d0c..cf2202aba 100644 --- a/isys/Makefile +++ b/isys/Makefile @@ -28,6 +28,12 @@ PYMODULES += _silo.so SOURCES += silo.c endif +ifeq ($(ARCH),ppc) +OBJECTS += minifind.o +SOURCES += minifind.c +DIETLIB=libisys-diet.a +endif + ifeq (.depend,$(wildcard .depend)) TARGET=all else diff --git a/isys/minifind.c b/isys/minifind.c new file mode 100644 index 000000000..9da9f62ef --- /dev/null +++ b/isys/minifind.c @@ -0,0 +1,79 @@ +/* minifind.c -- simple find library + * + * Copyright (c) 2002 Terra Soft Solutions, Inc. + * Written by Dan Burcaw <dburcaw@terrasoftsolutions.com> + * + * This software may be freely redistributed under the terms of the GNU + * library public license. + * + * You should have received a copy of the GNU Library Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#include "minifind.h" + +// insert a node at head of linked-list +void insert_node(struct pathNode *n, char *path) +{ + struct pathNode *new = (struct pathNode *) malloc(sizeof(struct pathNode)); + new->path = path; + new->next = n->next; + n->next = new; +} + +// return input strip less last character +char *stripLastChar(char *in) +{ + int i; + + char *out = malloc(sizeof(char)*strlen(in)); + snprintf(out, strlen(in) - 1, "%s", in); + return out; +} + +// do the work +char *minifind(char *dir, char *search, struct findNode *list) +{ + char *d = NULL; + int n; + struct dirent **namelist; + struct stat buf; + + if (dir[strlen(dir)-1] == '/') + dir = stripLastChar(dir); + + // check is there is an exact filematch to dir + // when search is not specified + if (search == NULL) + { + if (lstat(dir, &buf) == 0) + insert_node(list->result, dir); + return 0; + } + + n = scandir(dir, &namelist, 0, alphasort); + if (n >= 0) + { + while (n--) + { + d = malloc(sizeof(char) * (strlen(dir) \ + + strlen(namelist[n]->d_name)+1)); + sprintf(d, "%s/%s", dir, namelist[n]->d_name); + if (strstr(namelist[n]->d_name, search)) + insert_node(list->result, d); + + if ((lstat(d, &buf) == 0) && S_ISDIR(buf.st_mode)) + { + if (strcmp(namelist[n]->d_name, ".") && + strcmp(namelist[n]->d_name, "..")) + d = minifind(d, search, list); + } + free(namelist[n]); + } + free(namelist); + return d; + } + return 0; +} diff --git a/isys/minifind.h b/isys/minifind.h new file mode 100644 index 000000000..4f725258c --- /dev/null +++ b/isys/minifind.h @@ -0,0 +1,42 @@ +/* minifind.h + * + * Copyright (c) 2002 Terra Soft Solutions, Inc. + * Written by Dan Burcaw <dburcaw@terrasoftsolutions.com> + * + * This software may be freely redistributed under the terms of the GNU + * library public license. + * + * You should have received a copy of the GNU Library Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +#ifndef MINIFIND_H +#define MINIFIND_H + +#include <stdio.h> +#include <string.h> +#include <dirent.h> +#include <malloc.h> +#include <unistd.h> +#include <sys/stat.h> +#include <sys/types.h> + +struct pathNode +{ + char *path; + struct pathNode *next; +}; + +struct findNode +{ + struct pathNode *result; + struct pathNode *exclude; +}; + +void insert_node(struct pathNode *n, char *path); +char *stripLastChar(char *in); +char *minifind(char *dir, char *search, struct findNode *list); + +#endif /* MINIFIND_H */ diff --git a/isys/smp.c b/isys/smp.c index ef13ef3b4..1ddda330b 100644 --- a/isys/smp.c +++ b/isys/smp.c @@ -21,6 +21,7 @@ typedef unsigned long u_long; typedef unsigned int u_int; #endif + #ifdef __alpha__ int alphaDetectSMP(void) { @@ -98,11 +99,41 @@ int sparcDetectSMP(void) #endif /* __sparc__ */ #ifdef __powerpc__ -/* FIXME: placeholder */ -int ppcDetectSMP(void) { - return 0; +#include "minifind.h" + +/* FIXME: this won't work on iSeries */ +int powerpcDetectSMP(void) +{ + int issmp = -1; + FILE *f; + struct findNode *list = (struct findNode *) malloc(sizeof(struct findNode)); + struct pathNode *n; + + list->result = (struct pathNode *) malloc(sizeof(struct pathNode)); + list->result->path = NULL; + list->result->next = list->result; + + minifind("/proc/device-tree/cpus", "device_type", list); + + for (n = list->result->next; n != list->result; n = n->next) + { + f = fopen(n->path, "r"); + if (f) { + char buff[1024]; + while (fgets (buff, 1024, f) != NULL) { + if (!strncmp (buff, "cpu", 3)) + { + issmp++; + break; + } + } + fclose(f); + } + } + + return issmp; } -#endif +#endif /* __powerpc__ */ #ifdef __i386__ /* @@ -601,7 +632,7 @@ int detectSMP(void) #elif __x86_64__ return isSMP = 1; #elif __powerpc__ - return isSMP = ppcDetectSMP(); + return isSMP = powerpcDetectSMP(); #else #error unknown architecture #endif |