Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 181685 | Differences between
and this patch

Collapse All | Expand All

(-)mkinitrd-4.2.1.10.reiserfs/nash/nash.8 (-9 / +30 lines)
Lines 38-44 Link Here
38
38
39
.TP
39
.TP
40
\fBfind \fIdir\fR -name \fIname\fR
40
\fBfind \fIdir\fR -name \fIname\fR
41
Display the path to files named \fIname\fR in or below directory \fIdir\FR.
41
Display the path to files named \fIname\fR in or below directory \fIdir\fR.
42
This is a \fBvery\fR limited implementation of find(1).
42
This is a \fBvery\fR limited implementation of find(1).
43
43
44
.TP
44
.TP
Lines 47-52 Link Here
47
system. If none is available, no output is displayed.
47
system. If none is available, no output is displayed.
48
48
49
.TP
49
.TP
50
\fBinsmod\fR \fImodule\fR [ \fImodule options\fR ... ]
51
Inserts a module into the kernel.
52
53
.TP
50
\fBlosetup \fI/dev/loopdev\fR \fIfile\fR
54
\fBlosetup \fI/dev/loopdev\fR \fIfile\fR
51
Binds \fIfile\fR to the loopback device \fI/dev/loopdev\fR. See
55
Binds \fIfile\fR to the loopback device \fI/dev/loopdev\fR. See
52
\fBlosetup(8)\fR for information on loopback devices.
56
\fBlosetup(8)\fR for information on loopback devices.
Lines 84-93 Link Here
84
the device number.
88
the device number.
85
89
86
.TP
90
.TP
87
\fBmount \fI[--ro]\fR -o \fIopts\fR -t \fItype\fR \fIdevice\fR \fImntpoint\fR
91
\fBmount\fR [ --ro ] -o \fIopts\fR -t \fItype\fR \fIdevice\fR \fImntpoint\fR
88
Mounts a filesystem. It does not support NFS, and it must be used in
92
Mounts a filesystem. It does not support NFS, and it must be used in
89
the form given above (arguments must go first).  If \fIdevice\fR is of the form
93
the form given above (arguments must go first).  If \fIdevice\fR is of the form
90
\fBLABEL=\fIfoo\fR the devices listed in /fB/proc/partitions\fR will
94
\fBLABEL=\fIfoo\fR the devices listed in \fB/proc/partitions\fR will
91
be searched, and the first device with a volume label of \fIfoo\fR will
95
be searched, and the first device with a volume label of \fIfoo\fR will
92
be mounted. Normal \fBmount\fR(2) options are supported, and \fB--ro\fR will
96
be mounted. Normal \fBmount\fR(2) options are supported, and \fB--ro\fR will
93
mount the filesystem read only for compatibility with older versions of nash.
97
mount the filesystem read only for compatibility with older versions of nash.
Lines 99-111 Link Here
99
and mounts the current root filesystem as \fIoldrootpath\fR.
103
and mounts the current root filesystem as \fIoldrootpath\fR.
100
104
101
.TP
105
.TP
106
\fBraidautorun \fImddevice\fR
107
Runs raid autodetection on all raid-typed partitions. \fImddevice\fR must
108
be a raid device (any will do).
109
110
.TP
102
\fBreadlink \fIpath\fR
111
\fBreadlink \fIpath\fR
103
Displays the value of the symbolic link \fIpath\fR.
112
Displays the value of the symbolic link \fIpath\fR.
104
113
105
.TP
114
.TP
106
\fBraidautorun \fImddevice\fR
115
\fBrm\fR [ -r | -n ] \fIpath\fR [ [ -r | -n ] \fIpath2\fR [ ... ] ]
107
Runs raid autodetection on all raid-typed partitions. \fImddevice\fR must
116
Removes file(s) or directory(s) \fIpath1\fR, \fIpath2\fR... 
108
be a raid device (any will do).
117
If specified \fI-r\fR key then rm enters to subdirectories
118
recursively. \fI-n\fR key disables recursion.
119
120
.TP
121
\fBrmdir \fIpath1\fR [ \fIpath2\fR [ ... ] ]
122
Removes empty directory(s) \fIpath1\fR, \fIpath2\fR...
109
123
110
.TP
124
.TP
111
\fBsetquiet\fR
125
\fBsetquiet\fR
Lines 120-134 Link Here
120
Sleep for \fInum\fR seconds
134
Sleep for \fInum\fR seconds
121
135
122
.TP
136
.TP
137
\fBstabilized\fR [ --iterations \fIN\fR ] [ --interval \fIMSECS\fR ] \fIfile\fR
138
139
.TP
123
\fBswitchroot \fInewrootpath\fR
140
\fBswitchroot \fInewrootpath\fR
124
Makes the filesystem mounted at \fInewrootpath\fR the new root
141
Unmounts \fI/dev\fR, \fI/proc\fR and \fI/sys\fR, removes them and makes the filesystem
125
filesystem by moving the mountpoint.  This will only work in 2.6 or
142
mounted at \fInewrootpath\fR the new root filesystem by moving the mountpoint.
126
later kernels.
143
This will only work in 2.6 or later kernels.
127
144
128
.TP
145
.TP
129
\fBumount \fIpath\fR
146
\fBumount \fIpath\fR
130
Unmounts the filesystem mounted at \fIpath\fR.
147
Unmounts the filesystem mounted at \fIpath\fR.
131
148
149
.TP
150
\fBunlink \fIfile\fR [ \fIfile2\fR [ ... ] ]\fR
151
Removes file(s) \fIfile\fR, \fIfile2\fR...
152
132
.SH RETURN VALUE
153
.SH RETURN VALUE
133
Returns 0 is the last command succeeded or 1 if it failed.
154
Returns 0 is the last command succeeded or 1 if it failed.
134
155
(-)mkinitrd-4.2.1.10.reiserfs/nash/nash.c (+144 lines)
Lines 771-776 Link Here
771
    return 0;
771
    return 0;
772
}
772
}
773
773
774
int doRm(const char *path, int recursive);
775
774
#define MAX_INIT_ARGS 32
776
#define MAX_INIT_ARGS 32
775
/* 2.6 magic not-pivot-root but kind of similar stuff.
777
/* 2.6 magic not-pivot-root but kind of similar stuff.
776
 * This is based on code from klibc/utils/run_init.c
778
 * This is based on code from klibc/utils/run_init.c
Lines 807-812 Link Here
807
    if (init == NULL)
809
    if (init == NULL)
808
        cmdline = getKernelCmdLine();
810
        cmdline = getKernelCmdLine();
809
811
812
	doRm("/dev", 1);
813
	umount("/proc");
814
	rmdir("/proc");
815
	umount("/sys");
816
	rmdir("/sys");
817
810
    if (mount(".", "/", NULL, MS_MOVE, NULL)) {
818
    if (mount(".", "/", NULL, MS_MOVE, NULL)) {
811
        printf("switchroot: mount failed: %d\n", errno);
819
        printf("switchroot: mount failed: %d\n", errno);
812
        return 1;
820
        return 1;
Lines 1556-1561 Link Here
1556
    return 0;
1564
    return 0;
1557
}
1565
}
1558
1566
1567
int doRm(const char *path, int recursive) {
1568
	struct stat st;
1569
	int result = 0;
1570
	stat(path, &st);
1571
	if ( S_ISDIR(st.st_mode) ) {
1572
		if (recursive) {
1573
			DIR *dir = opendir(path);
1574
			if (dir) {
1575
				size_t np_size = 0;
1576
				char * new_path = NULL;
1577
				struct dirent *de;
1578
				while( (de = readdir(dir)) ) {
1579
					if ( strcmp(de->d_name, "..") && strcmp(de->d_name, ".") )  {	// do not delete ".." and "." entries
1580
						const size_t new_size = strlen(de->d_name) + strlen(path) + 2;
1581
						if (new_size > np_size) {
1582
							np_size = new_size;
1583
							new_path = (char*)realloc(new_path, np_size);
1584
						}
1585
						strncpy(new_path, path, np_size);
1586
						strcat(new_path, "/");
1587
						strcat(new_path, de->d_name);
1588
						doRm(new_path, recursive);
1589
					}
1590
				}
1591
				free(new_path);
1592
				closedir(dir);
1593
			}
1594
		}
1595
		result = rmdir(path);
1596
	} else
1597
		result = unlink(path);
1598
	
1599
	if (result != 0)
1600
		printf("rm: unable to remove \"%s\": %d\n", path, errno);
1601
	return result;
1602
}
1603
1604
int rmCommand(char * cmd, char * end) {
1605
	int recursive = 0;
1606
	char *arg;
1607
	while( (cmd = getArg(cmd, end, &arg)) ) {
1608
		if ( !strcmp("-r", arg) )
1609
			recursive = 1;
1610
		else if ( !strcmp("-n", arg) )
1611
			recursive = 0;
1612
		else
1613
			doRm(arg, recursive);
1614
	}
1615
	return 0;
1616
}
1617
1618
int rmdirCommand(char * cmd, char * end) {
1619
	char *path;
1620
	int result = -1;
1621
	while( (cmd = getArg(cmd, end, &path)) ) {
1622
		if (result < 0)
1623
			result = 1;
1624
		if ( rmdir(path) )
1625
			printf("rmdir: unable to delete \"%s\": %d\n", path, errno);
1626
		else
1627
			result = 0;
1628
	}
1629
	return result;
1630
}
1631
1632
int unlinkCommand(char * cmd, char * end) {
1633
	char *path;
1634
	int result = -1;
1635
	while( (cmd = getArg(cmd, end, &path)) ) {
1636
		if (result < 0)
1637
			result = 1;
1638
		if ( unlink(path) )
1639
			printf("unlink: unable to delete \"%s\": %d\n", path, errno);
1640
		else
1641
			result = 0;
1642
	}
1643
	return result;
1644
}
1645
1646
extern long init_module(void*, unsigned long, const char *);
1647
1648
int insmodCommand(char * cmd, char * end) {
1649
	char *modname;
1650
	int fd;
1651
	int result = 1;
1652
	if ( !(cmd = getArg(cmd, end, &modname)) ) {
1653
		printf("insmod: path expected\n");
1654
		return 1;
1655
	}
1656
	if ( (fd = open(modname, O_RDONLY) ) < 0) {
1657
		printf("insmod: unable to open \"%s\": %d\n", modname, errno);
1658
		return 1;
1659
	}
1660
	do {
1661
		void *buffer;
1662
		off_t modsize = lseek(fd, 0, SEEK_END);
1663
		if (modsize == (off_t)-1) {
1664
			printf("insmod: unable to determine module \"%s\" size: %d\n", modname, errno);
1665
			break;
1666
		}
1667
1668
		buffer = malloc(modsize);
1669
		if (buffer == NULL) {
1670
			printf("insmod: unable to allocate memory for \"%s\": %d\n", modname, errno);
1671
			break;
1672
		}
1673
1674
		lseek(fd, 0, SEEK_SET);
1675
		if ( read(fd, buffer, modsize) != modsize) {
1676
			printf("insmod: unable to read \"%s\": %d\n", modname, errno);
1677
			free(buffer);
1678
			break;
1679
		}
1680
1681
		*end = '\0';
1682
		if (init_module(buffer, modsize, (cmd < end) ? cmd : "") ) {
1683
			printf("insmod: unable to insert module \"%s %s\": %d\n", modname, cmd, errno);
1684
			free(buffer);
1685
			break;
1686
		}
1687
1688
		result = 0;
1689
	} while(0);
1690
1691
	close(fd);
1692
	return result;
1693
}
1694
1559
int runStartup(int fd) {
1695
int runStartup(int fd) {
1560
    char contents[32768];
1696
    char contents[32768];
1561
    int i;
1697
    int i;
Lines 1645-1650 Link Here
1645
            rc = readlinkCommand(chptr, end);
1781
            rc = readlinkCommand(chptr, end);
1646
        else if (!strncmp(start, "setquiet", MAX(8, chptr-start)))
1782
        else if (!strncmp(start, "setquiet", MAX(8, chptr-start)))
1647
            rc = setQuietCommand(chptr, end);
1783
            rc = setQuietCommand(chptr, end);
1784
	else if (!strncmp(start, "rm", MAX(2, chptr-start)))
1785
		rc = rmCommand(chptr, end);
1786
	else if (!strncmp(start, "insmod", MAX(6, chptr - start)))
1787
		rc = insmodCommand(chptr, end);
1788
	else if (!strncmp(start, "unlink", MAX(6, chptr - start)))
1789
		rc = unlinkCommand(chptr, end);
1790
	else if (!strncmp(start, "rmdir", MAX(5, chptr - start)))
1791
		rc = rmdirCommand(chptr, end);
1648
#ifdef DEBUG
1792
#ifdef DEBUG
1649
        else if (!strncmp(start, "cat", MAX(3, chptr-start)))
1793
        else if (!strncmp(start, "cat", MAX(3, chptr-start)))
1650
            rc = catCommand(chptr, end);
1794
            rc = catCommand(chptr, end);
(-)mkinitrd-4.2.1.10.orig/mkinitrd (-1 / +17 lines)
Lines 518-523 Link Here
518
rootfs=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $3; exit }}' $fstab)
518
rootfs=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $3; exit }}' $fstab)
519
rootopts=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $4; exit }}' $fstab)
519
rootopts=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $4; exit }}' $fstab)
520
520
521
# in case the root filesystem in fstab set to `auto'
522
if [ "$rootfs" == "auto" ]; then
523
	echo "Warning: root filesystem type in fstab is 'auto'." >&2
524
	while read MNT_LINE; do
525
		if [ "`echo $MNT_LINE | cut --delimiter=' ' --field=2`" == "/" ]; then
526
			rootfs="`echo $MNT_LINE | cut --delimiter=' ' --field=3`"
527
			test "$rootfs" != "rootfs" && break
528
		fi
529
	done < /proc/mounts
530
fi
531
521
# in case the root filesystem is modular
532
# in case the root filesystem is modular
522
findmodule -${rootfs}
533
findmodule -${rootfs}
523
534
Lines 601-610 Link Here
601
ln -s bin $MNTIMAGE/sbin
612
ln -s bin $MNTIMAGE/sbin
602
613
603
inst /sbin/nash "$MNTIMAGE/bin/nash"
614
inst /sbin/nash "$MNTIMAGE/bin/nash"
604
inst /sbin/insmod.static "$MNTIMAGE/bin/insmod"
615
strip --strip-all "$MNTIMAGE/bin/nash"
605
ln -s /sbin/nash $MNTIMAGE/sbin/modprobe
616
ln -s /sbin/nash $MNTIMAGE/sbin/modprobe
606
617
607
if [ -n "$USE_UDEV" ]; then
618
if [ -n "$USE_UDEV" ]; then
619
	inst /sbin/insmod.static "$MNTIMAGE/bin/insmod"
608
    inst /sbin/udev.static $MNTIMAGE/sbin/udev
620
    inst /sbin/udev.static $MNTIMAGE/sbin/udev
609
    ln -s udev $MNTIMAGE/sbin/udevstart
621
    ln -s udev $MNTIMAGE/sbin/udevstart
610
    mkdir -p $MNTIMAGE/etc/udev
622
    mkdir -p $MNTIMAGE/etc/udev
Lines 788-793 Link Here
788
800
789
    [  -n "$UDEV_KEEP_DEV" ] && echo "mount -t tmpfs --bind /dev /sysroot/dev" >> $RCFILE
801
    [  -n "$UDEV_KEEP_DEV" ] && echo "mount -t tmpfs --bind /dev /sysroot/dev" >> $RCFILE
790
802
803
	echo "echo Removing temporary files" >> $RCFILE
804
	echo "rm -r /bin /etc /init /lib /loopfs" >> $RCFILE
805
	echo "unlink /sbin" >> $RCFILE
806
791
    echo "echo Switching to new root" >> $RCFILE
807
    echo "echo Switching to new root" >> $RCFILE
792
    echo "switchroot /sysroot" >> $RCFILE
808
    echo "switchroot /sysroot" >> $RCFILE
793
else 
809
else 

Return to bug 181685