#!/usr/bin/perl use lib qw(/usr/lib/libDrakX); use standalone; use fs::remote::nfs; use fs::remote::smb; use MDK::Common::Func qw(if_); "@ARGV" =~ /-h/ and die "usage: lsnetdrake [-h] [--nfs] [--smb]\n"; my $nfs = !@ARGV || "@ARGV" =~ /-(nfs)/; my $smb = !@ARGV || "@ARGV" =~ /-(smb)/; $| = 1; $ENV{PATH} = "/sbin:/usr/sbin:$ENV{PATH}"; foreach my $class (if_($nfs, fs::remote::nfs->new), if_($smb, fs::remote::smb->new)) { foreach my $server (sort_names($class->find_servers)) { foreach (sort_names(eval { $class->find_exports($server) })) { print $class->to_fullstring($_), "\n"; } } } sub sort_names { sort { $a->{name} cmp $b->{name} } @_; } ref='/'>index : drakx
Mageia Installer and base platform for many utilitiesThierry Vignaud [tv]
summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/thirdparty.c
blob: 247b7e1f9b34d520f780eee515a0744e7b290110 (plain)
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
/*
 * Guillaume Cottenceau (gc@mandriva.com)
 * Olivier Blin (oblin@mandriva.com)
 *
 * Copyright 2005 Mandriva
 *
 * 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 <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/mount.h>
#include <sys/utsname.h>

#include "stage1.h"
#include "tools.h"
#include "utils.h"
#include "log.h"
#include "modules.h"
#include "mount.h"
#include "frontend.h"
#include "partition.h"
#include "automatic.h"
#include "probing.h"

#include "thirdparty.h"

#define THIRDPARTY_MOUNT_LOCATION "/tmp/thirdparty"

#define N_PCITABLE_ENTRIES 100
static struct pcitable_entry pcitable[N_PCITABLE_ENTRIES];
static int pcitable_len = 0;

static enum return_type thirdparty_choose_device(char ** device, int probe_only)
{
	char ** medias, ** medias_models;
	char ** ptr, ** ptr_models;
#ifndef DISABLE_DISK
	char ** disk_medias, ** disk_medias_models;
	int disk_count;
	char * parts[50];
	char * parts_comments[50];
#endif
#ifndef DISABLE_CDROM
	char ** cdrom_medias, ** cdrom_medias_models;
	int cdrom_count;
#endif
	char * floppy_dev;
	enum return_type results;
	int count = 0;

	wait_message("Looking for floppy, disk and cdrom devices ...");

#ifndef DISABLE_DISK
	disk_count = get_disks(&disk_medias, &disk_medias_models);
	count += disk_count;
#endif
#ifndef DISABLE_CDROM
        cdrom_count = get_cdroms(&cdrom_medias, &cdrom_medias_models);
        count += cdrom_count;
#endif

	floppy_dev = floppy_device();
	if (strstr(floppy_dev, "/dev/") == floppy_dev) {
		floppy_dev = floppy_dev + 5;
	}
	if (floppy_dev)
		count += 1;

	remove_wait_message();

	if (count == 0) {
		stg1_error_message("I can't find any floppy, disk or cdrom on this system. "
				   "No third-party kernel modules will be used.");
		return RETURN_BACK;
	}

	if (probe_only) {
#ifndef DISABLE_DISK
		free(disk_medias);
		free(disk_medias_models);
#endif
#ifndef DISABLE_CDROM
		free(cdrom_medias);
		free(cdrom_medias_models);
#endif
		return RETURN_OK;
	}

	ptr = medias = malloc((count + 1) * sizeof(char *));
	ptr_models =medias_models = malloc((count + 1) * sizeof(char *));
#ifndef DISABLE_DISK
	memcpy(ptr, disk_medias, disk_count * sizeof(char *));
	memcpy(ptr_models, disk_medias_models, disk_count * sizeof(char *));
	free(disk_medias);
	free(disk_medias_models);
	ptr += disk_count;
	ptr_models += disk_count;
#endif
#ifndef DISABLE_CDROM
	memcpy(ptr, cdrom_medias, cdrom_count * sizeof(char *));
	memcpy(ptr_models, cdrom_medias_models, cdrom_count * sizeof(char *));
	free(cdrom_medias);
	free(cdrom_medias_models);
	cdrom_medias = ptr; /* used later to know if a cdrom is selected */
	ptr += cdrom_count;
	ptr_models += cdrom_count;
#endif
	if (floppy_dev) {
		ptr[0] = floppy_dev;
		ptr_models[0] = "Floppy device";
		ptr++;
		ptr_models++;
 	}
	ptr[0] = NULL;
	ptr_models[0] = NULL;

	if (count == 1) {
		*device = medias[0];
	}  else {
		results = ask_from_list_comments("If you want to insert third-party kernel modules, "
						 "please select the disk containing the modules.",
						 medias, medias_models, device);
		if (results != RETURN_OK)
			return results;
	}
 
	if (streq(*device, floppy_dev)) {
		/* a floppy is selected, don't try to list partitions */
		return RETURN_OK;
	}

#ifndef DISABLE_CDROM
        for (ptr = cdrom_medias; ptr < cdrom_medias + cdrom_count; ptr++) {
		if (*device == *ptr) {
			/* a cdrom is selected, don't try to list partitions */
			log_message("thirdparty: a cdrom is selected, using it (%s)", *device);
			return RETURN_OK;
		}
	}
#endif

#ifndef DISABLE_DISK
	/* a disk or usb key is selected */
	if (list_partitions(*device, parts, parts_comments)) {
		stg1_error_message("Could not read partitions information.");
		return RETURN_ERROR;
	}

	if (parts[0] == NULL) {
		stg1_error_message("No partition found.");
		return RETURN_ERROR;
	}

	/* only one partition has been discovered, don't ask which one to use */
	if (parts[1] == NULL) {
		log_message("thirdparty: found only one partition on device (%s)", parts[0]);
		*device = parts[0];
		return RETURN_OK;
        }

	results = ask_from_list_comments("Please select the partition containing "
					 "the third party modules.",
					 parts, parts_comments, device);
	if (results == RETURN_OK)
		return RETURN_OK;
#endif

	stg1_error_message("Sorry, no third party device can be used.");

	return RETURN_BACK;
}


static enum return_type thirdparty_mount_device(char * device)
{
        log_message("third party: trying to mount device %s", device);
	if (try_mount(device, THIRDPARTY_MOUNT_LOCATION) != 0) {
		stg1_error_message("I can't mount the selected device (%s).", device);
		return RETURN_ERROR;
	}
	return RETURN_OK;
}