OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Mar 18, 2024 8:54 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: PLEASE DELETE! THIS TOPIC IS POINTLESS AND I DO APOLOGIZE
PostPosted: Sun Jul 11, 2021 10:34 pm 
Offline
User avatar

Joined: Sun Jul 11, 2021 8:47 pm
Posts: 3
Location: Unknown
Sorry for wasting everyones time. As Solar already discovered I am a total noob at programming however I wish to learn. Apparently my nonsense code wasn't the right approach and for that I do apologize. I will write a more detailed post regarding what kind of operating system I wish to make whilst asking for any advice I can get.

Here's a little hint as to what kind of operating system I am hoping to code.

A simple prompt/terminal/no GUI based OS similar to MS-DOS or an older operating system.

I wasn't looking for anything too fancy.

_________________
I really don't have much to say besides this simple fact. I came to learn everything I can about OS developement and any programming language I can manage to learn, read, and write. I am not here to do anything other than that.


Last edited by MrPsycho on Tue Jul 13, 2021 10:34 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: How to add a register/login system with username & passw
PostPosted: Mon Jul 12, 2021 11:03 am 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1590
You are skipping several layers of abstraction here. The code you showed first looks like user space code. But the kernel you showed at the end does not look like it would be capable of running user space code. Before you can get to what you want, there is a lot left to go. There is file systems, binary programs, possibly a run time linker, and of course system calls. Also, from the code it does not look like you have any storage drivers, or indeed any memory management, and all of that is going to be crucial.

When you have all that, you can take the login code you have and throw it in the bin. It is using clear text passwords, and that is about the most horrible thing you can do in the 21st century. Also, at that point you should have more than enough experience to come up with a login system yourself.

_________________
Carpe diem!


Top
 Profile  
 
 Post subject: Re: How to add a register/login system with username & passw
PostPosted: Mon Jul 12, 2021 2:30 pm 
Offline
Member
Member
User avatar

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 7612
Location: Germany
I intend no offense when I say, you should not try your hand at OS code at all at this point.

Your example code uses scanf() on (potentially malformed) user input, then does not check the return codes and uses the (potentially uninitialized) variable. It tries to read a "First Name" with "%c" (which reads ONE character). It does not check whether the fgets() calls actually received a full line or a partial one. It uses "magic numbers" all over the place ("20" and "30" should be named constants). You throw away the errno you got from your failed fopen() and instead give an error message that says "an error has ocurred" (instead of e.g. calling perror() which would give you the reason for the failed fopen()).

And that is just the user-space code.

All this marks you as a beginner. And, again, no offense intended, but a beginner shouldn't try to code the most involved, complex, and unforgiving type of code imaginable (kernel code). Not yet.

_________________
Every good solution is obvious once you've found it.


Last edited by Solar on Tue Jul 13, 2021 7:05 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: How to add a register/login system with username & passw
PostPosted: Mon Jul 12, 2021 3:10 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 27, 2006 9:42 am
Posts: 1925
Location: Athens, GA, USA
I would like to add that you should learn how to post code in a BBCode forum in a way which preserves indentation. There is a button marked' Code' at the top of the editor window, which will automatically insert the [ code] and [ /code] tags used to mark where code samples begin and end, like so:

Code:
#include "myOS/cpu/cpu-isr.h"
#include "myOS/drivers/drivers-screen.h"
#include "myOS/kernel/kernel.h"
#include "myOS/libc/libc-string.h"
#include "myOS/libc/libc-mem.h"
#include <stdio.h>
#include <stdlib.h>

void kernel_main() {
    isr_install();
    irq_install();

    asm("int $2");
    asm("int $3");

    kprint("Hello and welcome to myOS Version1.2\n"
                "This is an alpha test of myOS created approximately [date given]\n"
                "Please register or login to begin or type LOGIN or REGISTER to get started.\n"
                "You can also type END to halt the CPU or PAGE to request a kmalloc()\n> ");

    /* I don't exactly remember what PAGE does but it's in the code regardless. I might have that option replaced for the login/registration system. */

}


On a related note: indentation is not considered optional by anyone these days, and consistency in how you indent the code is important. Which indent style you use is your choice, but whichever one it is, pick one and stick to it.

_________________
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.


Top
 Profile  
 
 Post subject: Re: How to add a register/login system
PostPosted: Tue Jul 13, 2021 6:45 pm 
Offline
User avatar

Joined: Sun Jul 11, 2021 8:47 pm
Posts: 3
Location: Unknown
nullplan wrote:
You are skipping several layers of abstraction here. The code you showed first looks like user space code. But the kernel you showed at the end does not look like it would be capable of running user space code. Before you can get to what you want, there is a lot left to go. There is file systems, binary programs, possibly a run time linker, and of course system calls. Also, from the code it does not look like you have any storage drivers, or indeed any memory management, and all of that is going to be crucial.

When you have all that, you can take the login code you have and throw it in the bin. It is using clear text passwords, and that is about the most horrible thing you can do in the 21st century. Also, at that point you should have more than enough experience to come up with a login system yourself.



@Nullplan:

I see, well as quite clearly as Solar pointed out (I'll be giving kudos to especially Solar for taking a notice to this) that yes I am a beginner. However I am also taking everyone's notes, words, and criticism to heart as this is part of a dream of mine that I wish to fufill.

Kudos to Nullplan for first post on my topic


Solar wrote:
I intend no offense when I say, you should not try your hand at OS code at all at this point.

Your example code uses scanf() on (potentially malformed) user input, then does not check the return codes and uses the (potentially uninitialized) variable. It tries to read a "First Name" with "%c" (which reads ONE character). It does not check whether the fgets() calls actually received a full line or a partial one. It uses "magic numbers" all over the place ("20" and "30" should be named constants). You throw away the errno you got from your failed fopen() and instead give an error message that says "an error has ocurred" (instead of e.g. calling perror() which would give you the reason for the failed fopen()).

And that is just the user-space code.

All this marks you as a beginner. And, again, no offense intended, but a beginner shouldn't try to code the most involved, complex, and unforgiving type of code imaginable (kernel code). Not yet.



@Solar & @Nullplan:

Please forgive me Solar and Nullplan for attempting to explain this. Even though I know I can be an idiot sometimes and that programming languages are not easiest thing to learn which also are no where near my level of expertise; but I still want to learn and try my hardest before remotely thinking of giving up and throwing in the towel.

Kudos to Solar for posting on my topic

Schol-R-LEA wrote:
I would like to add that you should learn how to post code in a BBCode forum in a way which preserves indentation. There is a button marked' Code' at the top of the editor window, which will automatically insert the [ code] and [ /code] tags used to mark where code samples begin and end, like so:

Code:
#include "myOS/cpu/cpu-isr.h"
#include "myOS/drivers/drivers-screen.h"
#include "myOS/kernel/kernel.h"
#include "myOS/libc/libc-string.h"
#include "myOS/libc/libc-mem.h"
#include <stdio.h>
#include <stdlib.h>

void kernel_main() {
    isr_install();
    irq_install();

    asm("int $2");
    asm("int $3");

    kprint("Hello and welcome to myOS Version1.2\n"
                "This is an alpha test of myOS created approximately [date given]\n"
                "Please register or login to begin or type LOGIN or REGISTER to get started.\n"
                "You can also type END to halt the CPU or PAGE to request a kmalloc()\n> ");

    /* I don't exactly remember what PAGE does but it's in the code regardless. I might have that option replaced for the login/registration system. */

}


On a related note: indentation is not considered optional by anyone these days, and consistency in how you indent the code is important. Which indent style you use is your choice, but whichever one it is, pick one and stick to it.



@Schol-R-LEA:

Thank you for this information and please forgive me I honestly didn't know this was an option. I'm honestly a bit of a shut-in who lives out in the middle of no-where with a terrible wifi service whom rarely joins forums and places with similar layouts.

Kudos to Schol-R-LEA for posting on my topic

_________________
I really don't have much to say besides this simple fact. I came to learn everything I can about OS developement and any programming language I can manage to learn, read, and write. I am not here to do anything other than that.


Top
 Profile  
 
 Post subject: Re: PLEASE DELETE! THIS TOPIC IS POINTLESS AND I DO APOLOGIZ
PostPosted: Wed Jul 14, 2021 6:24 am 
Offline
Member
Member

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 1071
MrPsycho wrote:
A simple prompt/terminal/no GUI based OS similar to MS-DOS or an older operating system.

To code that, you should have a strong knowledge of ASM, as those OSes were coded in ASM. Also, I would recommend using Real Mode. Look at OSes like MikeOS and see how they handled some things. If you are going for DOS compatibility, look up MS-DOS interrupt listings and API details
Most importantly, have fun! It doesn't have to be perfect, just make it be something you will enjoy to write.
Good luck,
nexos

_________________
"How did you do this?"
"It's very simple — you read the protocol and write the code." - Bill Joy
Projects: NexNix | libnex | nnpkg


Top
 Profile  
 
 Post subject: Re: PLEASE DELETE! THIS TOPIC IS POINTLESS AND I DO APOLOGIZ
PostPosted: Wed Jul 14, 2021 8:50 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5069
Is the goal to make an OS that looks like DOS, or an OS that works like DOS?


Top
 Profile  
 
 Post subject: Re: How to add a register/login system
PostPosted: Wed Jul 14, 2021 9:11 am 
Offline
Member
Member
User avatar

Joined: Thu Nov 16, 2006 12:01 pm
Posts: 7612
Location: Germany
There is nothing you need to apologize for, and the topic is not pointless. Sorry if you felt under attack.

MrPsycho wrote:
...but I still want to learn and try my hardest before remotely thinking of giving up and throwing in the towel.


I would not dream of discouraging you. But at this point, the best learning experience you can have is by practicing user-space coding. Pick something you yourself might use. A diary. An appointment calendar. A vocabulary learning software. Anything, really -- but make sure it is something simple. Not something that requires complicated graphics, sound processing or the like. Just some data in, processing, data out. Implement that. Use it, find the bugs, fix them. Get acquainted with best practices in your chosen language. Post some of your code to a software review site. Add features to your project, get used to version control, ticket management, roadmaps, release versioning, perhaps even a small project website.

If you feel that project cannot teach you any more things, pick something more ambitious, perhaps with some algorithmics to it, and / or graphics. A checkers with AI opponent, for example. Develop that, with the same language or a different one, however you like.

The point is to get used to all the things that any software developer needs to learn about to get anywhere -- and doing so in an environment where a mistake gives you a debug-able error message instead of a triple-fault reboot or an unresponsive machine. Where tutorials and example code abound and are not limited to a niche community.

Become an experienced software engineer. Because you need to become one anyway. Consider all this necessary training for the big day when you climb into the ring.

Starting with kernel code as a beginner will just frustrate you unnecessarily. And your project will not get anywhere in time for the hardware you are developing on to not become utterly outdated. (When I started with PDCLib, neither x64, GPT, nor UEFI were a thing...

_________________
Every good solution is obvious once you've found it.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group