Deleted Added
full compact
install.c (8677) install.c (8702)
1/*
2 * The new sysinstall program.
3 *
4 * This is probably the last program in the `sysinstall' line - the next
5 * generation being essentially a complete rewrite.
6 *
1/*
2 * The new sysinstall program.
3 *
4 * This is probably the last program in the `sysinstall' line - the next
5 * generation being essentially a complete rewrite.
6 *
7 * $Id: install.c,v 1.45 1995/05/21 01:56:01 phk Exp $
7 * $Id: install.c,v 1.46 1995/05/21 15:40:48 jkh Exp $
8 *
9 * Copyright (c) 1995
10 * Jordan Hubbard. All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright

--- 35 unchanged lines hidden (view full) ---

51Boolean SystemWasInstalled;
52
53static void make_filesystems(void);
54static void copy_self(void);
55static void cpio_extract(void);
56static void install_configuration_files(void);
57static void do_final_setup(void);
58
8 *
9 * Copyright (c) 1995
10 * Jordan Hubbard. All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright

--- 35 unchanged lines hidden (view full) ---

51Boolean SystemWasInstalled;
52
53static void make_filesystems(void);
54static void copy_self(void);
55static void cpio_extract(void);
56static void install_configuration_files(void);
57static void do_final_setup(void);
58
59static Disk *rootdisk;
60static Chunk *rootdev;
61
62static Boolean
63checkLabels(void)
64{
65 Device **devs;
66 Disk *disk;
67 Chunk *c1, *c2, *swapdev = NULL;
68 int i;
69
70 devs = deviceFind(NULL, DEVICE_TYPE_DISK);
71 /* First verify that we have a root device */
72 for (i = 0; devs[i]; i++) {
73 if (!devs[i]->enabled)
74 continue;
75 disk = (Disk *)devs[i]->private;
76 msgDebug("Scanning disk %s for root filesystem\n", disk->name);
77 if (!disk->chunks)
78 msgFatal("No chunk list found for %s!", disk->name);
79 for (c1 = disk->chunks->part; c1; c1 = c1->next) {
80 if (c1->type == freebsd) {
81 for (c2 = c1->part; c2; c2 = c2->next) {
82 if (c2->type == part && c2->subtype != FS_SWAP &&
83 c2->private && c2->flags & CHUNK_IS_ROOT) {
84 rootdisk = disk;
85 rootdev = c2;
86 break;
87 }
88 }
89 }
90 }
91 }
92
93 /* Now register the swap devices */
94 for (i = 0; devs[i]; i++) {
95 disk = (Disk *)devs[i]->private;
96 msgDebug("Scanning disk %s for swap partitions\n", disk->name);
97 if (!disk->chunks)
98 msgFatal("No chunk list found for %s!", disk->name);
99 for (c1 = disk->chunks->part; c1; c1 = c1->next) {
100 if (c1->type == freebsd) {
101 for (c2 = c1->part; c2; c2 = c2->next) {
102 if (c2->type == part && c2->subtype == FS_SWAP) {
103 swapdev = c2;
104 break;
105 }
106 }
107 }
108 }
109 }
110
111 if (!rootdev) {
112 msgConfirm("No root device found - you must label a partition as /\n in the label editor.");
113 return FALSE;
114 }
115 if (!swapdev) {
116 msgConfirm("No swap devices found - you must create at least one\nswap partition.");
117 return FALSE;
118 }
119 return TRUE;
120}
121
59static void
60installInitial(void)
61{
62 extern u_char boot1[], boot2[];
63 extern u_char mbr[], bteasy17[];
64 u_char *mbrContents;
65 Device **devs;
66 int i;

--- 6 unchanged lines hidden (view full) ---

73 if (!getenv(DISK_PARTITIONED)) {
74 msgConfirm("You need to partition your disk before you can proceed with\nthe installation.");
75 return;
76 }
77 if (!getenv(DISK_LABELLED)) {
78 msgConfirm("You need to assign disk labels before you can proceed with\nthe installation.");
79 return;
80 }
122static void
123installInitial(void)
124{
125 extern u_char boot1[], boot2[];
126 extern u_char mbr[], bteasy17[];
127 u_char *mbrContents;
128 Device **devs;
129 int i;

--- 6 unchanged lines hidden (view full) ---

136 if (!getenv(DISK_PARTITIONED)) {
137 msgConfirm("You need to partition your disk before you can proceed with\nthe installation.");
138 return;
139 }
140 if (!getenv(DISK_LABELLED)) {
141 msgConfirm("You need to assign disk labels before you can proceed with\nthe installation.");
142 return;
143 }
144 if (!checkLabels())
145 return;
81
82 /* Figure out what kind of MBR the user wants */
83 dmenuOpenSimple(&MenuMBRType);
84 mbrContents = NULL;
85 cp = getenv("bootManager");
86 if (cp) {
87 if (!strcmp(cp, "bteasy"))
88 mbrContents = bteasy17;
89 else if (!strcmp(cp, "mbr"))
90 mbrContents = mbr;
91 }
92
93 /* If we refuse to proceed, bail. */
94 if (msgYesNo("Last Chance! Are you SURE you want continue the installation?\n\nIf you're running this on an existing system, we STRONGLY\nencourage you to make proper backups before proceeding.\nWe take no responsibility for lost disk contents!"))
95 return;
96
97 devs = deviceFind(NULL, DEVICE_TYPE_DISK);
98 for (i = 0; devs[i]; i++) {
146
147 /* Figure out what kind of MBR the user wants */
148 dmenuOpenSimple(&MenuMBRType);
149 mbrContents = NULL;
150 cp = getenv("bootManager");
151 if (cp) {
152 if (!strcmp(cp, "bteasy"))
153 mbrContents = bteasy17;
154 else if (!strcmp(cp, "mbr"))
155 mbrContents = mbr;
156 }
157
158 /* If we refuse to proceed, bail. */
159 if (msgYesNo("Last Chance! Are you SURE you want continue the installation?\n\nIf you're running this on an existing system, we STRONGLY\nencourage you to make proper backups before proceeding.\nWe take no responsibility for lost disk contents!"))
160 return;
161
162 devs = deviceFind(NULL, DEVICE_TYPE_DISK);
163 for (i = 0; devs[i]; i++) {
99 Disk *d = (Disk *)devs[i]->private;
100 Chunk *c1;
164 Chunk *c1;
165 Disk *d = (Disk *)devs[i]->private;
101
102 if (!devs[i]->enabled)
103 continue;
104
105 if (mbrContents) {
106 Set_Boot_Mgr(d, mbrContents);
107 mbrContents = NULL;
108 }

--- 64 unchanged lines hidden (view full) ---

173/* Go newfs and/or mount all the filesystems we've been asked to */
174static void
175make_filesystems(void)
176{
177 int i;
178 Disk *disk;
179 Chunk *c1, *c2;
180 Device **devs;
166
167 if (!devs[i]->enabled)
168 continue;
169
170 if (mbrContents) {
171 Set_Boot_Mgr(d, mbrContents);
172 mbrContents = NULL;
173 }

--- 64 unchanged lines hidden (view full) ---

238/* Go newfs and/or mount all the filesystems we've been asked to */
239static void
240make_filesystems(void)
241{
242 int i;
243 Disk *disk;
244 Chunk *c1, *c2;
245 Device **devs;
246 char dname[40];
247 PartInfo *p = (PartInfo *)rootdev->private;
181
182 command_clear();
183 devs = deviceFind(NULL, DEVICE_TYPE_DISK);
184
248
249 command_clear();
250 devs = deviceFind(NULL, DEVICE_TYPE_DISK);
251
185 /* First look for the root device and mount it */
186 for (i = 0; devs[i]; i++) {
187 disk = (Disk *)devs[i]->private;
188 msgDebug("Scanning disk %s for root filesystem\n", disk->name);
189 if (!disk->chunks)
190 msgFatal("No chunk list found for %s!", disk->name);
191 for (c1 = disk->chunks->part; c1; c1 = c1->next) {
192 if (c1->type == freebsd) {
193 for (c2 = c1->part; c2; c2 = c2->next) {
194 if (c2->type == part && c2->subtype != FS_SWAP &&
195 c2->private && c2->flags & CHUNK_IS_ROOT) {
196 char dname[40];
197 PartInfo *p = (PartInfo *)c2->private;
252 /* First, create and mount the root device */
253 if (strcmp(p->mountpoint, "/"))
254 msgConfirm("Warning: %s is marked as a root partition but is mounted on %s", rootdev->name, p->mountpoint);
198
255
199 if (strcmp(p->mountpoint, "/")) {
200 msgConfirm("Warning: %s is marked as a root partition but is mounted on %s", c2->name, p->mountpoint);
201 continue;
202 }
203 if (p->newfs) {
204 int i;
256 if (p->newfs) {
257 int i;
205
258
206 sprintf(dname, "/dev/r%sa", disk->name);
207 msgNotify("Making a new root filesystem on %s", dname);
208 i = vsystem("%s %s", p->newfs_cmd,dname);
209 if (i) {
210 msgConfirm("Unable to make new root filesystem! Command returned status %d", i);
211 return;
212 }
213 }
214 else
215 msgConfirm("Warning: You have selected a Read-Only root device\nand may be unable to find the appropriate device entries on it\nif it is from an older pre-slice version of FreeBSD.");
216 sprintf(dname, "/dev/%sa", disk->name);
217 if (Mount("/mnt", dname)) {
218 msgConfirm("Unable to mount the root file system! Giving up.");
219 return;
220 }
221 else {
222 extern int makedevs(void);
259 sprintf(dname, "/dev/r%sa", rootdisk->name);
260 msgNotify("Making a new root filesystem on %s", dname);
261 i = vsystem("%s %s", p->newfs_cmd, dname);
262 if (i) {
263 msgConfirm("Unable to make new root filesystem! Command returned status %d", i);
264 return;
265 }
266 }
267 else
268 msgConfirm("Warning: You have selected a Read-Only root device\nand may be unable to find the appropriate device entries on it\nif it is from an older pre-slice version of FreeBSD.");
269 sprintf(dname, "/dev/%sa", rootdisk->name);
270 if (Mount("/mnt", dname)) {
271 msgConfirm("Unable to mount the root file system! Giving up.");
272 return;
273 }
274 else {
275 extern int makedevs(void);
223
276
224 msgNotify("Making device files");
225 if (Mkdir("/mnt/dev", NULL)
226 || chdir("/mnt/dev")
227 || makedevs())
228 msgConfirm("Failed to make some of the devices in /mnt!");
229 if (Mkdir("/mnt/stand", NULL))
230 msgConfirm("Unable to make /mnt/stand directory!");
231 chdir("/");
232 break;
233 }
234 }
235 }
236 }
277 msgNotify("Making device files");
278 if (Mkdir("/mnt/dev", NULL) || chdir("/mnt/dev") || makedevs())
279 msgConfirm("Failed to make some of the devices in /mnt!");
280 if (Mkdir("/mnt/stand", NULL)) {
281 msgConfirm("Unable to make /mnt/stand directory!");
282 return;
237 }
283 }
284 chdir("/");
238 }
239
240 /* Now buzz through the rest of the partitions and mount them too */
241 for (i = 0; devs[i]; i++) {
242 disk = (Disk *)devs[i]->private;
243 if (!disk->chunks)
244 msgFatal("No chunk list found for %s!", disk->name);
245

--- 5 unchanged lines hidden (view full) ---

251 for (c2 = c1->part; c2; c2 = c2->next) {
252 if (c2->type == part && c2->subtype != FS_SWAP && c2->private) {
253 PartInfo *tmp = (PartInfo *)c2->private;
254
255 if (!strcmp(tmp->mountpoint, "/"))
256 continue;
257
258 if (tmp->newfs)
285 }
286
287 /* Now buzz through the rest of the partitions and mount them too */
288 for (i = 0; devs[i]; i++) {
289 disk = (Disk *)devs[i]->private;
290 if (!disk->chunks)
291 msgFatal("No chunk list found for %s!", disk->name);
292

--- 5 unchanged lines hidden (view full) ---

298 for (c2 = c1->part; c2; c2 = c2->next) {
299 if (c2->type == part && c2->subtype != FS_SWAP && c2->private) {
300 PartInfo *tmp = (PartInfo *)c2->private;
301
302 if (!strcmp(tmp->mountpoint, "/"))
303 continue;
304
305 if (tmp->newfs)
259 command_shell_add(tmp->mountpoint,
260 "%s /mnt/dev/r%s", tmp->newfs_cmd, c2->name);
306 command_shell_add(tmp->mountpoint, "%s /mnt/dev/r%s", tmp->newfs_cmd, c2->name);
261 command_func_add(tmp->mountpoint, Mount, c2->name);
262 }
307 command_func_add(tmp->mountpoint, Mount, c2->name);
308 }
309 else if (c2->type == part && c2->subtype == FS_SWAP) {
310 char fname[80];
311 int i;
312
313 sprintf(fname, "/mnt/dev/%s", c2->name);
314 i = swapon(fname);
315 if (!i)
316 msgNotify("Added %s as a swap device", fname);
317 else
318 msgConfirm("Unable to add %s as a swap device: %s", fname, strerror(errno));
319 }
263 }
264 }
265 }
266 }
267 command_sort();
268 command_execute();
269}
270

--- 9 unchanged lines hidden (view full) ---

280 msgConfirm("Copy returned error status of %d!", i);
281}
282
283static void
284cpio_extract(void)
285{
286 int i, j, zpid, cpid, pfd[2];
287
320 }
321 }
322 }
323 }
324 command_sort();
325 command_execute();
326}
327

--- 9 unchanged lines hidden (view full) ---

337 msgConfirm("Copy returned error status of %d!", i);
338}
339
340static void
341cpio_extract(void)
342{
343 int i, j, zpid, cpid, pfd[2];
344
345#if 0
346 if (mediaDevice && mediaDevice->type == DEVICE_TYPE_CDROM) {
347 if (mediaDevice->init) {
348 if ((*mediaDevice->init)(mediaDevice)) {
349 CpioFD = open("/cdrom/floppies/cpio.flp", O_RDONLY);
350 if (CpioFD != -1)
351 msgNotify("Loading CPIO floppy from CDROM");
352 }
353 }
354 }
355#endif
288 tryagain:
289 while (CpioFD == -1) {
290 msgConfirm("Please Insert CPIO floppy in floppy drive 0");
356 tryagain:
357 while (CpioFD == -1) {
358 msgConfirm("Please Insert CPIO floppy in floppy drive 0");
291 CpioFD = open("/dev/rfd0", O_RDWR);
359 CpioFD = open("/dev/rfd0", O_RDONLY);
292 if (CpioFD >= 0)
293 break;
294 msgDebug("Error on open of cpio floppy: %s (%d)\n", strerror(errno), errno);
295 }
296 j = fork();
297 if (!j) {
298 chdir("/");
299 msgNotify("Extracting contents of CPIO floppy...");
300 pipe(pfd);
301 zpid = fork();
302 if (!zpid) {
303 dup2(CpioFD, 0); close(CpioFD);
304 dup2(pfd[1], 1); close(pfd[1]);
360 if (CpioFD >= 0)
361 break;
362 msgDebug("Error on open of cpio floppy: %s (%d)\n", strerror(errno), errno);
363 }
364 j = fork();
365 if (!j) {
366 chdir("/");
367 msgNotify("Extracting contents of CPIO floppy...");
368 pipe(pfd);
369 zpid = fork();
370 if (!zpid) {
371 dup2(CpioFD, 0); close(CpioFD);
372 dup2(pfd[1], 1); close(pfd[1]);
373 if (DebugFD != -1)
374 dup2(DebugFD, 2);
305 close(pfd[0]);
306 i = execl("/stand/gunzip", "/stand/gunzip", 0);
307 msgDebug("/stand/gunzip command returns %d status\n", i);
308 exit(i);
309 }
310 cpid = fork();
311 if (!cpid) {
312 dup2(pfd[0], 0); close(pfd[0]);

--- 53 unchanged lines hidden ---
375 close(pfd[0]);
376 i = execl("/stand/gunzip", "/stand/gunzip", 0);
377 msgDebug("/stand/gunzip command returns %d status\n", i);
378 exit(i);
379 }
380 cpid = fork();
381 if (!cpid) {
382 dup2(pfd[0], 0); close(pfd[0]);

--- 53 unchanged lines hidden ---