mirror of
https://github.com/fspc/gbootroot.git
synced 2025-02-23 09:03:23 -05:00
This is the beginnings of non-root ext2 root_fs creation with Erick Anderson's
most recently revised genext2fs.
This commit is contained in:
parent
22300ca6bf
commit
2726b68559
@ -792,44 +792,56 @@ sub create_filesystem {
|
|||||||
my $file;
|
my $file;
|
||||||
my $error;
|
my $error;
|
||||||
|
|
||||||
|
my $fs_type = (split(/\s/,$main::makefs))[0];
|
||||||
|
|
||||||
info(0, "Creating root filesystem.\n");
|
info(0, "Creating root filesystem.\n");
|
||||||
info(0, "Description: $fs_size K ext2 file system\n");
|
info(0, "Description: $fs_size K root file system\n");
|
||||||
info(0, "Where: $device\n");
|
info(0, "Where: $device\n");
|
||||||
|
|
||||||
sync();
|
# Maybe other fs will be represented in the future, but genext2fs is all
|
||||||
sys("dd if=/dev/zero of=$device bs=1k count=$fs_size");
|
# that exists now for non-root users.
|
||||||
sync();
|
if ( $fs_type ne "genext2fs" ) {
|
||||||
|
|
||||||
if (-f $device) {
|
sync();
|
||||||
##### If device is a plain file, it means we're using some loopback
|
sys("dd if=/dev/zero of=$device bs=1k count=$fs_size");
|
||||||
##### device. Use -F switch in mke2fs so it won't complain.
|
sync();
|
||||||
## Options here can be changed.
|
|
||||||
## Originally, this was -b 1024 switched with the inode approach.
|
if (-f $device) {
|
||||||
|
##### If device is a plain file, it means we're using some
|
||||||
|
##### loopback device. Use -F switch in mke2fs so it
|
||||||
|
##### won't complain.
|
||||||
|
## Options here can be changed.
|
||||||
|
## Originally, this was -b 1024 switched with the inode approach.
|
||||||
if (sys("$main::makefs $device $fs_size") !~
|
if (sys("$main::makefs $device $fs_size") !~
|
||||||
/^0$/ ) {
|
/^0$/ ) {
|
||||||
my $fs_type = (split(/\s/,$main::makefs))[0];
|
|
||||||
$error = error("Can not $fs_type filesystem.");
|
$error = error("Can not $fs_type filesystem.");
|
||||||
return "ERROR" if $error && $error eq "ERROR";
|
return "ERROR" if $error && $error eq "ERROR";
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (sys("$main::makefs $device $fs_size") !~
|
if (sys("$main::makefs $device $fs_size") !~
|
||||||
/^0$/ ) {
|
/^0$/ ) {
|
||||||
my $fs_type = (split(/\s/,$main::makefs))[0];
|
|
||||||
$error = error("Can not $fs_type filesystem.");
|
$error = error("Can not $fs_type filesystem.");
|
||||||
return "ERROR" if $error && $error eq "ERROR";
|
return "ERROR" if $error && $error eq "ERROR";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!-d $mount_point) {
|
if (!-d $mount_point) {
|
||||||
return "ERROR" if errmk(sys("mkdir $mount_point")) == 2;
|
return "ERROR" if errmk(sys("mkdir $mount_point")) == 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "ERROR" if errm(mount_device($device,$mount_point)) == 2;
|
|
||||||
##### lost+found on a ramdisk is pointless
|
|
||||||
sys("rm -rf $mount_point/lost+found");
|
|
||||||
|
|
||||||
sync();
|
if ( $fs_type ne "genext2fs" ) {
|
||||||
|
|
||||||
|
return "ERROR" if errm(mount_device($device,$mount_point)) == 2;
|
||||||
|
##### lost+found on a ramdisk is pointless
|
||||||
|
sys("rm -rf $mount_point/lost+found");
|
||||||
|
|
||||||
|
sync();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
##### Setting up the file structure is tricky. Given a tangled set
|
##### Setting up the file structure is tricky. Given a tangled set
|
||||||
##### of symbolic links and directories, we have to create the
|
##### of symbolic links and directories, we have to create the
|
||||||
@ -960,11 +972,32 @@ sub create_filesystem {
|
|||||||
sys("ldconfig -v -r $mount_point");
|
sys("ldconfig -v -r $mount_point");
|
||||||
}
|
}
|
||||||
|
|
||||||
## Probably will want to umount here
|
|
||||||
return "ERROR" if errum(sys("umount $mount_point")) == 2;
|
|
||||||
|
|
||||||
info(0, "\nDone making the root filesystem. $Warnings warnings.\n",
|
if ( $fs_type ne "genext2fs" ) {
|
||||||
"$device is now umounted from $mount_point\n\n");
|
## Probably will want to umount here
|
||||||
|
return "ERROR" if errum(sys("umount $mount_point")) == 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
# This is fun.
|
||||||
|
else {
|
||||||
|
# The -D option is unique to the newest unreleased version of
|
||||||
|
# genextfs modified by BusyBox maintainer Erick Andersen
|
||||||
|
# August 20, 2001.
|
||||||
|
|
||||||
|
my $device_table; # to be removed once device table creation is
|
||||||
|
# added.
|
||||||
|
|
||||||
|
if (
|
||||||
|
sys("$main::makefs -b $fs_size -d $mount_point -D $device_table $device") !~
|
||||||
|
/^0$/ ) {
|
||||||
|
$error = error("Can not $fs_type filesystem.");
|
||||||
|
return "ERROR" if $error && $error eq "ERROR";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
info(0, "\nDone making the root filesystem. $Warnings warnings.\n",
|
||||||
|
"$device is now umounted from $mount_point\n\n");
|
||||||
|
|
||||||
#info(0, "All done!\n");
|
#info(0, "All done!\n");
|
||||||
#info(0, "You can run more tests with the UML kernel\n",
|
#info(0, "You can run more tests with the UML kernel\n",
|
||||||
|
@ -276,6 +276,9 @@ sub file_system {
|
|||||||
# Editor and execute options
|
# Editor and execute options
|
||||||
label("Filesystem Command:",0,1,0,1,$table_filesystem);
|
label("Filesystem Command:",0,1,0,1,$table_filesystem);
|
||||||
my $fs1 = entry(1,3,0,1,2,$table_filesystem);
|
my $fs1 = entry(1,3,0,1,2,$table_filesystem);
|
||||||
|
if ( $> != 0 && -e "/usr/lib/bootroot/genext2fs" ) {
|
||||||
|
$main::makefs = "genext2fs -i8192";
|
||||||
|
}
|
||||||
$fs1->set_text($main::makefs);
|
$fs1->set_text($main::makefs);
|
||||||
|
|
||||||
$table_filesystem->set_row_spacing( 0, 2);
|
$table_filesystem->set_row_spacing( 0, 2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user