mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Compilation Error with a Dynamic Module
@ 2002-10-20 19:22 Murali Therthala
  2002-10-20 20:43 ` Sam Ravnborg
  0 siblings, 1 reply; 2+ messages in thread
From: Murali Therthala @ 2002-10-20 19:22 UTC (permalink / raw)
  To: linux-kernel

Hi All,

I am trying to compile a dynamic module shown below that creates a readable
procs entry.
I invoke gcc as follows.

gcc -Wall -o2 -DMODULE -D_KERNEL_ -DLINUX -I
/lib/modules/`uname -r`\build/modules -c fMod3.c

and I get a whole bunch of errors with procfs.h.

/lib/modules/2.4.18-4GB/build/include/linux/proc_fs.h:47: parse error before
`off_t'
/lib/modules/2.4.18-4GB/build/include/linux/proc_fs.h:50: warning: `struct
file' declared inside parameter list
............................................................................
............................................................
............................................................................
............................................................

Could any of you offer me any hints to resolve this problem? I am using SUSE
with Kernel 2.4.18-4GB.
Thanks in advance for any feedback. Please see the source below.

Murali
----------------------------------------------------------------------------
---------------------------------

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/proc_fs.h>
#include <linux/sched.h>
#include <asm/uaccess.h>
#define MODULE_VERSION "1.0"
#define MODULE_NAME "My_procfs_example"
#define FOOBAR_LEN 8

struct fb_data_t
{
        char name[FOOBAR_LEN + 1];
        char value[FOOBAR_LEN + 1];
};

static struct proc_dir_entry  *example_dir,*foo_file;
struct fb_data_t   foo_data;

static int proc_read_foo(char *page,char **start,off_t off,int count,int
*eof,void *data)
{
        int len;
        struct fb_data_t *fb_data = (struct fb_data_t *)data;
        MOD_INC_USE_COUNT;
        len = sprintf(page, "%s = '%s'\n",fb_data->name, fb_data->value);
        MOD_DEC_USE_COUNT;
        return len;
}

static int __init init_procfs_example(void)
{
        int rv = 0;
        /* create directory */
        example_dir = proc_mkdir(MODULE_NAME, NULL);
        if(example_dir == NULL)
         {
                rv = -ENOMEM;
                goto out;
        }

        example_dir->owner = THIS_MODULE;

        foo_file = create_proc_entry("foo", 0644, example_dir);
        if(foo_file == NULL)
        {
                rv = -ENOMEM;
                goto no_foo;
        }
        strcpy(foo_data.name, "foo");
        strcpy(foo_data.value, "foo");
        foo_file->data = &foo_data;
        foo_file->read_proc = proc_read_foo;
        foo_file->write_proc = NULL;
        foo_file->owner = THIS_MODULE;

        printk(KERN_INFO "%s %s initialised\n",MODULE_NAME, MODULE_VERSION);
        return 0;

no_foo:
        remove_proc_entry("jiffies", example_dir);
out:
        return rv;
}

static void __exit cleanup_procfs_example(void)
{
        remove_proc_entry("foo", example_dir);
        remove_proc_entry(MODULE_NAME, NULL);
        printk(KERN_INFO "%s %s removed\n",MODULE_NAME, MODULE_VERSION);
}

module_init(init_procfs_example);
module_exit(cleanup_procfs_example);

MODULE_AUTHOR("XYZ");
MODULE_DESCRIPTION("A procfs example");

EXPORT_NO_SYMBOLS;


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Compilation Error with a Dynamic Module
  2002-10-20 19:22 Compilation Error with a Dynamic Module Murali Therthala
@ 2002-10-20 20:43 ` Sam Ravnborg
  0 siblings, 0 replies; 2+ messages in thread
From: Sam Ravnborg @ 2002-10-20 20:43 UTC (permalink / raw)
  To: Murali Therthala; +Cc: linux-kernel

On Sun, Oct 20, 2002 at 03:22:46PM -0400, Murali Therthala wrote:
> Hi All,
> 
> I am trying to compile a dynamic module shown below that creates a readable
> procs entry.
> I invoke gcc as follows.
> 
> gcc -Wall -o2 -DMODULE -D_KERNEL_ -DLINUX -I
> /lib/modules/`uname -r`\build/modules -c fMod3.c

The easiet way is to add
obj-m	+= myprocfsexample.o
to for example fs/Makefile

Then you can see what arguments are used for gcc in the real kernel compile.
I tried compiling your file in this way - no problem.

	Sam

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-10-20 20:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-20 19:22 Compilation Error with a Dynamic Module Murali Therthala
2002-10-20 20:43 ` Sam Ravnborg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®