View | Details | Raw Unified | Return to bug 149803
Collapse All | Expand All

(-)etc/rc.d/root (+10 lines)
Lines 36-41 Link Here
36
	if [ -x /sbin/nextboot ]; then
36
	if [ -x /sbin/nextboot ]; then
37
		/sbin/nextboot -D > /dev/null 2>&1
37
		/sbin/nextboot -D > /dev/null 2>&1
38
	fi
38
	fi
39
40
	# Create rootdev link
41
	rootmnt=`kenv vfs.root.mountfrom`
42
	rootdev=${rootmnt#*:}
43
	(
44
	cd /dev
45
	if [ -e "${rootdev}" ]; then
46
		ln -s ${rootdev} rootdev
47
	fi
48
	)
39
}
49
}
40
50
41
load_rc_config $name
51
load_rc_config $name
(-)lib/libstand/ioctl.c (-7 / +27 lines)
Lines 64-69 Link Here
64
__FBSDID("$FreeBSD$");
64
__FBSDID("$FreeBSD$");
65
65
66
#include "stand.h"
66
#include "stand.h"
67
#include "saioctl.h"
67
68
68
int
69
int
69
ioctl(fd, cmd, arg)
70
ioctl(fd, cmd, arg)
Lines 77-88 Link Here
77
		errno = EBADF;
78
		errno = EBADF;
78
		return (-1);
79
		return (-1);
79
	}
80
	}
80
	if (f->f_flags & F_RAW) {
81
	switch (SAIO_LAYER(cmd)) {
81
		errno = (f->f_dev->dv_ioctl)(f, cmd, arg);
82
		case SAIO_DEV:
82
		if (errno)
83
			if (f->f_flags & F_RAW)
83
			return (-1);
84
				errno = (f->f_dev->dv_ioctl)(f, cmd, arg);
84
		return (0);
85
			else
86
				errno = EIO;
87
			break;
88
		case SAIO_FS:
89
			switch (cmd) {
90
				case SAIOGFSTYPE:
91
					*(const char **)arg = f->f_ops->fs_name;
92
					errno = 0;
93
					break;
94
				case SAIOGFSLABEL:
95
					*(const char **)arg = f->f_labeldev;
96
					errno = 0;
97
					break;
98
				default:
99
					errno = EINVAL;
100
			}
101
			break;
102
		default:
103
			errno = EINVAL;
85
	}
104
	}
86
	errno = EIO;
105
	if (errno)
87
	return (-1);
106
		return (-1);
107
	return (0);
88
}
108
}
(-)lib/libstand/ext2fs.c (+9 lines)
Lines 386-391 Link Here
386
	fs->fs_ipb = fs->fs_bsize / fs->fs_isize;
386
	fs->fs_ipb = fs->fs_bsize / fs->fs_isize;
387
	fs->fs_fsbtodb = (fs->fs_bsize / DEV_BSIZE) - 1;
387
	fs->fs_fsbtodb = (fs->fs_bsize / DEV_BSIZE) - 1;
388
388
389
	if (fs->fs_fd.fd_volname[0] != '\0') {
390
		sprintf(namebuf, "/dev/ext2fs/%s", fs->fs_fd.fd_volname);
391
		f->f_labeldev = strdup(namebuf);
392
	}
393
389
	/*
394
	/*
390
	 * we have to load in the "group descriptors" here
395
	 * we have to load in the "group descriptors" here
391
	 */
396
	 */
Lines 794-799 Link Here
794
	struct file *fp = (struct file *)f->f_fsdata;
799
	struct file *fp = (struct file *)f->f_fsdata;
795
	int level;
800
	int level;
796
801
802
	if (f->f_labeldev != NULL) {
803
		free(f->f_labeldev);
804
		f->f_labeldev = NULL;
805
	}
797
	f->f_fsdata = (void *)0;
806
	f->f_fsdata = (void *)0;
798
	if (fp == (struct file *)0)
807
	if (fp == (struct file *)0)
799
		return (0);
808
		return (0);
(-)lib/libstand/Makefile (-1 / +1 lines)
Lines 12-18 Link Here
12
LIB=		stand
12
LIB=		stand
13
NO_PROFILE=
13
NO_PROFILE=
14
NO_PIC=
14
NO_PIC=
15
INCS=		stand.h
15
INCS=		stand.h saioctl.h
16
MAN=		libstand.3
16
MAN=		libstand.3
17
17
18
CFLAGS+= -ffreestanding -Wformat
18
CFLAGS+= -ffreestanding -Wformat
(-)lib/libstand/ufs.c (+11 lines)
Lines 538-543 Link Here
538
		goto out;
538
		goto out;
539
	}
539
	}
540
	/*
540
	/*
541
	 * Find a unique device name.
542
	 */
543
	if (fs->fs_volname[0] != '\0') {
544
		sprintf (namebuf, "/dev/ufs/%s", fs->fs_volname);
545
	} else {
546
		sprintf (namebuf, "/dev/ufsid/%08x%08x", fs->fs_id[0], fs->fs_id[1]);
547
	}
548
	f->f_labeldev = strdup(namebuf);
549
	/*
541
	 * Calculate indirect block levels.
550
	 * Calculate indirect block levels.
542
	 */
551
	 */
543
	{
552
	{
Lines 711-716 Link Here
711
	if (fp->f_buf)
720
	if (fp->f_buf)
712
		free(fp->f_buf);
721
		free(fp->f_buf);
713
	free(fp->f_fs);
722
	free(fp->f_fs);
723
	free(f->f_labeldev);
724
	f->f_labeldev = NULL;
714
	free(fp);
725
	free(fp);
715
	return (0);
726
	return (0);
716
}
727
}
(-)lib/libstand/open.c (-1 lines)
Lines 123-129 Link Here
123
123
124
	error = ((*file_system[i]).fo_open)(file, f);
124
	error = ((*file_system[i]).fo_open)(file, f);
125
	if (error == 0) {
125
	if (error == 0) {
126
	    
127
	    f->f_ops = file_system[i];
126
	    f->f_ops = file_system[i];
128
	    o_rainit(f);
127
	    o_rainit(f);
129
	    return (fd);
128
	    return (fd);
(-)lib/libstand/saioctl.h (-15 / +27 lines)
Lines 33-50 Link Here
33
 * $FreeBSD$
33
 * $FreeBSD$
34
 */
34
 */
35
35
36
/* ioctl's -- for disks just now */
36
/* ioctl's */
37
#define	SAIOHDR		(('d'<<8)|1)	/* next i/o includes header */
37
38
#define	SAIOCHECK	(('d'<<8)|2)	/* next i/o checks data */
38
#define SAIO_LAYER(cmd) (cmd & 0xf0000000)
39
#define	SAIOHCHECK	(('d'<<8)|3)	/* next i/o checks header & data */
39
#define SAIO_DEV (0 << 28)
40
#define	SAIONOBAD	(('d'<<8)|4)	/* inhibit bad sector forwarding */
40
#define SAIO_FS  (1 << 28)
41
#define	SAIODOBAD	(('d'<<8)|5)	/* enable bad sector forwarding */
41
42
#define	SAIOECCLIM	(('d'<<8)|6)	/* set limit to ecc correction, bits */
42
/* DEV layer */
43
#define	SAIOECCUNL	(('d'<<8)|7)	/* use standard ecc procedures */
43
44
#define	SAIORETRIES	(('d'<<8)|8)	/* set retry count for unit */
44
#define	SAIOHDR		(SAIO_DEV|('d'<<8)|1)	/* next i/o includes header */
45
#define	SAIODEVDATA	(('d'<<8)|9)	/* get pointer to pack label */
45
#define	SAIOCHECK	(SAIO_DEV|('d'<<8)|2)	/* next i/o checks data */
46
#define	SAIOSSI		(('d'<<8)|10)	/* set skip sector inhibit */
46
#define	SAIOHCHECK	(SAIO_DEV|('d'<<8)|3)	/* next i/o checks header & data */
47
#define	SAIONOSSI	(('d'<<8)|11)	/* inhibit skip sector handling */
47
#define	SAIONOBAD	(SAIO_DEV|('d'<<8)|4)	/* inhibit bad sector forwarding */
48
#define	SAIOSSDEV	(('d'<<8)|12)	/* is device skip sector type? */
48
#define	SAIODOBAD	(SAIO_DEV|('d'<<8)|5)	/* enable bad sector forwarding */
49
#define	SAIODEBUG	(('d'<<8)|13)	/* enable/disable debugging */
49
#define	SAIOECCLIM	(SAIO_DEV|('d'<<8)|6)	/* set limit to ecc correction, bits */
50
#define	SAIOGBADINFO	(('d'<<8)|14)	/* get bad-sector table */
50
#define	SAIOECCUNL	(SAIO_DEV|('d'<<8)|7)	/* use standard ecc procedures */
51
#define	SAIORETRIES	(SAIO_DEV|('d'<<8)|8)	/* set retry count for unit */
52
#define	SAIODEVDATA	(SAIO_DEV|('d'<<8)|9)	/* get pointer to pack label */
53
#define	SAIOSSI		(SAIO_DEV|('d'<<8)|10)	/* set skip sector inhibit */
54
#define	SAIONOSSI	(SAIO_DEV|('d'<<8)|11)	/* inhibit skip sector handling */
55
#define	SAIOSSDEV	(SAIO_DEV|('d'<<8)|12)	/* is device skip sector type? */
56
#define	SAIODEBUG	(SAIO_DEV|('d'<<8)|13)	/* enable/disable debugging */
57
#define	SAIOGBADINFO	(SAIO_DEV|('d'<<8)|14)	/* get bad-sector table */
58
59
/* FS layer */
60
61
#define SAIOGFSTYPE	(SAIO_FS|('f'<<8)|1)	/* get file system type */
62
#define SAIOGFSLABEL	(SAIO_FS|('f'<<8)|2)	/* get unique device name */
(-)lib/libstand/cd9660.c (+6 lines)
Lines 276-281 Link Here
276
	struct iso_directory_record rec;
276
	struct iso_directory_record rec;
277
	struct iso_directory_record *dp = 0;
277
	struct iso_directory_record *dp = 0;
278
	int rc, first, use_rrip, lenskip;
278
	int rc, first, use_rrip, lenskip;
279
	char labelbuf[64];
279
280
280
	/* First find the volume descriptor */
281
	/* First find the volume descriptor */
281
	buf = malloc(buf_size = ISO_DEFAULT_BLOCK_SIZE);
282
	buf = malloc(buf_size = ISO_DEFAULT_BLOCK_SIZE);
Lines 301-306 Link Here
301
	if (isonum_723(vd->logical_block_size) != ISO_DEFAULT_BLOCK_SIZE)
302
	if (isonum_723(vd->logical_block_size) != ISO_DEFAULT_BLOCK_SIZE)
302
		goto out;
303
		goto out;
303
304
305
	sprintf(labelbuf, "/dev/iso9660/%s", vd->volume_id);
306
	f->f_labeldev = strdup(labelbuf);
307
304
	rec = *(struct iso_directory_record *) vd->root_directory_record;
308
	rec = *(struct iso_directory_record *) vd->root_directory_record;
305
	if (*path == '/') path++; /* eat leading '/' */
309
	if (*path == '/') path++; /* eat leading '/' */
306
310
Lines 410-415 Link Here
410
{
414
{
411
	struct file *fp = (struct file *)f->f_fsdata;
415
	struct file *fp = (struct file *)f->f_fsdata;
412
416
417
	free(f->f_labeldev);
418
	f->f_labeldev = NULL;
413
	f->f_fsdata = 0;
419
	f->f_fsdata = 0;
414
	free(fp);
420
	free(fp);
415
421
(-)lib/libstand/stand.h (+1 lines)
Lines 164-169 Link Here
164
    char		*f_rabuf;	/* readahead buffer pointer */
164
    char		*f_rabuf;	/* readahead buffer pointer */
165
    size_t		f_ralen;	/* valid data in readahead buffer */
165
    size_t		f_ralen;	/* valid data in readahead buffer */
166
    off_t		f_raoffset;	/* consumer offset in readahead buffer */
166
    off_t		f_raoffset;	/* consumer offset in readahead buffer */
167
    char		*f_labeldev;	/* unique device name for this file system */
167
#define SOPEN_RASIZE	512
168
#define SOPEN_RASIZE	512
168
};
169
};
169
170
(-)sys/boot/common/boot.c (-3 / +24 lines)
Lines 32-37 Link Here
32
 */
32
 */
33
33
34
#include <stand.h>
34
#include <stand.h>
35
#include <sys/ioctl.h>
36
#include <saioctl.h>
35
#include <string.h>
37
#include <string.h>
36
38
37
#include "bootstrap.h"
39
#include "bootstrap.h"
Lines 361-371 Link Here
361
		cp++;
363
		cp++;
362
	*cp = 0;
364
	*cp = 0;
363
	options = strdup(ep);
365
	options = strdup(ep);
364
	/* Build the <fstype>:<device> and save it in vfs.root.mountfrom */
366
365
	sprintf(lbuf, "%s:%s", fstyp, dev);
367
	/* Build the <fstype>:<device> and save it in vfs.root.mountfrom,
368
	 * except if dev is special value "/dev/rootdev", in which case
369
	 * we rely to the value determined below to provide the proper
370
	 * device name.
371
	 */
372
	if (strcmp (dev, "/dev/rootdev")) {
373
		sprintf(lbuf, "%s:%s", fstyp, dev);
374
		setenv("vfs.root.mountfrom", lbuf, 0);
375
	}
366
	free(dev);
376
	free(dev);
367
	free(fstyp);
377
	free(fstyp);
368
	setenv("vfs.root.mountfrom", lbuf, 0);
369
378
370
	/* Don't override vfs.root.mountfrom.options if it is already set */
379
	/* Don't override vfs.root.mountfrom.options if it is already set */
371
	if (getenv("vfs.root.mountfrom.options") == NULL) {
380
	if (getenv("vfs.root.mountfrom.options") == NULL) {
Lines 376-381 Link Here
376
	error = 0;
385
	error = 0;
377
	break;
386
	break;
378
    }
387
    }
388
389
    if (getenv("vfs.root.mountfrom") == NULL) {
390
	/* Try to get device name from on-disk label */
391
	if (ioctl(fd, SAIOGFSTYPE, &fstyp) == 0 &&
392
	    ioctl(fd, SAIOGFSLABEL, &dev)  == 0)
393
	{
394
		sprintf(lbuf, "%s:%s", fstyp, dev);
395
		setenv("vfs.root.mountfrom", lbuf, 0);
396
		error = 0;
397
	}
398
    }
399
379
    close(fd);
400
    close(fd);
380
    return(error);
401
    return(error);
381
}
402
}

Return to bug 149803