summaryrefslogtreecommitdiffhomepage
path: root/src/kernel/KernelKit
diff options
context:
space:
mode:
author😄 Amlal El Mahrouss <amlal@nekernel.org>2026-03-24 12:37:20 +0100
committerGitHub <noreply@github.com>2026-03-24 12:37:20 +0100
commit48a0084c66f43eb2206fdfd757fb026bbd90d1eb (patch)
tree7ded7e3fddec1a79e134451e4be5bce0b3244897 /src/kernel/KernelKit
parent5b5081e679a0481356d1e026310546ac632b1c87 (diff)
parent6cf854b950e3884d6b5a08eb6059d1780f4d19db (diff)
Merge pull request #144 from ne-foss-org/user-system-utf8
[FEAT] Kernel: UTF-8 usage in UserMgr.
Diffstat (limited to 'src/kernel/KernelKit')
-rw-r--r--src/kernel/KernelKit/Semaphore.h7
-rw-r--r--src/kernel/KernelKit/User.h13
2 files changed, 16 insertions, 4 deletions
diff --git a/src/kernel/KernelKit/Semaphore.h b/src/kernel/KernelKit/Semaphore.h
index bb6b9ba9..4dc9a454 100644
--- a/src/kernel/KernelKit/Semaphore.h
+++ b/src/kernel/KernelKit/Semaphore.h
@@ -29,6 +29,7 @@ using SemaphoreArr = UInt64[kSemaphoreCount];
/// @brief Checks if the semaphore is valid.
inline bool rtl_sem_is_valid(const SemaphoreArr& sem, const UInt64& owner = 0) {
+ if (!sem) return false;
return sem[kSemaphoreOwnerIndex] == owner && sem[kSemaphoreCountIndex] > 0;
}
@@ -36,6 +37,8 @@ inline bool rtl_sem_is_valid(const SemaphoreArr& sem, const UInt64& owner = 0) {
/// @param sem
/// @return
inline bool rtl_sem_release(SemaphoreArr& sem) {
+ if (!sem) return false;
+
sem[kSemaphoreOwnerIndex] = 0;
sem[kSemaphoreCountIndex] = 0;
@@ -47,6 +50,8 @@ inline bool rtl_sem_release(SemaphoreArr& sem) {
/// @param owner the owner to set, could be anything identifitable.
/// @return
inline bool rtl_sem_acquire(SemaphoreArr& sem, const UInt64& owner) {
+ if (!sem) return false;
+
if (!owner) {
err_global_get() = kErrorInvalidData;
return false; // Invalid owner, return false and set KPC.
@@ -65,6 +70,8 @@ inline bool rtl_sem_acquire(SemaphoreArr& sem, const UInt64& owner) {
/// @return
inline bool rtl_sem_wait(SemaphoreArr& sem, const UInt64& owner, const UInt64& timeout,
bool& condition) {
+ if (!sem) return false;
+
if (!rtl_sem_is_valid(sem, owner)) {
return false;
}
diff --git a/src/kernel/KernelKit/User.h b/src/kernel/KernelKit/User.h
index bae51180..cc64bd1c 100644
--- a/src/kernel/KernelKit/User.h
+++ b/src/kernel/KernelKit/User.h
@@ -42,16 +42,16 @@ enum struct UserRingKind : Int32 {
kRingCount = 3,
};
-using UserPublicKey = Char*;
-using UserPublicKeyType = Char;
+using UserPublicKey = Char8*;
+using UserPublicKeyType = Char8;
/// @brief System User class.
class User final {
public:
User() = delete;
- User(const Int32& sel, const Char* username);
- User(const UserRingKind& kind, const Char* username);
+ User(const Int32& sel, const UserPublicKeyType* username);
+ User(const UserRingKind& kind, const UserPublicKeyType* username);
~User();
@@ -82,10 +82,15 @@ class User final {
/// @param password the password to check.
Bool Login(const UserPublicKey password);
+ /// @brief Returns whether the user is an adult or not.
+ Bool IsAdult();
+
private:
UserRingKind mUserRing{UserRingKind::kRingStdUser};
Char mUserName[kMaxUserNameLen] = {0};
UInt64 mUserFNV{0UL};
+ Bool mUserIsAdult{NO};
+
};
/// \brief Alias for user ptr.