Welcome! Log In Create A New Profile

Advanced

Adding new struct(s) for a new system call

Posted by fbcyborg 
Adding new struct(s) for a new system call
July 06, 2008 01:46PM
Hello everybody,

I'm adding a new system call to the linux kernel that needs two new structs.

I defined a .h file in which are defined these two structs.
My doubt is in their definition: using typedef or not? Yes, I know it's a really n00b question, but unfortunately I'm not so expert in C programming language.
I must go on on my job anyway in some way.

My system call gets information from the PCB of each process on the system, so each process must have a new field in its task_struct (I have 2 struct in the .h file - one of them has a pointer to the other one). So I included in the task_struct (sched.h) a new field which is the one that has the pointer to the other structure.

My .h file is like the following:
#ifndef __LINUX_INFO_H
#define __LINUX_INFO_H

#include <linux/unistd.h>
#include <linux/linkage.h>

typedef struct{
	int a;
	int b;
	int c;
} info;

typedef struct{
	int i;
	struct info *inf;
} my_struct;

#endif

I added to the PCB a pointer to the my_struct struct.

struct my_struct *ms;

I need to initialize the info struct in the do_fork() (fork.c) function. As you certainly know, there's a pointer to the current PCB in many critical function of the kernel (e.g. in the mm/ source files). Through that pointer I need to change the a, b and c values for the current process.
....
My compilation problems are in that file and are about the utilisation of the "." instead of "->" and vice versa.
I tryed all possibilities but compilation problems still remain, so I guess the main problem is elsewhere.

That's the reason why my doubt is in the correctness of my header file (needed for the system call).

Thanks a lot in advance.

PS: if I write the .h file without the typedef clause, I get a lot of errors like "multiple definition of ... first defined here" without any indication of where the error really is.

I Love



Edited 1 time(s). Last edit at 07/06/2008 01:50PM by fbcyborg.
Re: Adding new struct(s) for a new system call
July 11, 2008 10:40AM
Is there anybody in this forum???

I Love
Author:

Your Email:


Subject:


Spam prevention:
Please, solve the mathematical question and enter the answer in the input field below. This is for blocking bots that try to post this form automatically.
Question: how much is 10 plus 7?
Message: