summaryrefslogtreecommitdiffstats
path: root/docs
ModeNameSize
-rw-r--r--.cvsignore9logstatsplain
-rw-r--r--BUGS420logstatsplain
-rw-r--r--COPYING18007logstatsplain
-rw-r--r--HACKING3821logstatsplain
-rw-r--r--README15404logstatsplain
-rw-r--r--README.devel9849logstatsplain
-rw-r--r--SHORTCUTS1464logstatsplain
-rw-r--r--TODO17444logstatsplain
-rw-r--r--advocacy3122logstatsplain
-rw-r--r--comparisons1421logstatsplain
-rw-r--r--diskdrake.TODO1127logstatsplain
-rw-r--r--draknet_advanced_doc.txt7633logstatsplain
-rw-r--r--mdk-vs-redhat1381logstatsplain
-rw-r--r--object_class.fig1026logstatsplain
-rw-r--r--wizard.doc1082logstatsplain
82 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
/*
 * Guillaume Cottenceau (gc@mandrakesoft.com)
 *
 * Copyright 2000 Mandrakesoft
 *
 * 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.
 *
 */

/*
 * (1) calculate dependencies
 * (2) unarchive relevant modules
 * (3) insmod them
 */

#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mount.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include "stage1.h"
#include "log.h"
#include "utils.h"
#include "frontend.h"
#include "mount.h"
#include "modules_descr.h"
#include "zlibsupport.h"

#include "modules.h"

static struct module_deps_elem * modules_deps = NULL;

extern long init_module(void *, unsigned long, const char *);


static const char *moderror(int err)
{
	switch (err) {
	case ENOEXEC:
		return "Invalid module format";
	case ENOENT:
		return "Unknown symbol in module";
	case ESRCH:
		return "Module has wrong symbol version";
	case EINVAL:
		return "Invalid parameters";
	default:
		return strerror(err);
	}
}

int insmod_local_file(char * path, char * options)
{
	void *file;
	unsigned long len;
	int rc;
                
	if (IS_TESTING)
		return 0;

	file = grab_file(path, &len);
                
	if (!file) {
		log_perror(asprintf_("\terror reading %s", path));
		return -1;
	}
                
	rc = init_module(file, len, options ? options : "");
	if (rc)
		log_message("\terror: %s", moderror(errno));
	return rc;
}

static char *kernel_module_extension(void)
{
	return ".ko.gz";
}

static int load_modules_dependencies(void)
{
	char * deps_file = "/modules/modules.dep";
	char * buf, * ptr, * start, * end;
	struct stat s;
	int fd, line, i;

	log_message("loading modules dependencies");

	fd = open(deps_file, O_RDONLY);
	if (fd == -1) {
		log_perror(deps_file);
		return -1;
	}
	
	fstat(fd, &s);
	buf = alloca(s.st_size + 1);
	if (read(fd, buf, s.st_size) != (ssize_t)s.st_size) {