Deleted Added
full compact
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.2 1995/04/27 18:03:53 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
16 * notice, this list of conditions and the following disclaimer,
17 * verbatim and that no modifications are made prior to this
18 * point in the file.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 * 3. All advertising materials mentioning features or use of this software
23 * must display the following acknowledgement:
24 * This product includes software developed by Jordan Hubbard
25 * for the FreeBSD Project.
26 * 4. The name of Jordan Hubbard or the FreeBSD project may not be used to
27 * endorse or promote products derived from this software without specific
28 * prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY JORDAN HUBBARD ``AS IS'' AND
31 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED. IN NO EVENT SHALL JORDAN HUBBARD OR HIS PETS BE LIABLE
34 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36 * OR SERVICES; LOSS OF USE, DATA, LIFE OR PROFITS; OR BUSINESS INTERRUPTION)
37 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 * SUCH DAMAGE.
41 *
42 */
43
44#include "sysinstall.h"
45#include "libdisk.h"
46
47/* Get all device information for a given device class */
48Device *
49device_get_all(DeviceType which, int *ndevs)
50{
51 char **names;
52 Device *devs = NULL;
53
54 *ndevs = 0;
55 if (which == DEVICE_TYPE_DISK || which == DEVICE_TYPE_ANY) {
56 if ((names = Disk_Names()) != NULL) {
57 int i;
58
59 for (i = 0; names[i]; i++)
60 ++*ndevs;
61 devs = safe_malloc(sizeof(Device) * (*ndevs + 1));
62 for (i = 0; names[i]; i++) {
63 strcpy(devs[i].name, names[i]);
64 devs[i].type = DEVICE_TYPE_DISK;
65 }
66 devs[i].name[0] = '\0';
67 free(names);
68 }
69 }
70 /* put detection for other classes here just as soon as I figure out how */
71 return devs;
72}
73
74void
75device_print_chunk(struct chunk *c1, int offset, int *row)
76{
77 CHAR_N
78
79 if (!c1)
80 return;
81 mvprintw(*row++, offset, "%10lu %10lu %10lu %-8s %d %-8s %4d %lx",
82 c1->offset, c1->size, c1->end, c1->name, c1->type,
83 chunk_n[c1->type], c1->subtype, c1->flags);
84 device_print_chunk(c1->part, offset + 2, row);
85 device_print_chunk(c1->next, offset, row);
86}
87
88int
89device_slice_disk(char *disk)
90{
91 struct disk *d;
92 char *p;
93 int row;
94
95 d = Open_Disk(disk);
96 if (!d)
97 msgFatal("Couldn't open disk `%s'!", disk);
98 p = CheckRules(d);
99 if (p) {
100 msgConfirm(p);
101 free(p);
102 }
103 dialog_clear();
104 while (1) {
105 clear();
106 mvprintw(0, 0, "Disk name: %s, Flags: %lx", disk, d->flags);
107 mvprintw(1, 0,
108 "Real Geometry: %lu/%lu/%lu, BIOS Geometry: %lu/%lu/%lu [cyls/heads/sectors]",
109 d->real_cyl, d->real_hd, d->real_sect,
110 d->bios_cyl, d->bios_hd, d->bios_sect);
111 mvprintw(4, 0, "%10s %10s %10s %-8s %4s %-8s %4s %4s",
112 "Offset", "Size", "End", "Name", "PType", "Desc",
113 "Subtype", "Flags");
114 row = 5;
115 device_print_chunk(d->chunks, 0, &row);
116 move(23, 0);
117 addstr("Done!");
118 if (getch() == 'q')
119 return 0;
120 }
121 return 0;
122}