debian-installer/tools/ddetect archdetect-mips-linux.c,NONE,1.1 archdetect-mipsel-linux.c,NONE,1.1 archdetect-generic.c,1.1,1.2 archdetect-powerpc-linux.c,1.1,1.2 archdetect.c,1.2,1.3 archdetect.h,1.1,1.2
- To: debian-boot@lists.debian.org
- Subject: debian-installer/tools/ddetect archdetect-mips-linux.c,NONE,1.1 archdetect-mipsel-linux.c,NONE,1.1 archdetect-generic.c,1.1,1.2 archdetect-powerpc-linux.c,1.1,1.2 archdetect.c,1.2,1.3 archdetect.h,1.1,1.2
- From: debian-boot CVS user <cvs_boot@debian.org>
- Date: Tue, 09 Dec 2003 20:53:05 +0000
- Message-id: <[🔎] E1AToqv-0002ZI-00@gluck.debian.org>
- Reply-to: debian-boot@lists.debian.org
Update of /cvs/debian-boot/debian-installer/tools/ddetect
In directory gluck:/tmp/cvs-serv7805
Modified Files:
archdetect-generic.c archdetect-powerpc-linux.c archdetect.c
archdetect.h
Added Files:
archdetect-mips-linux.c archdetect-mipsel-linux.c
Log Message:
- Add support for mips, mipsel to archdetect.
- Remove unused #includes.
- Unify code formatting.
- Add CFLAGS for warnings and space optimization.
Index: archdetect.h
===================================================================
RCS file: /cvs/debian-boot/debian-installer/tools/ddetect/archdetect.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- archdetect.h 30 Sep 2003 15:39:04 -0000 1.1
+++ archdetect.h 9 Dec 2003 20:53:03 -0000 1.2
@@ -1,4 +1 @@
-#include <stdbool.h>
-
-const char *subarch_analyze (void);
-
+const char *subarch_analyze(void);
--- NEW FILE: archdetect-mipsel-linux.c ---
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "archdetect.h"
struct cpu {
char *cpu;
char *ret;
};
struct system {
char *sys;
struct cpu *cpu;
};
static struct cpu system_dec_decs_cpu[] = {
{ "R3", "r3k-kn02" },
{ "R4", "r4k-kn04" },
{ NULL, "unknown" }
};
/* add new system types here */
static struct cpu system_unknown_cpu[] = {
{ NULL, "unknown" }
};
static struct system system_type[] = {
/*
* match any of
* "Digital unknown DECstation"
* "Digital DECstation"
* "Digital DECsystem"
* "Digital Personal DECstation"
*/
{"Digital ", system_dec_decs_cpu },
/* add new system types here */
{ NULL, system_unknown_cpu }
};
#define INVALID_SYS_IDX (sizeof(system_type) / sizeof(struct system) - 1)
#define INVALID_CPU_IDX (-1)
#define BUFFER_LENGTH (1024)
static int check_system(const char *entry)
{
int ret;
for (ret = 0; system_type[ret].sys; ret++) {
if (!strncmp(system_type[ret].sys, entry,
strlen(system_type[ret].sys)))
break;
}
return ret;
}
static int check_cpu(const char *entry, int sys_idx)
{
int ret;
if (sys_idx == INVALID_SYS_IDX) {
/*
* This means an unsupported system type, because the
* system type is always the first entry in /proc/cpuinfo.
*/
return INVALID_CPU_IDX;
}
for (ret = 0; system_type[sys_idx].cpu[ret].cpu; ret++) {
if (!strncmp(system_type[sys_idx].cpu[ret].cpu, entry,
strlen(system_type[sys_idx].cpu[ret].cpu)))
break;
}
return ret;
}
const char *subarch_analyze(void)
{
FILE *file;
int sys_idx = INVALID_SYS_IDX;
int cpu_idx = INVALID_CPU_IDX;
char buf[BUFFER_LENGTH];
char *pos;
size_t len;
if (!(file = fopen("/proc/cpuinfo", "r")))
return system_type[sys_idx].cpu[0].ret;
while (fgets(buf, sizeof(buf), file)) {
if (!(pos = strchr(buf, ':')))
continue;
if (!(len = strspn(pos, ": \t")))
continue;
if (!strncmp(buf, "system type", strlen("system type")))
sys_idx = check_system(pos + len);
else if (!strncmp(buf, "cpu model", strlen("cpu model")))
cpu_idx = check_cpu(pos + len, sys_idx);
}
fclose(file);
if (cpu_idx == INVALID_CPU_IDX) {
sys_idx = INVALID_SYS_IDX;
cpu_idx = 0;
}
return system_type[sys_idx].cpu[cpu_idx].ret;
}
Index: archdetect-powerpc-linux.c
===================================================================
RCS file: /cvs/debian-boot/debian-installer/tools/ddetect/archdetect-powerpc-linux.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- archdetect-powerpc-linux.c 30 Sep 2003 15:39:04 -0000 1.1
+++ archdetect-powerpc-linux.c 9 Dec 2003 20:53:03 -0000 1.2
@@ -1,76 +1,71 @@
#include <ctype.h>
-#include <stdio.h>
#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
#include <strings.h>
-#include <unistd.h>
#include "archdetect.h"
-struct map
-{
- char *entry;
- char *ret;
+struct map {
+ char *entry;
+ char *ret;
};
-struct map map_generation[] =
-{
- { "OldWorld", "powermac_oldworld" },
- { "NewWorld", "powermac_newworld" },
- { NULL, NULL }
+struct map map_generation[] = {
+ { "OldWorld", "powermac_oldworld" },
+ { "NewWorld", "powermac_newworld" },
+ { NULL, NULL }
};
-struct map map_machine[] =
-{
- { "PReP", "prep" },
- { "CHRP Pegasos", "chrp_pegasos" },
- { "CHRP", "chrp" },
- { "Amiga", "amiga" },
- { NULL, NULL }
+struct map map_machine[] = {
+ { "PReP", "prep" },
+ { "CHRP Pegasos", "chrp_pegasos" },
+ { "CHRP", "chrp" },
+ { "Amiga", "amiga" },
+ { NULL, NULL }
};
-char *check_map (struct map map[], const char *entry)
+static char *check_map(struct map map[], const char *entry)
{
- for (; map->entry; map++)
- if (!strncasecmp (map->entry, entry, strlen (map->entry)))
- return map->ret;
- return NULL;
+ for (; map->entry; map++)
+ if (!strncasecmp(map->entry, entry, strlen(map->entry)))
+ return map->ret;
+
+ return NULL;
}
-const char *subarch_analyze() {
+const char *subarch_analyze(void)
+{
FILE *cpuinfo;
char line[1024];
- char cpuinfo_machine[256], cpuinfo_generation[256];
- char *ret, *pos;
+ char cpuinfo_machine[256], cpuinfo_generation[256];
+ char *ret, *pos;
cpuinfo = fopen("/proc/cpuinfo", "r");
- if(cpuinfo == NULL)
- return "unknown";
+ if (cpuinfo == NULL)
+ return "unknown";
- while(fgets(line, sizeof (line), cpuinfo) != NULL) {
- if(line == NULL)
- continue;
+ while (fgets(line, sizeof(line), cpuinfo) != NULL) {
pos = strchr(line, ':');
- if(pos == NULL)
+ if (pos == NULL)
continue;
- while(*++pos && isblank(*pos));
+ while (*++pos && isblank(*pos));
- if(strstr(line, "machine") == line)
- strncpy(cpuinfo_machine, pos, sizeof (cpuinfo_machine));
+ if (strstr(line, "machine") == line)
+ strncpy(cpuinfo_machine, pos, sizeof(cpuinfo_machine));
- if(strstr(line, "pmac-generation") == line)
- strncpy(cpuinfo_generation, pos, sizeof (cpuinfo_generation));
+ if (strstr(line, "pmac-generation") == line)
+ strncpy(cpuinfo_generation, pos, sizeof(cpuinfo_generation));
}
fclose(cpuinfo);
- ret = check_map (map_machine, cpuinfo_machine);
- if (ret)
- return ret;
- ret = check_map (map_generation, cpuinfo_generation);
- if (ret)
- return ret;
+ ret = check_map(map_machine, cpuinfo_machine);
+ if (ret)
+ return ret;
+ ret = check_map(map_generation, cpuinfo_generation);
+ if (ret)
+ return ret;
- return "unknown";
+ return "unknown";
}
-
Index: archdetect.c
===================================================================
RCS file: /cvs/debian-boot/debian-installer/tools/ddetect/archdetect.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- archdetect.c 12 Oct 2003 12:50:30 -0000 1.2
+++ archdetect.c 9 Dec 2003 20:53:03 -0000 1.3
@@ -1,23 +1,22 @@
-#include <cdebconf/debconfclient.h>
#include <string.h>
+#include <cdebconf/debconfclient.h>
+
#include "archdetect.h"
-int main(int argc, char *argv[]) {
+int main(int argc, char *argv[])
+{
const char *subarch;
- if(!(subarch = subarch_analyze()))
- return(0);
+ if (!(subarch = subarch_analyze()))
+ return 0;
- if(strstr(argv[0], "postinst") != NULL)
- {
+ if (strstr(argv[0], "postinst") != NULL) {
struct debconfclient *debconf;
debconf = debconfclient_new();
debconf_set(debconf, "debian-installer/kernel/subarchitecture", subarch);
- }
- else
+ } else
printf("%s/%s\n", CPU_TEXT, subarch);
return 0;
}
-
Index: archdetect-generic.c
===================================================================
RCS file: /cvs/debian-boot/debian-installer/tools/ddetect/archdetect-generic.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- archdetect-generic.c 30 Sep 2003 15:39:04 -0000 1.1
+++ archdetect-generic.c 9 Dec 2003 20:53:03 -0000 1.2
@@ -1,7 +1,6 @@
#include "archdetect.h"
-const char *subarch_analyze (void)
+const char *subarch_analyze(void)
{
- return "generic";
+ return "generic";
}
-
--- NEW FILE: archdetect-mips-linux.c ---
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "archdetect.h"
struct cpu {
char *cpu;
char *ret;
};
struct system {
char *sys;
struct cpu *cpu;
};
static struct cpu system_sgi_ind_cpu[] = {
{ "R4", "r4k-ip22" },
{ "R5", "r5k-ip22" },
{ NULL, "unknown" }
};
/* add new system types here */
static struct cpu system_unknown_cpu[] = {
{ NULL, "unknown" }
};
static struct system system_type[] = {
/* match "SGI Indy" and "SGI Indigo2" */
{"SGI Ind", system_sgi_ind_cpu },
/* add new system types here */
{ NULL, system_unknown_cpu }
};
#define INVALID_SYS_IDX (sizeof(system_type) / sizeof(struct system) - 1)
#define INVALID_CPU_IDX (-1)
#define BUFFER_LENGTH (1024)
static int check_system(const char *entry)
{
int ret;
for (ret = 0; system_type[ret].sys; ret++) {
if (!strncmp(system_type[ret].sys, entry,
strlen(system_type[ret].sys)))
break;
}
return ret;
}
static int check_cpu(const char *entry, int sys_idx)
{
int ret;
if (sys_idx == INVALID_SYS_IDX) {
/*
* This means an unsupported system type, because the
* system type is always the first entry in /proc/cpuinfo.
*/
return INVALID_CPU_IDX;
}
for (ret = 0; system_type[sys_idx].cpu[ret].cpu; ret++) {
if (!strncmp(system_type[sys_idx].cpu[ret].cpu, entry,
strlen(system_type[sys_idx].cpu[ret].cpu)))
break;
}
return ret;
}
const char *subarch_analyze(void)
{
FILE *file;
int sys_idx = INVALID_SYS_IDX;
int cpu_idx = INVALID_CPU_IDX;
char buf[BUFFER_LENGTH];
char *pos;
size_t len;
if (!(file = fopen("/proc/cpuinfo", "r")))
return system_type[sys_idx].cpu[0].ret;
while (fgets(buf, sizeof(buf), file)) {
if (!(pos = strchr(buf, ':')))
continue;
if (!(len = strspn(pos, ": \t")))
continue;
if (!strncmp(buf, "system type", strlen("system type")))
sys_idx = check_system(pos + len);
else if (!strncmp(buf, "cpu model", strlen("cpu model")))
cpu_idx = check_cpu(pos + len, sys_idx);
}
fclose(file);
if (cpu_idx == INVALID_CPU_IDX) {
sys_idx = INVALID_SYS_IDX;
cpu_idx = 0;
}
return system_type[sys_idx].cpu[cpu_idx].ret;
}
Reply to:
- Prev by Date:
debian-installer/tools/ddetect/debian changelog,1.219,1.220 rules,1.16,1.17
- Next by Date:
debian-installer/main-menu/debian changelog,1.204,1.205
- Previous by thread:
debian-installer/tools/ddetect/debian changelog,1.219,1.220 rules,1.16,1.17
- Next by thread:
debian-installer/main-menu/debian changelog,1.204,1.205
- Index(es):