LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Trying to look at sources for common unix/linux commands (https://www.linuxquestions.org/questions/linux-general-1/trying-to-look-at-sources-for-common-unix-linux-commands-639284/)

IanGlenn 05-02-2008 03:14 AM

Trying to look at sources for common unix/linux commands
 
I was wondering if there is somewhere where i can look at the source for some basic commands in unix/linux like ls and who.

I'm an aspiring programmer and I'm just curious to see the code.

vin2008_linux 05-02-2008 04:09 AM

http://lxr.linux.no/
is the best one to have look @ code


I am not able to compile c code
gcc is not getting path of module.h and kernel.h

#include <module.h> /* Needed by all modules */
#include <kernel.h> /* Needed for KERN_INFO */

int init_module(void)
{
printk(KERN_INFO "Hello world 1.\n");
/*
* A non 0 return means init_module failed; module can't be loaded.
*/
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world 1.\n");
}
=========================
[root@linuxguru.symantec.com][ /usr/src ]gcc -o hello-1.0 hello-1.c
hello-1.c:1:54: error: module.h: No such file or directory
hello-1.c:2:53: error: kernel.h: No such file or directory
hello-1.c: In function ‘init_module’:
hello-1.c:6: error: ‘KERN_INFO’ undeclared (first use in this function)
hello-1.c:6: error: (Each undeclared identifier is reported only once
hello-1.c:6: error: for each function it appears in.)
hello-1.c:6: error: expected ‘)’ before string constant
hello-1.c: In function ‘cleanup_module’:
hello-1.c:14: error: ‘KERN_INFO’ undeclared (first use in this function)
hello-1.c:14: error: expected ‘)’ before string constant
[root@linuxguru.symantec.com][ /usr/src ]vi hello-1.c
=
plz compile @ ur end and let me know ?

pixellany 05-02-2008 04:56 AM

Quote:

Originally Posted by IanGlenn (Post 3139584)
I was wondering if there is somewhere where i can look at the source for some basic commands in unix/linux like ls and who.

I'm an aspiring programmer and I'm just curious to see the code.

ftp://ftp.gnu.org/gnu/

also, for a lot of Open-source SW, there are typically project pages at sourceforge.


All times are GMT -5. The time now is 06:46 PM.