-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Add tool to display emergency log message full-sceen on boot failure. #28077
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I want to start with a function that fetches the oldest message in the journal and displays it to the console. |
2022bbe
to
7bd44d9
Compare
@bluca Subsequently, I have to modify it to take over the entire screen, turn it blue, and display the QR code. Howevever, I am currently not getting an output at all, even when i change the PRIORITY to numbers other than 0. Thank you. |
src/journal/bsod.c
Outdated
_cleanup_close_ int fd = -EBADF; | ||
char * message = first_emerg_boot_message(); | ||
|
||
fd = open_terminal("/dev/console", O_WRONLY|O_NOCTTY|O_CLOEXEC); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so for this I think we should not go to /dev/console (which is a magic device that basically points to wherever boot time logs and stuff should go to which can be serial or similar) but the VT subsystem (which is the virtual terminal, i.e. a textual interface to a local physical display device, i.e. no serial), and I think we should not interfere with the usual log/progress output that /dev/console gets. Hence I'd suggest we allocate a full new VT for this, and then switch to that.
(in case you wonder what a VT is, it's this archaic textual display logic that the linux kernel uses to do early boot logging before wayland/x11 take over, and that you can log into via Alt-F2, Alt-F3, …)
i.e. open /dev/tty1 temporarily, then issue the VT_GETSTATE ioctl call on it which tells you which VTs are currently allocated via a bitmask. Look for the first free VT (i.e. determine lowest unset bit, then format /dev/tty%i with it plus one. Then open that, and use that. switch to it via the VT_ACTIVATE ioctl, then clear it by output ANSI_HOME_CLEAR on it, then display the message there.
If this sounds like a bit much, grep our sources for VT_GETSTAT, we already call that ioctl elsewhere for other reasons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VT_OPENQRY
might be easier than VT_GETSTATE
and __builtin_ctz(~vt_stat.v_state)
or whatever.
I read that the APIs return errno-style errors on failure. Kindly review my choice of error types sir. I made some of the requested changes. I still have the But I don't want to miss the chance of getting a review in case you view the PR, so I decided to push some first. |
I looked up the format string and format value macros sir, and I've now used them in the patch. So it's VT I need to look up now. perhaps I have too many log messages? |
Thank you so much @yuwata for the very detailed review. |
@yuwata, I made all the requested changes. |
needs a rebase on main due to conflicts |
Okay sir. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Let's go in this form at least now.
Future tasks are
- merge two qrcode logic more,
- add tests for bsod.service.
When you rebase and push, please also amend the commit message, as this is not about PID1, it's a different tool |
Certainly sir. |
Alright sir. |
No description provided.