Compare commits
28 Commits
be23ab5b0e
...
3ac73fa2e9
Author | SHA1 | Date |
---|---|---|
|
3ac73fa2e9 | |
|
0c68126d80 | |
|
fc35a83207 | |
|
f760a5dcb4 | |
|
41ce661869 | |
|
26eb73876f | |
|
b63ca134a6 | |
|
d8671aa3bf | |
|
70d648001d | |
|
6b688d6390 | |
|
727e81f48a | |
|
e80afff9fe | |
|
4014b3f069 | |
|
7f4c7d226f | |
|
532cfab618 | |
|
b2e42b5ed7 | |
|
3d10d27719 | |
|
1b52adb9b1 | |
|
76b98beea6 | |
|
a0ccd6149c | |
|
42faa43cee | |
|
3e756054b5 | |
|
91b281e5b2 | |
|
642ee075c1 | |
|
32331e4f6a | |
|
eb1c8d9a6f | |
|
91a7fabba3 | |
|
fed94378a0 |
2
Makefile
2
Makefile
|
@ -13,8 +13,6 @@ libui \
|
||||||
bench \
|
bench \
|
||||||
carray \
|
carray \
|
||||||
checksum \
|
checksum \
|
||||||
chkblayout \
|
|
||||||
chvideomode \
|
|
||||||
dhclient \
|
dhclient \
|
||||||
disked \
|
disked \
|
||||||
display \
|
display \
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
chkblayout
|
|
|
@ -1,30 +0,0 @@
|
||||||
SOFTWARE_MEANT_FOR_SORTIX=1
|
|
||||||
include ../build-aux/platform.mak
|
|
||||||
include ../build-aux/compiler.mak
|
|
||||||
include ../build-aux/dirs.mak
|
|
||||||
|
|
||||||
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
|
|
||||||
CFLAGS?=$(OPTLEVEL)
|
|
||||||
|
|
||||||
CFLAGS += -Wall -Wextra
|
|
||||||
|
|
||||||
BINARIES = chkblayout
|
|
||||||
MANPAGES1 = chkblayout.1
|
|
||||||
|
|
||||||
LIBS =
|
|
||||||
|
|
||||||
all: $(BINARIES)
|
|
||||||
|
|
||||||
.PHONY: all install clean
|
|
||||||
|
|
||||||
install: all
|
|
||||||
mkdir -p $(DESTDIR)$(BINDIR)
|
|
||||||
install $(BINARIES) $(DESTDIR)$(BINDIR)
|
|
||||||
mkdir -p $(DESTDIR)$(MANDIR)/man1
|
|
||||||
cp $(MANPAGES1) $(DESTDIR)$(MANDIR)/man1
|
|
||||||
|
|
||||||
%: %.c
|
|
||||||
$(CC) -std=gnu11 $(CFLAGS) $(CPPFLAGS) $< -o $@ $(LIBS)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(BINARIES)
|
|
|
@ -1 +0,0 @@
|
||||||
chvideomode
|
|
|
@ -1,30 +0,0 @@
|
||||||
SOFTWARE_MEANT_FOR_SORTIX=1
|
|
||||||
include ../build-aux/platform.mak
|
|
||||||
include ../build-aux/compiler.mak
|
|
||||||
include ../build-aux/dirs.mak
|
|
||||||
|
|
||||||
OPTLEVEL?=$(DEFAULT_OPTLEVEL)
|
|
||||||
CFLAGS?=$(OPTLEVEL)
|
|
||||||
|
|
||||||
CFLAGS += -Wall -Wextra
|
|
||||||
|
|
||||||
BINARIES = chvideomode
|
|
||||||
MANPAGES1 = chvideomode.1
|
|
||||||
|
|
||||||
LIBS =
|
|
||||||
|
|
||||||
all: $(BINARIES)
|
|
||||||
|
|
||||||
.PHONY: all install clean
|
|
||||||
|
|
||||||
install: all
|
|
||||||
mkdir -p $(DESTDIR)$(BINDIR)
|
|
||||||
install $(BINARIES) $(DESTDIR)$(BINDIR)
|
|
||||||
mkdir -p $(DESTDIR)$(MANDIR)/man1
|
|
||||||
cp $(MANPAGES1) $(DESTDIR)$(MANDIR)/man1
|
|
||||||
|
|
||||||
%: %.c
|
|
||||||
$(CC) -std=gnu11 $(CFLAGS) $(CPPFLAGS) $< -o $@ $(LIBS)
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(BINARIES)
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2015, 2016, 2023 Jonas 'Sortie' Termansen.
|
* Copyright (c) 2014, 2015, 2016 Jonas 'Sortie' Termansen.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -115,8 +115,6 @@ CONNECTION_MESSAGE_HANDLER_NO_AUX(shutdown)
|
||||||
exit(1);
|
exit(1);
|
||||||
else if ( msg->code == 2 )
|
else if ( msg->code == 2 )
|
||||||
exit(2);
|
exit(2);
|
||||||
else if ( msg->code == 3 )
|
|
||||||
exit(3);
|
|
||||||
else
|
else
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -274,8 +274,6 @@ Request system reboot, normally sent by
|
||||||
.It Dv SIGQUIT
|
.It Dv SIGQUIT
|
||||||
Request system halt, normally sent by
|
Request system halt, normally sent by
|
||||||
.Xr halt 8 .
|
.Xr halt 8 .
|
||||||
.It Dv SIGHUP
|
|
||||||
Request system reinitialization.
|
|
||||||
.El
|
.El
|
||||||
.Sh EXIT STATUS
|
.Sh EXIT STATUS
|
||||||
.Nm
|
.Nm
|
||||||
|
|
36
init/init.c
36
init/init.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011-2023 Jonas 'Sortie' Termansen.
|
* Copyright (c) 2011-2022 Jonas 'Sortie' Termansen.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -322,7 +322,6 @@ static void signal_handler(int signum)
|
||||||
case SIGINT: caught_exit_signal = 1; break;
|
case SIGINT: caught_exit_signal = 1; break;
|
||||||
case SIGTERM: caught_exit_signal = 0; break;
|
case SIGTERM: caught_exit_signal = 0; break;
|
||||||
case SIGQUIT: caught_exit_signal = 2; break;
|
case SIGQUIT: caught_exit_signal = 2; break;
|
||||||
case SIGHUP: caught_exit_signal = 3; break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,13 +331,11 @@ static void install_signal_handler(void)
|
||||||
sigaddset(&handled_signals, SIGINT);
|
sigaddset(&handled_signals, SIGINT);
|
||||||
sigaddset(&handled_signals, SIGQUIT);
|
sigaddset(&handled_signals, SIGQUIT);
|
||||||
sigaddset(&handled_signals, SIGTERM);
|
sigaddset(&handled_signals, SIGTERM);
|
||||||
sigaddset(&handled_signals, SIGHUP);
|
|
||||||
sigprocmask(SIG_BLOCK, &handled_signals, NULL);
|
sigprocmask(SIG_BLOCK, &handled_signals, NULL);
|
||||||
struct sigaction sa = { .sa_handler = signal_handler, .sa_flags = 0 };
|
struct sigaction sa = { .sa_handler = signal_handler, .sa_flags = 0 };
|
||||||
sigaction(SIGINT, &sa, NULL);
|
sigaction(SIGINT, &sa, NULL);
|
||||||
sigaction(SIGQUIT, &sa, NULL);
|
sigaction(SIGQUIT, &sa, NULL);
|
||||||
sigaction(SIGTERM, &sa, NULL);
|
sigaction(SIGTERM, &sa, NULL);
|
||||||
sigaction(SIGHUP, &sa, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void uninstall_signal_handler(void)
|
static void uninstall_signal_handler(void)
|
||||||
|
@ -349,7 +346,6 @@ static void uninstall_signal_handler(void)
|
||||||
sigaction(SIGINT, &sa, NULL);
|
sigaction(SIGINT, &sa, NULL);
|
||||||
sigaction(SIGQUIT, &sa, NULL);
|
sigaction(SIGQUIT, &sa, NULL);
|
||||||
sigaction(SIGTERM, &sa, NULL);
|
sigaction(SIGTERM, &sa, NULL);
|
||||||
sigaction(SIGHUP, &sa, NULL);
|
|
||||||
sigprocmask(SIG_UNBLOCK, &handled_signals, NULL);
|
sigprocmask(SIG_UNBLOCK, &handled_signals, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1600,7 +1596,7 @@ static bool daemon_is_failed(struct daemon* daemon)
|
||||||
WEXITSTATUS(daemon->exit_code) != 0;
|
WEXITSTATUS(daemon->exit_code) != 0;
|
||||||
case EXIT_CODE_MEANING_POWEROFF_REBOOT:
|
case EXIT_CODE_MEANING_POWEROFF_REBOOT:
|
||||||
return !WIFEXITED(daemon->exit_code) ||
|
return !WIFEXITED(daemon->exit_code) ||
|
||||||
4 <= WEXITSTATUS(daemon->exit_code);
|
3 <= WEXITSTATUS(daemon->exit_code);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2344,8 +2340,6 @@ static void init(void)
|
||||||
log_status("stopped", "Rebooting...\n");
|
log_status("stopped", "Rebooting...\n");
|
||||||
else if ( caught_exit_signal == 2 )
|
else if ( caught_exit_signal == 2 )
|
||||||
log_status("stopped", "Halting...\n");
|
log_status("stopped", "Halting...\n");
|
||||||
else if ( caught_exit_signal == 3 )
|
|
||||||
log_status("stopped", "Reinitializing...\n");
|
|
||||||
else
|
else
|
||||||
log_status("stopped", "Exiting %i...\n", caught_exit_signal);
|
log_status("stopped", "Exiting %i...\n", caught_exit_signal);
|
||||||
if ( default_daemon->state != DAEMON_STATE_FINISHING &&
|
if ( default_daemon->state != DAEMON_STATE_FINISHING &&
|
||||||
|
@ -2548,11 +2542,7 @@ static void init(void)
|
||||||
sigprocmask(SIG_SETMASK, &saved_mask, NULL);
|
sigprocmask(SIG_SETMASK, &saved_mask, NULL);
|
||||||
|
|
||||||
if ( default_daemon_exit_code != -1 )
|
if ( default_daemon_exit_code != -1 )
|
||||||
{
|
daemon_find_by_name("default")->exit_code = default_daemon_exit_code;
|
||||||
struct daemon* default_daemon = daemon_find_by_name("default");
|
|
||||||
default_daemon->exit_code = default_daemon_exit_code;
|
|
||||||
default_daemon->exit_code_meaning = EXIT_CODE_MEANING_POWEROFF_REBOOT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write_random_seed(void)
|
static void write_random_seed(void)
|
||||||
|
@ -3376,14 +3366,6 @@ static void niht(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void reinit(void)
|
|
||||||
{
|
|
||||||
niht();
|
|
||||||
const char* argv[] = { "init", NULL };
|
|
||||||
execv("/sbin/init", (char* const*) argv);
|
|
||||||
fatal("Failed to load init during reinit: %s: %m", argv[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
main_pid = getpid();
|
main_pid = getpid();
|
||||||
|
@ -3677,8 +3659,11 @@ int main(int argc, char* argv[])
|
||||||
else if ( !WIFEXITED(status) )
|
else if ( !WIFEXITED(status) )
|
||||||
fatal("Automatic upgrade failed: Unexpected unusual termination");
|
fatal("Automatic upgrade failed: Unexpected unusual termination");
|
||||||
// Soft reinit into the freshly upgraded operating system.
|
// Soft reinit into the freshly upgraded operating system.
|
||||||
|
niht();
|
||||||
// TODO: Use next_argv here.
|
// TODO: Use next_argv here.
|
||||||
reinit();
|
const char* argv[] = { "init", NULL };
|
||||||
|
execv("/sbin/init", (char* const*) argv);
|
||||||
|
fatal("Failed to load init during reinit: %s: %m", argv[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Use the arguments to specify additional things the default daemon
|
// TODO: Use the arguments to specify additional things the default daemon
|
||||||
|
@ -3692,13 +3677,6 @@ int main(int argc, char* argv[])
|
||||||
// Initialize the operating system.
|
// Initialize the operating system.
|
||||||
init();
|
init();
|
||||||
|
|
||||||
// Reinitialize the operating system if requested.
|
|
||||||
if ( default_daemon->exit_code_meaning ==
|
|
||||||
EXIT_CODE_MEANING_POWEROFF_REBOOT &&
|
|
||||||
WIFEXITED(default_daemon->exit_code) &&
|
|
||||||
WEXITSTATUS(default_daemon->exit_code) == 3 )
|
|
||||||
reinit();
|
|
||||||
|
|
||||||
// Finish with the exit code of the default daemon.
|
// Finish with the exit code of the default daemon.
|
||||||
return exit_code_to_exit_status(default_daemon->exit_code);
|
return exit_code_to_exit_status(default_daemon->exit_code);
|
||||||
}
|
}
|
||||||
|
|
|
@ -530,7 +530,7 @@ void HandleTCGetBlob(int chl, struct fsm_req_tcgetblob* msg, Filesystem* fs)
|
||||||
else if ( !strcmp(name, "device-path") )
|
else if ( !strcmp(name, "device-path") )
|
||||||
RespondTCGetBlob(chl, fs->device->path, strlen(fs->device->path));
|
RespondTCGetBlob(chl, fs->device->path, strlen(fs->device->path));
|
||||||
else if ( !strcmp(name, "filesystem-type") )
|
else if ( !strcmp(name, "filesystem-type") )
|
||||||
RespondTCGetBlob(chl, "iso9660", strlen("iso9660"));
|
RespondTCGetBlob(chl, "ext2", strlen("iso9660"));
|
||||||
// TODO: Some kind of unique id.
|
// TODO: Some kind of unique id.
|
||||||
//else if ( !strcmp(name, "filesystem-uuid") )
|
//else if ( !strcmp(name, "filesystem-uuid") )
|
||||||
// RespondTCGetBlob(chl, fs->sb->s_uuid, sizeof(fs->sb->s_uuid));
|
// RespondTCGetBlob(chl, fs->sb->s_uuid, sizeof(fs->sb->s_uuid));
|
||||||
|
|
|
@ -466,7 +466,7 @@ ssize_t Inode::ReadLink(uint8_t* buf, size_t bufsize)
|
||||||
break;
|
break;
|
||||||
const char* data = (const char*) (field + n + 2);
|
const char* data = (const char*) (field + n + 2);
|
||||||
size_t datalen = comp_len;
|
size_t datalen = comp_len;
|
||||||
// TODO: How is a trailing slash encoded?
|
// TDOO: How is a trailing slash encoded?
|
||||||
if ( !continued || (comp_flags & (1 << 3) /* root */) )
|
if ( !continued || (comp_flags & (1 << 3) /* root */) )
|
||||||
{
|
{
|
||||||
buf[result++] = '/';
|
buf[result++] = '/';
|
||||||
|
|
|
@ -154,7 +154,7 @@ int getopt_long(int argc, char* const* argv, const char* shortopts,
|
||||||
// Check whether the next argument is the parameter to this option.
|
// Check whether the next argument is the parameter to this option.
|
||||||
if ( !option_arg && option->has_arg != no_argument )
|
if ( !option_arg && option->has_arg != no_argument )
|
||||||
{
|
{
|
||||||
if ( optind < argc && argv[optind] &&
|
if ( optind + 1 < argc && argv[optind] &&
|
||||||
(option->has_arg == required_argument || argv[optind][0] != '-') )
|
(option->has_arg == required_argument || argv[optind][0] != '-') )
|
||||||
option_arg = argv[optind++];
|
option_arg = argv[optind++];
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,8 +49,6 @@ exit asking for powering off the computer
|
||||||
exit asking for rebooting the computer
|
exit asking for rebooting the computer
|
||||||
.It halt
|
.It halt
|
||||||
exit asking for halting the computer
|
exit asking for halting the computer
|
||||||
.It reinit
|
|
||||||
exit asking for reinitializing the system
|
|
||||||
.El
|
.El
|
||||||
.Sh SECURITY
|
.Sh SECURITY
|
||||||
There is currently no method to confirm the login screen is in fact real other
|
There is currently no method to confirm the login screen is in fact real other
|
||||||
|
@ -89,8 +87,7 @@ fallback session script run upon login (see
|
||||||
.Sh EXIT STATUS
|
.Sh EXIT STATUS
|
||||||
.Nm login
|
.Nm login
|
||||||
exits 0 if the computer should power off, exits 1 if the computer should
|
exits 0 if the computer should power off, exits 1 if the computer should
|
||||||
reboot, exits 2 on fatal failure and the boot should halt, or exits 3 if the
|
reboot, or exits 2 on fatal failure and the boot should halt.
|
||||||
system should reinitialize.
|
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr passwd 1 ,
|
.Xr passwd 1 ,
|
||||||
.Xr crypt_checkpass 3 ,
|
.Xr crypt_checkpass 3 ,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2015, 2018, 2022, 2023 Jonas 'Sortie' Termansen.
|
* Copyright (c) 2014, 2015, 2018, 2022 Jonas 'Sortie' Termansen.
|
||||||
* Copyright (c) 2023 dzwdz.
|
* Copyright (c) 2023 dzwdz.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
@ -341,8 +341,6 @@ bool parse_username(const char* input,
|
||||||
return *action = SPECIAL_ACTION_REBOOT, true;
|
return *action = SPECIAL_ACTION_REBOOT, true;
|
||||||
else if ( !strcmp(input, "halt") )
|
else if ( !strcmp(input, "halt") )
|
||||||
return *action = SPECIAL_ACTION_HALT, true;
|
return *action = SPECIAL_ACTION_HALT, true;
|
||||||
else if ( !strcmp(input, "reinit") )
|
|
||||||
return *action = SPECIAL_ACTION_REINIT, true;
|
|
||||||
|
|
||||||
// Skip leading spaces to allow logging in as special accounts.
|
// Skip leading spaces to allow logging in as special accounts.
|
||||||
while ( isspace(*input) )
|
while ( isspace(*input) )
|
||||||
|
@ -379,7 +377,6 @@ void handle_special(enum special_action action)
|
||||||
case SPECIAL_ACTION_POWEROFF: exit(0);
|
case SPECIAL_ACTION_POWEROFF: exit(0);
|
||||||
case SPECIAL_ACTION_REBOOT: exit(1);
|
case SPECIAL_ACTION_REBOOT: exit(1);
|
||||||
case SPECIAL_ACTION_HALT: exit(2);
|
case SPECIAL_ACTION_HALT: exit(2);
|
||||||
case SPECIAL_ACTION_REINIT: exit(3);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014, 2015, 2023 Jonas 'Sortie' Termansen.
|
* Copyright (c) 2014, 2015 Jonas 'Sortie' Termansen.
|
||||||
* Copyright (c) 2023 dzwdz.
|
* Copyright (c) 2023 dzwdz.
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
@ -42,7 +42,6 @@ enum special_action
|
||||||
SPECIAL_ACTION_POWEROFF,
|
SPECIAL_ACTION_POWEROFF,
|
||||||
SPECIAL_ACTION_REBOOT,
|
SPECIAL_ACTION_REBOOT,
|
||||||
SPECIAL_ACTION_HALT,
|
SPECIAL_ACTION_HALT,
|
||||||
SPECIAL_ACTION_REINIT,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
bool login(const char* username, const char* session);
|
bool login(const char* username, const char* session);
|
||||||
|
|
|
@ -290,7 +290,7 @@ These are
|
||||||
.Pa /etc/ssh_host_ed25519_key ,
|
.Pa /etc/ssh_host_ed25519_key ,
|
||||||
and
|
and
|
||||||
.Pa /etc/ssh_host_rsa_key .
|
.Pa /etc/ssh_host_rsa_key .
|
||||||
.It Sy finally Ns "=" Ns Oo Sy exit "|" Sy poweroff "|" Sy reboot "|" Sy halt "|" Sy boot "|" Sy chroot Oc ( default Sy boot )
|
.It Sy finally Ns "=" Ns Oo Sy exit "|" Sy poweroff "|" Sy reboot "|" Sy halt "|" Sy boot Oc ( default Sy boot )
|
||||||
What action should be taken when the installation is finished?
|
What action should be taken when the installation is finished?
|
||||||
.Pp
|
.Pp
|
||||||
The
|
The
|
||||||
|
|
|
@ -252,9 +252,8 @@ Any other exit means the daemon failed.
|
||||||
The
|
The
|
||||||
.Sy poweroff-reboot
|
.Sy poweroff-reboot
|
||||||
meaning is that exiting 0 means the system should power off, exiting 1 means the
|
meaning is that exiting 0 means the system should power off, exiting 1 means the
|
||||||
system should reboot, exiting 2 means the system should halt, exit means system
|
system should reboot, exiting 2 means the system should halt, and any other exit
|
||||||
should reload its configuration and reinitialize, and any other exit means the
|
means the daemon failed.
|
||||||
daemon failed.
|
|
||||||
.Pp
|
.Pp
|
||||||
Daemons are considered successful if they exit by
|
Daemons are considered successful if they exit by
|
||||||
.Sy SIGTERM
|
.Sy SIGTERM
|
||||||
|
|
|
@ -433,16 +433,19 @@ the new installation.
|
||||||
This will complete the operating system installation.
|
This will complete the operating system installation.
|
||||||
Upon reboot, the new system will start normally.
|
Upon reboot, the new system will start normally.
|
||||||
After powering off your system, you need to remove the installation medium and
|
After powering off your system, you need to remove the installation medium and
|
||||||
(if applicable) restore boot priorities in your firmware.
|
if applicable restore boot priorities in your firmware.
|
||||||
If you did not accept the bootloader, you will need to manually configure a
|
If you did not accept the bootloader, you will need to manually configure a
|
||||||
bootloader to boot the new operating system.
|
bootloader to boot the new operating system.
|
||||||
.Pp
|
.Pp
|
||||||
You will be given the choice of directly booting into the new system without a
|
You will be given the choice between powering off the system, rebooting it,
|
||||||
reboot, powering off the system, rebooting the system, halting the system, or
|
halting it, or directly booting the new system.
|
||||||
chrooting into the new system.
|
.Pp
|
||||||
All of these options (except the
|
The last option will directly boot the new system in a chroot while the live
|
||||||
.Xr chroot 2 )
|
environment remains in the background.
|
||||||
will destroy the live environment and all files within it will be lost.
|
If you invoked
|
||||||
|
.Xr sysinstall 8
|
||||||
|
yourself, then you will be returned to your live environment shell.
|
||||||
|
Otherwise the computer will power off when the chroot environment terminates.
|
||||||
.Pp
|
.Pp
|
||||||
This is a last chance to make modifications before the new system boots for the
|
This is a last chance to make modifications before the new system boots for the
|
||||||
first time.
|
first time.
|
||||||
|
|
|
@ -119,9 +119,6 @@ ext2 extensions.
|
||||||
You can make a compatible filesystem with:
|
You can make a compatible filesystem with:
|
||||||
.Pp
|
.Pp
|
||||||
.Dl $ mkfs.ext2 -O none,large_file,filetype
|
.Dl $ mkfs.ext2 -O none,large_file,filetype
|
||||||
.Pp
|
|
||||||
You can mount ISO 9660 filesystems for e.g. CD-ROMs using
|
|
||||||
.Xr iso9660fs 8 .
|
|
||||||
.Ss Networking
|
.Ss Networking
|
||||||
Internet Protocol version 4
|
Internet Protocol version 4
|
||||||
.Pq Xr ip 4
|
.Pq Xr ip 4
|
||||||
|
|
|
@ -1582,7 +1582,7 @@ int main(void)
|
||||||
while ( true )
|
while ( true )
|
||||||
{
|
{
|
||||||
prompt(input, sizeof(input), "finally",
|
prompt(input, sizeof(input), "finally",
|
||||||
"What now? (exit/poweroff/reboot/halt/boot/chroot)", "boot");
|
"What now? (exit/poweroff/reboot/halt/boot)", "boot");
|
||||||
if ( !strcasecmp(input, "exit") )
|
if ( !strcasecmp(input, "exit") )
|
||||||
exit(0);
|
exit(0);
|
||||||
else if ( !strcasecmp(input, "poweroff") )
|
else if ( !strcasecmp(input, "poweroff") )
|
||||||
|
@ -1592,27 +1592,13 @@ int main(void)
|
||||||
else if ( !strcasecmp(input, "halt") )
|
else if ( !strcasecmp(input, "halt") )
|
||||||
exit_gui(2);
|
exit_gui(2);
|
||||||
else if ( !strcasecmp(input, "boot") )
|
else if ( !strcasecmp(input, "boot") )
|
||||||
{
|
|
||||||
if ( !access("/etc/fstab", F_OK) )
|
|
||||||
{
|
|
||||||
printf("Only a live environment can reinit installations.\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
execute((const char*[]) {"mkdir", "-p", "/etc/init", NULL }, "ef");
|
|
||||||
execute((const char*[]) {"cp", "etc/fstab", "/etc/fstab", NULL },
|
|
||||||
"ef");
|
|
||||||
execute((const char*[]) {"sh", "-c",
|
|
||||||
"echo 'require chain exit-code' > "
|
|
||||||
"/etc/init/default", NULL },
|
|
||||||
"ef");
|
|
||||||
exit_gui(3);
|
|
||||||
}
|
|
||||||
else if ( !strcasecmp(input, "chroot") )
|
|
||||||
{
|
{
|
||||||
unmount_all_but_root();
|
unmount_all_but_root();
|
||||||
unsetenv("SYSINSTALL_TARGET");
|
unsetenv("SYSINSTALL_TARGET");
|
||||||
unsetenv("SHLVL");
|
unsetenv("SHLVL");
|
||||||
unsetenv("INIT_PID");
|
unsetenv("INIT_PID");
|
||||||
|
// TODO: If / is a kernel ramfs, and this is a live environment,
|
||||||
|
// then uninstall the base system to save memory.
|
||||||
exit(execute((const char*[]) { "chroot", "-d", fs,
|
exit(execute((const char*[]) { "chroot", "-d", fs,
|
||||||
"/sbin/init", NULL }, "f"));
|
"/sbin/init", NULL }, "f"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,10 @@ CPPFLAGS:=$(CPPFLAGS) -DVERSIONSTR=\"$(VERSION)\"
|
||||||
BINARIES_EXCEPT_INSTALL:=\
|
BINARIES_EXCEPT_INSTALL:=\
|
||||||
basename \
|
basename \
|
||||||
cat \
|
cat \
|
||||||
|
chkblayout \
|
||||||
chmod \
|
chmod \
|
||||||
chown \
|
chown \
|
||||||
|
chvideomode \
|
||||||
clear \
|
clear \
|
||||||
colormake \
|
colormake \
|
||||||
column \
|
column \
|
||||||
|
@ -81,6 +83,8 @@ $(BINARIES_EXCEPT_INSTALL) \
|
||||||
xinstall
|
xinstall
|
||||||
|
|
||||||
MANPAGES1=\
|
MANPAGES1=\
|
||||||
|
chkblayout.1 \
|
||||||
|
chvideomode.1 \
|
||||||
kernelinfo.1 \
|
kernelinfo.1 \
|
||||||
logname.1 \
|
logname.1 \
|
||||||
nc.1 \
|
nc.1 \
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2014 Jonas 'Sortie' Termansen.
|
* Copyright (c) 2014 Jonas 'Sortie' Termansen.
|
||||||
* Copyright (c) 2023 Juhani 'nortti' Krekelä.
|
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -24,7 +23,6 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <error.h>
|
#include <error.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <getopt.h>
|
|
||||||
#include <ioleast.h>
|
#include <ioleast.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
@ -34,31 +32,59 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
|
|
||||||
|
static void compact_arguments(int* argc, char*** argv)
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < *argc; i++ )
|
||||||
|
{
|
||||||
|
while ( i < *argc && !(*argv)[i] )
|
||||||
|
{
|
||||||
|
for ( int n = i; n < *argc; n++ )
|
||||||
|
(*argv)[n] = (*argv)[n+1];
|
||||||
|
(*argc)--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
bool list = false;
|
bool list = false;
|
||||||
|
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
|
|
||||||
const struct option longopts[] =
|
const char* argv0 = argv[0];
|
||||||
|
for ( int i = 1; i < argc; i++ )
|
||||||
{
|
{
|
||||||
{"list", no_argument, NULL, 'l'},
|
const char* arg = argv[i];
|
||||||
{0, 0, 0, 0}
|
if ( arg[0] != '-' || !arg[1] )
|
||||||
};
|
continue;
|
||||||
const char* opts = "l";
|
argv[i] = NULL;
|
||||||
int opt;
|
if ( !strcmp(arg, "--") )
|
||||||
while ( (opt = getopt_long(argc, argv, opts, longopts, NULL)) != -1 )
|
break;
|
||||||
|
if ( arg[1] != '-' )
|
||||||
{
|
{
|
||||||
switch ( opt )
|
char c;
|
||||||
|
while ( (c = *++arg) ) switch ( c )
|
||||||
{
|
{
|
||||||
case 'l': list = true; break;
|
case 'l': list = true; break;
|
||||||
default: return 1;
|
default:
|
||||||
|
fprintf(stderr, "%s: unknown option -- '%c'\n", argv0, c);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( !strcmp(arg, "--list") )
|
||||||
|
list = true;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: unknown option: %s\n", argv0, arg);
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compact_arguments(&argc, &argv);
|
||||||
|
|
||||||
if ( list )
|
if ( list )
|
||||||
{
|
{
|
||||||
if ( 0 < argc - optind )
|
if ( 2 <= argc )
|
||||||
errx(1, "unexpected extra operand");
|
errx(1, "unexpected extra operand");
|
||||||
execlp("ls", "ls", "/share/kblayout", (const char*) NULL);
|
execlp("ls", "ls", "/share/kblayout", (const char*) NULL);
|
||||||
err(127, "ls");
|
err(127, "ls");
|
||||||
|
@ -67,44 +93,42 @@ int main(int argc, char* argv[])
|
||||||
const char* tty_path = "/dev/tty";
|
const char* tty_path = "/dev/tty";
|
||||||
int tty_fd = open(tty_path, O_WRONLY);
|
int tty_fd = open(tty_path, O_WRONLY);
|
||||||
if ( tty_fd < 0 )
|
if ( tty_fd < 0 )
|
||||||
err(1, "%s", tty_path);
|
error(1, errno, "`%s'", tty_path);
|
||||||
if ( !isatty(tty_fd) )
|
if ( !isatty(tty_fd) )
|
||||||
err(1, "%s", tty_path);
|
error(1, errno, "`%s'", tty_path);
|
||||||
|
|
||||||
if ( argc - optind == 0 )
|
if ( argc == 1 )
|
||||||
errx(1, "expected new keyboard layout");
|
error(1, 0, "expected new keyboard layout");
|
||||||
if ( 1 < argc - optind )
|
|
||||||
errx(1, "unexpected extra operand");
|
|
||||||
|
|
||||||
const char* kblayout_path = argv[optind];
|
const char* kblayout_path = argv[1];
|
||||||
if ( !strchr(kblayout_path, '/') )
|
if ( !strchr(kblayout_path, '/') )
|
||||||
{
|
{
|
||||||
char* new_kblayout_path;
|
char* new_kblayout_path;
|
||||||
if ( asprintf(&new_kblayout_path, "/share/kblayout/%s", kblayout_path) < 0 )
|
if ( asprintf(&new_kblayout_path, "/share/kblayout/%s", kblayout_path) < 0 )
|
||||||
err(1, "asprintf");
|
error(1, errno, "asprintf");
|
||||||
kblayout_path = new_kblayout_path;
|
kblayout_path = new_kblayout_path;
|
||||||
}
|
}
|
||||||
int kblayout_fd = open(kblayout_path, O_RDONLY);
|
int kblayout_fd = open(kblayout_path, O_RDONLY);
|
||||||
if ( kblayout_fd < 0 )
|
if ( kblayout_fd < 0 )
|
||||||
err(1, "%s", kblayout_path);
|
error(1, errno, "`%s'", kblayout_path);
|
||||||
|
|
||||||
struct stat kblayout_st;
|
struct stat kblayout_st;
|
||||||
if ( fstat(kblayout_fd, &kblayout_st) < 0 )
|
if ( fstat(kblayout_fd, &kblayout_st) < 0 )
|
||||||
err(1, "stat: %s", kblayout_path);
|
error(1, errno, "stat: `%s'", kblayout_path);
|
||||||
|
|
||||||
if ( (size_t) kblayout_st.st_size != (uintmax_t) kblayout_st.st_size )
|
if ( SIZE_MAX < (size_t) kblayout_st.st_size )
|
||||||
error(1, EFBIG, "%s", kblayout_path);
|
error(1, EFBIG, "`%s'", kblayout_path);
|
||||||
|
|
||||||
size_t kblayout_size = (size_t) kblayout_st.st_size;
|
size_t kblayout_size = (size_t) kblayout_st.st_size;
|
||||||
unsigned char* kblayout = (unsigned char*) malloc(kblayout_size);
|
unsigned char* kblayout = (unsigned char*) malloc(kblayout_size);
|
||||||
if ( !kblayout )
|
if ( !kblayout )
|
||||||
err(1, "malloc");
|
error(1, errno, "malloc");
|
||||||
if ( readall(kblayout_fd, kblayout, kblayout_size) != kblayout_size )
|
if ( readall(kblayout_fd, kblayout, kblayout_size) != kblayout_size )
|
||||||
err(1, "read: %s", kblayout_path);
|
error(1, errno, "read: `%s'", kblayout_path);
|
||||||
close(kblayout_fd);
|
close(kblayout_fd);
|
||||||
|
|
||||||
if ( tcsetblob(tty_fd, "kblayout", kblayout, kblayout_size) < 0 )
|
if ( tcsetblob(tty_fd, "kblayout", kblayout, kblayout_size) < 0 )
|
||||||
err(1, "tcsetblob: kblayout: %s:", kblayout_path);
|
error(1, errno, "tcsetblob(\"kblayout\", `%s')", kblayout_path);
|
||||||
|
|
||||||
free(kblayout);
|
free(kblayout);
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2013, 2014, 2015, 2016 Jonas 'Sortie' Termansen.
|
* Copyright (c) 2012, 2013, 2014, 2015, 2016 Jonas 'Sortie' Termansen.
|
||||||
* Copyright (c) 2023 Juhani 'nortti' Krekelä.
|
|
||||||
*
|
*
|
||||||
* Permission to use, copy, modify, and distribute this software for any
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
* purpose with or without fee is hereby granted, provided that the above
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
@ -25,9 +24,8 @@
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <err.h>
|
#include <error.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <getopt.h>
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
@ -41,7 +39,7 @@
|
||||||
static uint64_t device;
|
static uint64_t device;
|
||||||
static uint64_t connector;
|
static uint64_t connector;
|
||||||
|
|
||||||
static bool set_current_mode(struct dispmsg_crtc_mode mode)
|
bool SetCurrentMode(struct dispmsg_crtc_mode mode)
|
||||||
{
|
{
|
||||||
struct dispmsg_set_crtc_mode msg;
|
struct dispmsg_set_crtc_mode msg;
|
||||||
msg.msgid = DISPMSG_SET_CRTC_MODE;
|
msg.msgid = DISPMSG_SET_CRTC_MODE;
|
||||||
|
@ -51,7 +49,7 @@ static bool set_current_mode(struct dispmsg_crtc_mode mode)
|
||||||
return dispmsg_issue(&msg, sizeof(msg)) == 0;
|
return dispmsg_issue(&msg, sizeof(msg)) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct dispmsg_crtc_mode* get_available_modes(size_t* num_modes_ptr)
|
struct dispmsg_crtc_mode* GetAvailableModes(size_t* num_modes_ptr)
|
||||||
{
|
{
|
||||||
struct dispmsg_get_crtc_modes msg;
|
struct dispmsg_get_crtc_modes msg;
|
||||||
msg.msgid = DISPMSG_GET_CRTC_MODES;
|
msg.msgid = DISPMSG_GET_CRTC_MODES;
|
||||||
|
@ -100,8 +98,7 @@ struct filter
|
||||||
size_t maxychars;
|
size_t maxychars;
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool mode_passes_filter(struct dispmsg_crtc_mode mode,
|
bool mode_passes_filter(struct dispmsg_crtc_mode mode, struct filter* filter)
|
||||||
struct filter* filter)
|
|
||||||
{
|
{
|
||||||
if ( filter->include_all )
|
if ( filter->include_all )
|
||||||
return true;
|
return true;
|
||||||
|
@ -133,7 +130,7 @@ static bool mode_passes_filter(struct dispmsg_crtc_mode mode,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void filter_modes(struct dispmsg_crtc_mode* modes, size_t* num_modes_ptr, struct filter* filter)
|
void filter_modes(struct dispmsg_crtc_mode* modes, size_t* num_modes_ptr, struct filter* filter)
|
||||||
{
|
{
|
||||||
size_t in_num = *num_modes_ptr;
|
size_t in_num = *num_modes_ptr;
|
||||||
size_t out_num = 0;
|
size_t out_num = 0;
|
||||||
|
@ -145,44 +142,104 @@ static void filter_modes(struct dispmsg_crtc_mode* modes, size_t* num_modes_ptr,
|
||||||
*num_modes_ptr = out_num;
|
*num_modes_ptr = out_num;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t parse_size_t(const char* str)
|
size_t parse_size_t(const char* str, size_t def)
|
||||||
{
|
{
|
||||||
|
if ( !str || !*str )
|
||||||
|
return def;
|
||||||
char* endptr;
|
char* endptr;
|
||||||
errno = 0;
|
size_t ret = (size_t) strtoumax(str, &endptr, 10);
|
||||||
uintmax_t parsed = strtoumax(str, &endptr, 10);
|
if ( *endptr )
|
||||||
if ( !*str || *endptr )
|
return def;
|
||||||
errx(1, "Invalid integer argument: %s", str);
|
return ret;
|
||||||
if ( errno == ERANGE || (size_t) parsed != parsed )
|
|
||||||
errx(1, "Integer argument too large: %s", str);
|
|
||||||
return (size_t) parsed;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool parse_bool(const char* str)
|
bool parse_bool(const char* str, bool def)
|
||||||
{
|
{
|
||||||
if ( !strcmp(str, "0") || !strcmp(str, "false") )
|
if ( !str || !*str )
|
||||||
|
return def;
|
||||||
|
bool isfalse = !strcmp(str, "0") || !strcmp(str, "false");
|
||||||
|
return !isfalse;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void compact_arguments(int* argc, char*** argv)
|
||||||
|
{
|
||||||
|
for ( int i = 0; i < *argc; i++ )
|
||||||
|
{
|
||||||
|
while ( i < *argc && !(*argv)[i] )
|
||||||
|
{
|
||||||
|
for ( int n = i; n < *argc; n++ )
|
||||||
|
(*argv)[n] = (*argv)[n+1];
|
||||||
|
(*argc)--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool string_parameter(const char* option,
|
||||||
|
const char* arg,
|
||||||
|
int argc,
|
||||||
|
char** argv,
|
||||||
|
int* ip,
|
||||||
|
const char* argv0,
|
||||||
|
const char** result)
|
||||||
|
{
|
||||||
|
size_t option_len = strlen(option);
|
||||||
|
if ( strncmp(option, arg, option_len) != 0 )
|
||||||
return false;
|
return false;
|
||||||
if ( !strcmp(str, "1") || !strcmp(str, "true") )
|
if ( arg[option_len] == '=' )
|
||||||
|
return *result = arg + option_len + 1, true;
|
||||||
|
if ( arg[option_len] != '\0' )
|
||||||
|
return false;
|
||||||
|
if ( *ip + 1 == argc )
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: expected operand after `%s'\n", argv0, option);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
*result = argv[++*ip];
|
||||||
|
argv[*ip] = NULL;
|
||||||
return true;
|
return true;
|
||||||
errx(1, "Invalid boolean argument: %s", str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum longopt
|
bool minmax_parameter(const char* option,
|
||||||
|
const char* min_option,
|
||||||
|
const char* max_option,
|
||||||
|
const char* arg,
|
||||||
|
int argc,
|
||||||
|
char** argv,
|
||||||
|
int* ip,
|
||||||
|
const char* argv0,
|
||||||
|
size_t* min_result,
|
||||||
|
size_t* max_result)
|
||||||
{
|
{
|
||||||
OPT_SHOW_ALL = 128,
|
const char* parameter;
|
||||||
OPT_SHOW_SUPPORTED,
|
if ( string_parameter(option, arg, argc, argv, ip, argv0, ¶meter) )
|
||||||
OPT_SHOW_UNSUPPORTED,
|
return *min_result = *max_result = parse_size_t(parameter, 0), true;
|
||||||
OPT_SHOW_TEXT,
|
if ( string_parameter(min_option, arg, argc, argv, ip, argv0, ¶meter) )
|
||||||
OPT_SHOW_GRAPHICS,
|
return *min_result = parse_size_t(parameter, 0), true;
|
||||||
OPT_BPP,
|
if ( string_parameter(max_option, arg, argc, argv, ip, argv0, ¶meter) )
|
||||||
OPT_MIN_BPP,
|
return *max_result = parse_size_t(parameter, 0), true;
|
||||||
OPT_MAX_BPP,
|
return false;
|
||||||
OPT_WIDTH,
|
}
|
||||||
OPT_MIN_WIDTH,
|
|
||||||
OPT_MAX_WIDTH,
|
#define MINMAX_PARAMETER(option, min_result, max_result) \
|
||||||
OPT_HEIGHT,
|
minmax_parameter("--" option, "--min-" option, "--max-" option, arg, \
|
||||||
OPT_MIN_HEIGHT,
|
argc, argv, &i, argv0, min_result, max_result)
|
||||||
OPT_MAX_HEIGHT,
|
|
||||||
};
|
bool bool_parameter(const char* option,
|
||||||
|
const char* arg,
|
||||||
|
int argc,
|
||||||
|
char** argv,
|
||||||
|
int* ip,
|
||||||
|
const char* argv0,
|
||||||
|
bool* result)
|
||||||
|
{
|
||||||
|
const char* parameter;
|
||||||
|
if ( string_parameter(option, arg, argc, argv, ip, argv0, ¶meter) )
|
||||||
|
return *result = parse_bool(parameter, false), true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define BOOL_PARAMETER(option, result) \
|
||||||
|
bool_parameter("--" option, arg, argc, argv, &i, argv0, result)
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
@ -206,68 +263,56 @@ int main(int argc, char* argv[])
|
||||||
filter.minychars = 0;
|
filter.minychars = 0;
|
||||||
filter.maxychars = SIZE_MAX;
|
filter.maxychars = SIZE_MAX;
|
||||||
|
|
||||||
const struct option longopts[] =
|
const char* argv0 = argv[0];
|
||||||
|
for ( int i = 1; i < argc; i++ )
|
||||||
{
|
{
|
||||||
{"show-all", required_argument, NULL, OPT_SHOW_ALL},
|
const char* arg = argv[i];
|
||||||
{"show-supported", required_argument, NULL, OPT_SHOW_SUPPORTED},
|
if ( arg[0] != '-' || !arg[1] )
|
||||||
{"show-unsupported", required_argument, NULL, OPT_SHOW_UNSUPPORTED},
|
break; // Intentionally not continue.
|
||||||
{"show-text", required_argument, NULL, OPT_SHOW_TEXT},
|
argv[i] = NULL;
|
||||||
{"show-graphics", required_argument, NULL, OPT_SHOW_GRAPHICS},
|
if ( !strcmp(arg, "--") )
|
||||||
{"bpp", required_argument, NULL, OPT_BPP},
|
break;
|
||||||
{"min-bpp", required_argument, NULL, OPT_MIN_BPP},
|
if ( arg[1] != '-' )
|
||||||
{"max-bpp", required_argument, NULL, OPT_MAX_BPP},
|
|
||||||
{"width", required_argument, NULL, OPT_WIDTH},
|
|
||||||
{"min-width", required_argument, NULL, OPT_MIN_WIDTH},
|
|
||||||
{"max-width", required_argument, NULL, OPT_MAX_WIDTH},
|
|
||||||
{"height", required_argument, NULL, OPT_HEIGHT},
|
|
||||||
{"min-height", required_argument, NULL, OPT_MIN_HEIGHT},
|
|
||||||
{"max-height", required_argument, NULL, OPT_MAX_HEIGHT},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
const char* opts = "";
|
|
||||||
int opt;
|
|
||||||
while ( (opt = getopt_long(argc, argv, opts, longopts, NULL)) != -1 )
|
|
||||||
{
|
{
|
||||||
switch (opt)
|
char c;
|
||||||
|
while ( (c = *++arg) ) switch ( c )
|
||||||
{
|
{
|
||||||
case OPT_SHOW_ALL: filter.include_all = parse_bool(optarg); break;
|
default:
|
||||||
case OPT_SHOW_SUPPORTED:
|
fprintf(stderr, "%s: unknown option -- '%c'\n", argv0, c);
|
||||||
filter.include_supported = parse_bool(optarg); break;
|
exit(1);
|
||||||
case OPT_SHOW_UNSUPPORTED:
|
|
||||||
filter.include_unsupported = parse_bool(optarg); break;
|
|
||||||
case OPT_SHOW_TEXT: filter.include_text = parse_bool(optarg); break;
|
|
||||||
case OPT_SHOW_GRAPHICS:
|
|
||||||
filter.include_graphics = parse_bool(optarg); break;
|
|
||||||
case OPT_BPP:
|
|
||||||
filter.minbpp = filter.maxbpp = parse_size_t(optarg); break;
|
|
||||||
case OPT_MIN_BPP: filter.minbpp = parse_size_t(optarg); break;
|
|
||||||
case OPT_MAX_BPP: filter.maxbpp = parse_size_t(optarg); break;
|
|
||||||
case OPT_WIDTH:
|
|
||||||
filter.minxres = filter.maxxres = parse_size_t(optarg); break;
|
|
||||||
case OPT_MIN_WIDTH: filter.minxres = parse_size_t(optarg); break;
|
|
||||||
case OPT_MAX_WIDTH: filter.maxxres = parse_size_t(optarg); break;
|
|
||||||
case OPT_HEIGHT:
|
|
||||||
filter.minyres = filter.maxyres = parse_size_t(optarg); break;
|
|
||||||
case OPT_MIN_HEIGHT: filter.minyres = parse_size_t(optarg); break;
|
|
||||||
case OPT_MAX_HEIGHT: filter.maxyres = parse_size_t(optarg); break;
|
|
||||||
default: return 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ( BOOL_PARAMETER("show-all", &filter.include_all) ) { }
|
||||||
|
else if ( BOOL_PARAMETER("show-supported", &filter.include_supported) ) { }
|
||||||
|
else if ( BOOL_PARAMETER("show-unsupported", &filter.include_unsupported) ) { }
|
||||||
|
else if ( BOOL_PARAMETER("show-text", &filter.include_text) ) { }
|
||||||
|
else if ( BOOL_PARAMETER("show-graphics", &filter.include_graphics) ) { }
|
||||||
|
else if ( MINMAX_PARAMETER("bpp", &filter.minbpp, &filter.maxbpp) ) { }
|
||||||
|
else if ( MINMAX_PARAMETER("width", &filter.minxres, &filter.maxxres) ) { }
|
||||||
|
else if ( MINMAX_PARAMETER("height", &filter.minyres, &filter.maxyres) ) { }
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: unknown option: %s\n", argv0, arg);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
compact_arguments(&argc, &argv);
|
||||||
|
|
||||||
unsigned int xres = 0;
|
unsigned int xres = 0;
|
||||||
unsigned int yres = 0;
|
unsigned int yres = 0;
|
||||||
unsigned int bpp = 0;
|
unsigned int bpp = 0;
|
||||||
if ( 1 <= argc - optind )
|
if ( 2 <= argc )
|
||||||
{
|
{
|
||||||
if ( 1 < argc - optind )
|
if ( 2 < argc )
|
||||||
errx(1, "Unexpected extra operand");
|
error(1, 0, "Unexpected extra operand");
|
||||||
if ( sscanf(argv[optind], "%ux%ux%u", &xres, &yres, &bpp) != 3 )
|
if ( sscanf(argv[1], "%ux%ux%u", &xres, &yres, &bpp) != 3 )
|
||||||
errx(1, "Invalid video mode: %s", argv[optind]);
|
error(1, 0, "Invalid video mode: %s", argv[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
int tty_fd = open("/dev/tty", O_RDWR);
|
int tty_fd = open("/dev/tty", O_RDWR);
|
||||||
if ( tty_fd < 0 )
|
if ( tty_fd < 0 )
|
||||||
err(1, "/dev/tty");
|
error(1, errno, "/dev/tty");
|
||||||
struct tiocgdisplay display;
|
struct tiocgdisplay display;
|
||||||
struct tiocgdisplays gdisplays;
|
struct tiocgdisplays gdisplays;
|
||||||
memset(&gdisplays, 0, sizeof(gdisplays));
|
memset(&gdisplays, 0, sizeof(gdisplays));
|
||||||
|
@ -282,9 +327,9 @@ int main(int argc, char* argv[])
|
||||||
connector = display.connector;
|
connector = display.connector;
|
||||||
|
|
||||||
size_t num_modes = 0;
|
size_t num_modes = 0;
|
||||||
struct dispmsg_crtc_mode* modes = get_available_modes(&num_modes);
|
struct dispmsg_crtc_mode* modes = GetAvailableModes(&num_modes);
|
||||||
if ( !modes )
|
if ( !modes )
|
||||||
err(1, "Unable to detect available video modes");
|
error(1, errno, "Unable to detect available video modes");
|
||||||
|
|
||||||
if ( !num_modes )
|
if ( !num_modes )
|
||||||
{
|
{
|
||||||
|
@ -315,7 +360,7 @@ retry_pick_mode:
|
||||||
decided = false;
|
decided = false;
|
||||||
first_render = true;
|
first_render = true;
|
||||||
memset(&render_at, 0, sizeof(render_at));
|
memset(&render_at, 0, sizeof(render_at));
|
||||||
if ( 1 <= argc - optind )
|
if ( 2 <= argc )
|
||||||
{
|
{
|
||||||
bool found_other = true;
|
bool found_other = true;
|
||||||
size_t other_selection = 0;
|
size_t other_selection = 0;
|
||||||
|
@ -340,7 +385,7 @@ retry_pick_mode:
|
||||||
if ( found_other )
|
if ( found_other )
|
||||||
selection = other_selection;
|
selection = other_selection;
|
||||||
else
|
else
|
||||||
err(1, "No such available resolution: %s", argv[optind]);
|
error(1, 0, "No such available resolution: %s", argv[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ( !decided )
|
while ( !decided )
|
||||||
|
@ -405,10 +450,10 @@ retry_pick_mode:
|
||||||
printf("\e[2K");
|
printf("\e[2K");
|
||||||
printf(" [%-*zu] ", num_modes_display_length, index);
|
printf(" [%-*zu] ", num_modes_display_length, index);
|
||||||
if ( modes[i].control & DISPMSG_CONTROL_VALID )
|
if ( modes[i].control & DISPMSG_CONTROL_VALID )
|
||||||
printf("%ux%ux%u",
|
printf("%u x %u x %u",
|
||||||
|
modes[i].fb_format,
|
||||||
modes[i].view_xres,
|
modes[i].view_xres,
|
||||||
modes[i].view_yres,
|
modes[i].view_yres);
|
||||||
modes[i].fb_format);
|
|
||||||
else if ( modes[i].control & DISPMSG_CONTROL_OTHER_RESOLUTIONS )
|
else if ( modes[i].control & DISPMSG_CONTROL_OTHER_RESOLUTIONS )
|
||||||
printf("(enter a custom resolution)");
|
printf("(enter a custom resolution)");
|
||||||
else
|
else
|
||||||
|
@ -421,10 +466,10 @@ retry_pick_mode:
|
||||||
|
|
||||||
unsigned int oldtermmode;
|
unsigned int oldtermmode;
|
||||||
if ( gettermmode(0, &oldtermmode) < 0 )
|
if ( gettermmode(0, &oldtermmode) < 0 )
|
||||||
err(1, "gettermmode");
|
error(1, errno, "gettermmode");
|
||||||
|
|
||||||
if ( settermmode(0, TERMMODE_KBKEY | TERMMODE_UNICODE | TERMMODE_SIGNAL) < 0 )
|
if ( settermmode(0, TERMMODE_KBKEY | TERMMODE_UNICODE | TERMMODE_SIGNAL) < 0 )
|
||||||
err(1, "settermmode");
|
error(1, errno, "settermmode");
|
||||||
|
|
||||||
bool redraw = false;
|
bool redraw = false;
|
||||||
while ( !redraw && !decided )
|
while ( !redraw && !decided )
|
||||||
|
@ -432,7 +477,7 @@ retry_pick_mode:
|
||||||
uint32_t codepoint;
|
uint32_t codepoint;
|
||||||
ssize_t numbytes = read(0, &codepoint, sizeof(codepoint));
|
ssize_t numbytes = read(0, &codepoint, sizeof(codepoint));
|
||||||
if ( numbytes < 0 )
|
if ( numbytes < 0 )
|
||||||
err(1, "read");
|
error(1, errno, "read");
|
||||||
|
|
||||||
int kbkey = KBKEY_DECODE(codepoint);
|
int kbkey = KBKEY_DECODE(codepoint);
|
||||||
if ( kbkey )
|
if ( kbkey )
|
||||||
|
@ -441,7 +486,7 @@ retry_pick_mode:
|
||||||
{
|
{
|
||||||
case KBKEY_ESC:
|
case KBKEY_ESC:
|
||||||
if ( settermmode(0, oldtermmode) < 0 )
|
if ( settermmode(0, oldtermmode) < 0 )
|
||||||
err(1, "settermmode");
|
error(1, errno, "settermmode");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
exit(10);
|
exit(10);
|
||||||
break;
|
break;
|
||||||
|
@ -461,7 +506,7 @@ retry_pick_mode:
|
||||||
break;
|
break;
|
||||||
case KBKEY_ENTER:
|
case KBKEY_ENTER:
|
||||||
if ( settermmode(0, oldtermmode) < 0 )
|
if ( settermmode(0, oldtermmode) < 0 )
|
||||||
err(1, "settermmode");
|
error(1, errno, "settermmode");
|
||||||
fgetc(stdin);
|
fgetc(stdin);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
decided = true;
|
decided = true;
|
||||||
|
@ -483,7 +528,7 @@ retry_pick_mode:
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( settermmode(0, oldtermmode) < 0 )
|
if ( settermmode(0, oldtermmode) < 0 )
|
||||||
err(1, "settermmode");
|
error(1, errno, "settermmode");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct dispmsg_crtc_mode mode = modes[selection];
|
struct dispmsg_crtc_mode mode = modes[selection];
|
||||||
|
@ -492,11 +537,11 @@ retry_pick_mode:
|
||||||
uintmax_t req_bpp = bpp;
|
uintmax_t req_bpp = bpp;
|
||||||
uintmax_t req_width = xres;
|
uintmax_t req_width = xres;
|
||||||
uintmax_t req_height = yres;
|
uintmax_t req_height = yres;
|
||||||
while ( argc - optind < 1 )
|
while ( argc < 2 )
|
||||||
{
|
{
|
||||||
printf("Enter video mode [WIDTHxHEIGHTxBPP]: ");
|
printf("Enter video mode [BPP x WIDTH x HEIGHT]: ");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
if ( scanf("%jux%jux%ju", &req_width, &req_height, &req_bpp) != 3 )
|
if ( scanf("%ju x %ju x %ju", &req_bpp, &req_width, &req_height) != 3 )
|
||||||
{
|
{
|
||||||
fgetc(stdin);
|
fgetc(stdin);
|
||||||
fflush(stdin);
|
fflush(stdin);
|
||||||
|
@ -512,13 +557,12 @@ retry_pick_mode:
|
||||||
mode.control |= DISPMSG_CONTROL_VALID;
|
mode.control |= DISPMSG_CONTROL_VALID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !set_current_mode(mode) )
|
if ( !SetCurrentMode(mode) )
|
||||||
{
|
{
|
||||||
mode_set_error = errno;
|
error(0, mode_set_error = errno, "Unable to set video mode %ju x %ju x %ju",
|
||||||
warn("Unable to set video mode %jux%jux%ju",
|
(uintmax_t) mode.fb_format,
|
||||||
(uintmax_t) mode.view_xres,
|
(uintmax_t) mode.view_xres,
|
||||||
(uintmax_t) mode.view_yres,
|
(uintmax_t) mode.view_yres);
|
||||||
(uintmax_t) mode.fb_format);
|
|
||||||
goto retry_pick_mode;
|
goto retry_pick_mode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,6 @@ struct command commands[] =
|
||||||
{LOGOUT, "logout", NULL, suggest_logout},
|
{LOGOUT, "logout", NULL, suggest_logout},
|
||||||
|
|
||||||
{MOUNT, "extfs", "system", NULL},
|
{MOUNT, "extfs", "system", NULL},
|
||||||
{MOUNT, "iso9660fs", "system", NULL},
|
|
||||||
{MOUNT, "mount", NULL, NULL},
|
{MOUNT, "mount", NULL, NULL},
|
||||||
|
|
||||||
{PAGER, "less", NULL, NULL},
|
{PAGER, "less", NULL, NULL},
|
||||||
|
|
|
@ -33,5 +33,4 @@ It is not safe to shut down the computer directly after using this option.
|
||||||
will exit 0 on success and non-zero otherwise.
|
will exit 0 on success and non-zero otherwise.
|
||||||
.Sh SEE ALSO
|
.Sh SEE ALSO
|
||||||
.Xr unmount 2 ,
|
.Xr unmount 2 ,
|
||||||
.Xr extfs 8 ,
|
.Xr extfs 8
|
||||||
.Xr iso9660fs 8
|
|
||||||
|
|
Loading…
Reference in New Issue