AMiLDA FORUM

You are not logged in.

Announcement

### Our Homepage is down at the moment...work in progress !! ###

#1 2007-02-03 15:29:24

sebainones
Developer
Argentina
From: Mendoza
Registered: 2006-11-10
Last visit: 2007-04-06
Posts: 17

Where close library is?

HI i am doing a kernel module for AMILDA. I have already compiled it  an used it . All works fine but now that  i have just added more functionality  I have a problem. I am willind to use the close function but the compiler refuses to accept me that function tongue

root@negra:/usr/src/AMiLDA# make modules | grep modulos
make -C modulos modules
make[3]: Entering directory `/usr/src/AMiLDA/linux-2.4.32-amilda/net/modulos'
make[4]: Entering directory `/usr/src/AMiLDA/linux-2.4.32-amilda/net/modulos/kudp_server'
kudp_server4.c: In function `kudp_server_thread':
kudp_server4.c:262: warning: implicit declaration of function `close'
make[4]: Leaving directory `/usr/src/AMiLDA/linux-2.4.32-amilda/net/modulos/kudp_server'
make[3]: Leaving directory `/usr/src/AMiLDA/linux-2.4.32-amilda/net/modulos'
root@negra:/usr/src/AMiLDA# cd /usr/src/AMiLDA/linux-2.4.32/

The "close" function  usually is in /include/asm/unistd.h but in Amilda i can find it for example in
/include/asm-alpha/unistd.h

root@negra:/usr/src/AMiLDA/linux-2.4.32/include/asm-alpha# grep close unistd.h
#define __NR_close                6
static inline long close(int fd)
        return sys_close(fd)

I am including that library in this way:
#include <asm-alpha/unistd.h>
Am i doing something in a wrong way or what?
Thx 4 ur hlp

Offline

 

#2 2007-02-03 18:34:54

sergioag
Developer
Peru
From: Lima
Registered: 2006-02-16
Last visit: 2011-08-15
Posts: 166
Website

Re: Where close library is?

Hi

Don't mess the kernel API with the C api. THey are completely different. Also, you're using a MIPS processor, so you must not include something from alpha, but from mips.

Hope this helps you

Sergio

Offline

 

#3 2007-02-03 19:37:14

sebainones
Developer
Argentina
From: Mendoza
Registered: 2006-11-10
Last visit: 2007-04-06
Posts: 17

Re: Where close library is?

HI
Thx for ur advice, but i think that i'm not messing up(imho) the kernel API with the C api.
The close function i am using i got it from a kernel module code from Alessandro Rubini that he uses in replace of daemonize

sprintf(current->comm,"ktftpd-main"); /* comm is 16 bytes */
    lock_kernel();   /* This seems to be required for exit_mm */
    exit_mm(current);
    unlock_kernel();
   
    /* close open files as well (stdin/out/err) are most likely open */
    for (i=255; i>=0; i--)
        if (current->files->fd[i])
            close(i);
    debug_print("Daemonized: OK\n");

Also thx for telling me  i must use mips instead of alpha. I was messing that. I thought i could use it anyway.
Nonetheless I was using asm-alpha/unistd.h  as an example  cuz in
asm-mips the close function implementation that i'm looking for it doesn't exist.

root@negra:/usr/src/AMiLDA/linux-2.4.32/include/asm# grep close unistd.h
#define __NR_close                      (__NR_Linux +   6)
#define __NR_close                      (__NR_Linux +   3)
#define __NR_close                      (__NR_Linux +   3)
static inline _syscall1(int,close,int,fd)

Instread in asm-alpha it does

root@negra:/usr/src/AMiLDA/linux-2.4.32/include/asm-alpha# grep close unistd.h
#define __NR_close                6
static inline long close(int fd)
        return sys_close(fd);
root@negra:/usr/src/AMiLDA/linux-2.4.32/include/asm-alpha#

That's why i quoted as an example just for showing that in asm-mips it doesn't exist but it isn't the case of asm-alpha.
Thx for ur advices and for replying me as fast as possible.

Offline

 

#4 2007-02-05 07:04:26

sergioag
Developer
Peru
From: Lima
Registered: 2006-02-16
Last visit: 2011-08-15
Posts: 166
Website

Re: Where close library is?

Hi

If the mips directory doesn't contain that call, then it isn't available in the mips platform. Don't forget that not all of the functions found in the kernel includes are for usage inside the kernel. Don't ask me what functions should be used and which don't, as i'm not a kernel specialist (just a newbie in device drivers development).

Hope this helps you

Sergio

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2008 PunBB