Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Linux project no 1


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Linux project no 1

  1. 1. Linux project no 1 address: now is 20081208 Mon: I try again to do implementing system call and rebuild kernel I append today's date as the label, ie. 20081208 folder is in /usr/src/linux*-20081208 name of the new build is also wit *-20081208 I already expand my vmware disk vmdk with this command: All files modified are backed up using this extension: *.nur test file is in ~/system-call-examples/20081208/ ------- Old: --------------- trying this: -- twice & not successfull: rebuild kernel & install kernel give no error compile test code (testmycall.c) gives the following errors: Error code for the second trial: --------------------------------- In file included from testmycall.c:7: testmycall.h:9: error: expected declaration specifiers or ‘...’ before ‘mycall’ testmycall.h:9: error: expected declaration specifiers or ‘...’ before ‘i’ testmycall.c: In function ‘_syscall1’: testmycall.c:11: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
  2. 2. testmycall.h:9: error: parameter name omitted testmycall.h:9: error: parameter name omitted testmycall.c:15: error: expected ‘{’ at end of input --------------------------------- command to capture out and error: ./cmd 1>out.txt 2>err.txt I will try another steps from: How to build a kernel? Already done with Dung and successful: Need to do: Modify kernel Compile kernel Restart using new kernel Add a new system call: simplified system call with interrupt:
  3. 3. ========= IMPORTANT ============= Seems more practical resource is: (this is step by step instruction to create a new system call!) WORTH READING [SHOULD BE READ FIRST!] %20SysCall%20Add%20(Ubuntu%208.04).pdf (Similar to above, but for UBUNTU!) Detailed steps begin on page 4/6. ========= IMPORTANT ============= --> THIS IS like previous resource, and there IS steps to compile kernel! [WORTH READING] But it is obsolete! December 1st, 1999 You will read that we should use a floppy! Obsolete: o_add_systemcall.html rnel.html Similar project with detailed instructions:
  4. 4. (Not checked) Other links to check include: NOT WORTH READING Comment: .... this is new : May 14, 2008! but let me read first. And unfortunately, this is not a basic article to read! Part 1 First we edit the following program (with vim): #include <stdio.h> main() { while(1) ; } save the code as orchid.c then we compile it with gcc gcc orchit c -o orchid then we run it in the background: ./orchid & (to create another background process, just repeat that command. We need to make 20 background processes.) to view the process ID we use command ps After we found PID, we can see the memory location with this command ( ) $ pmap PID $ pmap 3724 And now we will create a C program to find the address of each task_struct data generated by each our orchid program. Resources helping us in doing this include:
  5. 5. but how to print each address pointing to task_struct data. This may help us: We now hope those above will solve our fist part of project 1. We have unsolved problem when compiling this code: We try to compile this simple C code (Cobaba.c): #include </usr/include/linux/kernel.h> #include </usr/include/linux/sched.h> #include </usr/include/sepol/module.h> int main() { struct task_struct *task; for_each_process (task) { printk("%s[%d]n", task->comm, task->pid); //printf("hello"); } return 0; } We found compile errors like this: Cobaba.c: In function ‘main’: Cobaba.c:9: error: expected ‘;’ before ‘{’ token What's wrong with our code? But it seems that we get the answer here:
  6. 6. Part 2 Now we will go to explore and understand second part of project 1. (although part 1 have not been solved yet) First question of part 2: After the above experiment, terminate the execution of the above 20 processes, and then execute orchid in the background. Then list (1) the PID of the group leader of the process that executes the above orchid and (2) the PID of the group leader of the shell process that creates the process which executes the above orchid. Answer: To terminate 20 process from part 1, we use kill command. $ kill PID How do we know the PID of the process(es) that we want to kill? Use ps command as above. After we kill all orchid processes, we start one orchid process in the background, then list the PID of the group leader of the process. What does group leader mean? Does it mean parent of the process? To list PID