Welcome! Log In Create A New Profile

Advanced

error message by compiling procfs3.c

Posted by geos 
Hello!

I'm using Kubuntu Gutsy (7.10) and trying to learn something about kernel programming with the tldp.org tutorial.
Works fine, but here I get an error message by compiling the procfs3.c sample:

"/home/tobias/kernel/procfs3.c:114: error: dereferencing pointer to incomplete type"

Can anyone explain what's the problem and how to correct it?

compiler:
gcc (GCC) 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
Bert
Re: error message by compiling procfs3.c
April 04, 2008 06:33AM
Hi,

took me some time to figure this out, but "current" as it is used in this example in the function module_permission (I'm working through this tutorial myself too, currently) has to be defined, which happens in <linux/sched.h>. So a way to solve this problem, is including this header file at the beginning of procfs3.c

The beginning of this file would then look like:
/* 
 *  procfs3.c -  create a "file" in /proc, use the file_operation way
 *              to manage the file.
 */
 
#include <linux/kernel.h>       /* We're doing kernel work */
#include <linux/module.h>       /* Specifically, a module */
#include <linux/proc_fs.h>      /* Necessary because we use proc fs */
#include <asm/uaccess.h>        /* for copy_*_user */
#include <linux/sched.h>	/* for task properties (euid) */

#define PROC_ENTRY_FILENAME     "buffer2k"
#define PROCFS_MAX_SIZE         2048
(Note the additional include for sched.h)

Hope this helps,
Bert
After adding the sched.h line, the error now is:
procfs3.c:115: error: ‘struct task_struct’ has no member named ‘euid’
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 25 plus 15?
Message: