1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
|
/*
* loader.c
*
* This is the installer loader. Its job is to somehow load the rest
* of the installer into memory and run it. This may require setting
* up some devices and networking, etc. The main point of this code is
* to stay SMALL! Remember that, live by that, and learn to like it.
*
* Erik Troan <ewt@redhat.com>
* Matt Wilson <msw@redhat.com>
*
* Copyright 1999 Red Hat Software
*
* This software may be freely redistributed under the terms of the GNU
* public license.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#include <unistd.h>
#include <popt.h>
#include <newt.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <net/route.h>
#include <sys/ioctl.h>
#include <fcntl.h>
#include "isys/imount.h"
#include "isys/isys.h"
#include "isys/pci/pciprobe.h"
#define _(x) x
struct intfInfo {
char device[10];
int isPtp, isUp;
int set, manuallySet;
struct in_addr ip, netmask, broadcast, network;
struct in_addr bootServer;
char * bootFile;
int bootProto;
};
static int configureNetDevice(struct intfInfo * intf) {
struct ifreq req;
int s;
struct sockaddr_in addr;
struct in_addr ia;
char ip[20], nm[20], nw[20], bc[20];
#if 0 /* 2.0 kernels only */
struct rtentry route;
#endif
addr.sin_family = AF_INET;
addr.sin_port = 0;
memcpy(&ia, &intf->ip, sizeof(intf->ip));
strcpy(ip, inet_ntoa(ia));
memcpy(&ia, &intf->netmask, sizeof(intf->netmask));
strcpy(nm, inet_ntoa(ia));
memcpy(&ia, &intf->broadcast, sizeof(intf->broadcast));
strcpy(bc, inet_ntoa(ia));
memcpy(&ia, &intf->network, sizeof(intf->network));
strcpy(nw, inet_ntoa(ia));
printf("configuring %s ip: %s nm: %s nw: %s bc: %s\n", intf->device,
ip, nm, nw, bc);
s = socket(AF_INET, SOCK_DGRAM, 0);
if (s < 0) {
perror("socket");
return 1;
}
strcpy(req.ifr_name, intf->device);
req.ifr_flags &= ~(IFF_UP | IFF_RUNNING); /* Take down iface */
if (ioctl(s, SIOCSIFFLAGS, &req)) {
perror("SIOCSIFFLAGS");
close(s);
return 1;
}
addr.sin_port = 0;
memcpy(&addr.sin_addr, &intf->ip, sizeof(intf->ip));
memcpy(&req.ifr_addr, &addr, sizeof(addr));
if (ioctl(s, SIOCSIFADDR, &req)) {
perror("SIOCSIFADDR");
close(s);
return 1;
}
memcpy(&addr.sin_addr, &intf->broadcast, sizeof(intf->broadcast));
memcpy(&req.ifr_broadaddr, &addr, sizeof(addr));
if (ioctl(s, SIOCSIFBRDADDR, &req)) {
perror("SIOCSIFNETMASK");
close(s);
return 1;
}
memcpy(&addr.sin_addr, &intf->netmask, sizeof(intf->netmask));
memcpy(&req.ifr_netmask, &addr, sizeof(addr));
if (ioctl(s, SIOCSIFNETMASK, &req)) {
perror("SIOCSIFNETMASK\n");
close(s);
return 1;
}
if (intf->isPtp)
req.ifr_flags = IFF_UP | IFF_RUNNING | IFF_POINTOPOINT | IFF_NOARP;
else
req.ifr_flags = IFF_UP | IFF_RUNNING | IFF_BROADCAST;
if (ioctl(s, SIOCSIFFLAGS, &req)) {
perror("SIOCSIFFLAGS");
close(s);
return 1;
}
#if 0 /* kernel 2.0 only */
memset(&route, 0, sizeof(route));
route.rt_dev = intf->device;
route.rt_flags = RTF_UP;
memcpy(&addr.sin_addr, &intf->network, sizeof(intf->netmask));
memcpy(&route.rt_dst, &addr, sizeof(addr));
memcpy(&addr.sin_addr, &intf->netmask, sizeof(intf->netmask));
memcpy(&route.rt_genmask, &addr, sizeof(addr));
if (ioctl(s, SIOCADDRT, &route)) {
perror("SIOCADDRT");
close(s);
return 1;
}
#endif
intf->isUp = 1;
return 0;
}
int main(int argc, char ** argv) {
char ** argptr;
char * anacondaArgs[30];
char * arg;
poptContext optCon;
int testing, network, local, rc;
char ** modules, *module;
struct intfInfo eth0;
struct poptOption optionTable[] = {
{ "test", '\0', POPT_ARG_NONE, &testing, 0 },
{ "network", '\0', POPT_ARG_NONE, &network, 0 },
{ "local", '\0', POPT_ARG_NONE, &local, 0 },
{ 0, 0, 0, 0, 0 }
};
optCon = poptGetContext(NULL, argc, argv, optionTable, 0);
if ((rc = poptGetNextOpt(optCon)) < -1) {
fprintf(stderr, "bad option %s: %s\n",
poptBadOption(optCon, POPT_BADOPTION_NOALIAS),
poptStrerror(rc));
exit(1);
}
if ((arg = poptGetArg(optCon))) {
fprintf(stderr, "unexpected argument: %s\n", arg);
exit(1);
}
if (probePciReadDrivers(testing ? "../isys/pci/pcitable" :
"/etc/pcitable")) {
perror("error reading pci table");
return 1;
}
if (!testing) {
modules = probePciDriverList();
if (modules == NULL) {
printf("No PCI devices found :(\n");
} else {
while ((module = *modules++)) {
if (!testing) {
printf("Inserting module %s\n", module);
insmod(module, NULL);
} else {
printf("Test mode: I would run insmod(%s, args);\n",
module);
}
}
}
/*
newtInit();
newtDrawRootText(0, 0, _("Welcome to Red Hat Linux"));
newtPushHelpLine(_(" <Tab>/<Alt-Tab> between elements | <Space> selects | <F12> next screen "));
newtFinished();
*/
strcpy(eth0.device, "eth0");
eth0.isPtp=0;
eth0.isUp=0;
eth0.ip.s_addr=inet_addr("207.175.42.47");
eth0.netmask.s_addr=htonl(0xffffff00);
eth0.broadcast.s_addr=inet_addr("207.175.42.255");
eth0.network.s_addr=inet_addr("207.175.42.0");
configureNetDevice(ð0);
mkdir("/mnt", 777);
mkdir("/mnt/source", 777);
insmod("sunrpc.o", NULL);
insmod("lockd.o", NULL);
insmod("nfs.o", NULL);
doPwMount("207.175.42.68:/mnt/test/msw/i386",
"/mnt/source", "nfs", 1, 0, NULL, NULL);
symlink("/mnt/source/RedHat/instimage/usr", "/usr");
symlink("/mnt/source/RedHat/instimage/lib", "/lib");
if (access("/usr/bin/anaconda", R_OK)) {
printf("NFS mount does not appear to be a Red Hat 6.1 tree\n");
exit (1);
}
}
argptr = anacondaArgs;
*argptr++ = testing ? "../anaconda" : "/usr/bin/anaconda";
printf("Launching anaconda (%s), please wait...\n", anacondaArgs[0]);
execv(anacondaArgs[0], anacondaArgs);
perror("exec");
return 0;
}
|