Skip to content

feat: Implement system power management with Ctrl+Alt+Del and Ctrl+Alt+Esc#32

Closed
ionutnechita wants to merge 2 commits intodifferrari:mainfrom
ionutnechita:power-commands
Closed

feat: Implement system power management with Ctrl+Alt+Del and Ctrl+Alt+Esc#32
ionutnechita wants to merge 2 commits intodifferrari:mainfrom
ionutnechita:power-commands

Conversation

@ionutnechita
Copy link
Copy Markdown

Description:

Added power management system with power_off() and reboot() functions
Implemented Ctrl+Alt+Del for system shutdown
Added Ctrl+Alt+Esc for system reboot
Added syscalls for power management (60: poweroff, 61: reboot)
Updated login screen with shutdown hint
Added necessary key code definitions

…t+Esc

Description:
 - Added power management system with power_off() and reboot() functions
 - Implemented Ctrl+Alt+Del for system shutdown
 - Added Ctrl+Alt+Esc for system reboot
 - Added syscalls for power management (60: poweroff, 61: reboot)
 - Updated login screen with shutdown hint
 - Added necessary key code definitions
Signed-off-by: Ionut Nechita <ionut_n2001@yahoo.com>
Signed-off-by: Ionut Nechita <ionut_n2001@yahoo.com>
kprintf("[FAT32] File not found in open_files for id %x", descriptor->id);
return 0;
}
// Limit to actual file size
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the improvement, but please keep the original TODO comment. We're not guaranteed that descriptor->size is the correct size, since it can be modified externally

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code itself is fine, it's just about remembering to properly implement this later on

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I will return to this section.

}

if (!active_proc){
kprintf("[LAUNCHER] Failed to read ELF file");
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the error messages shown here, since they're the only indication of what went wrong

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

dest[i] = ((uint8_t *)content)[i];
}

// Extract and display the ASCII strings that USER.ELF would have printed
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a message there to come back and fix the filesystem part. I'll delete it at some point.

Comment thread createfs
fi

if ! command -v "mkfs.fat" >/dev/null 2>&1; then
if ! command -v "/usr/sbin/mkfs.fat" >/dev/null 2>&1; then
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These paths should not be hardcoded. Check your $PATH to ensure you have them there, as this will break for other users

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My development operating system is OpenSUSE TW and that's why I use it that way, but I'll migrate to Manjaro in a few days. After that, I shouldn't have the problem anymore.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need to switch distros to make this work, just need to add /usr/sbin to your path like:

export PATH="$PATH:/usr/sbin"

for when doing development, or put that in your ~/.bashrc or equivalent to make it happen automatically. You could probably also just symlink /usr/sbin/mkfs.fat into a directory that is in your PATH if you didn't want to accidentally be able to run other stuff from /usr/sbin, though it shouldn't matter since you'd need to be root to do anything dangerous anyway.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @codebrainz.
I known this issue regarding mkfs.fat, but i have other issue with QEMU and SDL options in OpenSUSE TW.
That's why I would like to change to Manjaro.

#include "math/math.h"
#include "std/string.h"
#include "syscalls/syscalls.h"
#include "process/syscall.h" // For SYS_POWEROFF
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments (in the whole PR) are largely unnecessary. The code is self explanatory

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll keep that comment in mind.

@differrari
Copy link
Copy Markdown
Owner

Also, shutdown seems to crash when pressing the shortcut.
As for the overall code itself, was any of it AI generated?

@ionutnechita
Copy link
Copy Markdown
Author

Also, shutdown seems to crash when pressing the shortcut.
As for the overall code itself, was any of it AI generated?

It is written partly by me and partly by Qwen Coder AI.

@differrari
Copy link
Copy Markdown
Owner

As stated in the contributing guidelines of the project, use of AI is discouraged and PRs that appear to be largely made using AI will be rejected. Thank you for your contribution but the new functionality does appear to be largely written by AI, which is what I believe leads to some of the more inconsistent aspects of the code submitted.

@differrari differrari closed this Aug 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants