LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   where are Library funtion definitions stored? (https://www.linuxquestions.org/questions/linux-newbie-8/where-are-library-funtion-definitions-stored-652784/)

giri_blr 07-01-2008 05:54 AM

where are Library funtion definitions stored?
 
I want to know the path where i can find the library function definitions. I want the definition for copy_to_user() function in particular. Please help.

pixellany 07-01-2008 06:47 AM

Welcome to LQ.

What library functions are you referring to? e.g. Linux utilities, C libraries, Python, etc.?

Try entering "copy_to_user" in a Google search.

rjlee 07-01-2008 08:38 AM

copy_to_user is one of two functions used to copy data between kernel space and user-space.

It is a kernel function, not a library function.

You will find its definition somewhere under /usr/include/linux, assuming that you have the kernel headers installed.

giri_blr 07-01-2008 11:28 PM

Quote:

Originally Posted by rjlee (Post 3200273)
copy_to_user is one of two functions used to copy data between kernel space and user-space.

It is a kernel function, not a library function.

You will find its definition somewhere under /usr/include/linux, assuming that you have the kernel headers installed.

I have the kernel headers installed. When i tried searching the "copy_to_user" with locate or grep commands to find any related file, i found a lot of files containing this content and most with assembly like coding. I am confused wich file is actually the source. I found functions "__copy_user" with definitions.

rjlee 07-02-2008 06:03 AM

Quote:

Originally Posted by giri_blr (Post 3200981)
I have the kernel headers installed. When i tried searching the "copy_to_user" with locate or grep commands to find any related file, i found a lot of files containing this content and most with assembly like coding. I am confused wich file is actually the source. I found functions "__copy_user" with definitions.

The actual definition is in asm/uaccess.h. And this is an assembler file, so asm will be a symbolic link to the asm directory of your architecture.

The methods with leading underscores (__copy_user etc) are normally implementation methods that you wouldn't use directly. You can normally ignore these unless you are looking at how it works.

Hope that helps,

由obert J Lee

giri_blr 07-02-2008 07:20 AM

Quote:

Originally Posted by rjlee (Post 3201315)
The actual definition is in asm/uaccess.h. And this is an assembler file, so asm will be a symbolic link to the asm directory of your architecture.

The methods with leading underscores (__copy_user etc) are normally implementation methods that you wouldn't use directly. You can normally ignore these unless you are looking at how it works.

Hope that helps,

由obert J Lee

Thanks Mr.Robert. This really gave me a clear picture. And I am actually trying to understand how these kernel functions work. In particular, copy_to_user and copy_from_user. I had a look into the file "../Linux/asm-i386/uaccess.h". I couldn't understand how the conversion "__copy_user" to "copy_to_user"-which we use in proramming work. I found a lot of macro definitions like..

#define copy_to_user(to,from,n) indirect_copy_user(to,from,n)
#define __copy_to_user(to,from,n) __indirect_copy_user(to,from,n)

#define __copy_to_user __direct_copy_user

Could you please give some further assitance...

rjlee 07-02-2008 07:50 AM

Quote:

Originally Posted by giri_blr (Post 3201383)
Thanks Mr.Robert. This really gave me a clear picture. And I am actually trying to understand how these kernel functions work. In particular, copy_to_user and copy_from_user. I had a look into the file "../Linux/asm-i386/uaccess.h". I couldn't understand how the conversion "__copy_user" to "copy_to_user"-which we use in proramming work. I found a lot of macro definitions like..

#define copy_to_user(to,from,n) indirect_copy_user(to,from,n)
#define __copy_to_user(to,from,n) __indirect_copy_user(to,from,n)

#define __copy_to_user __direct_copy_user

Could you please give some further assitance...

Okay. #define defines a macro, so when you say:
Code:

copy_to_user(a,b,c)
this gets translated into
Code:

indirect_copy_user(a,b,c)
You could go and look up the definition of indirect_copy_user, and eventually you would get to a definition. Which would probably be in assembler.

In general, the symbols with two underscores are implementations of the ones without them; __indirect_copy_user would implement the logic behind indirect_copy_user. This is done so that extra checking can be put into the "public" symbol, if the architecture allows it.

If you're just interested to know what copy_to_user and copy_from_user do, then you might be better off looking at a reference on kernel programming; you might try http://kernelbook.sourceforge.net/

There's also a manpage for the copy_to_user call at http://www.gnugeneration.com/mirrors...api/r4299.html

Hope that helps,

由obert J Lee

giri_blr 07-03-2008 01:01 AM

Quote:

Originally Posted by rjlee (Post 3201413)
Okay. #define defines a macro, so when you say:
Code:

copy_to_user(a,b,c)
this gets translated into
Code:

indirect_copy_user(a,b,c)
You could go and look up the definition of indirect_copy_user, and eventually you would get to a definition. Which would probably be in assembler.

In general, the symbols with two underscores are implementations of the ones without them; __indirect_copy_user would implement the logic behind indirect_copy_user. This is done so that extra checking can be put into the "public" symbol, if the architecture allows it.

If you're just interested to know what copy_to_user and copy_from_user do, then you might be better off looking at a reference on kernel programming; you might try http://kernelbook.sourceforge.net/

There's also a manpage for the copy_to_user call at http://www.gnugeneration.com/mirrors...api/r4299.html

Hope that helps,

由obert J Lee


I read the header file for the fn. "pcibios_read_config_dword()" as "bios32.h". But i couldn't found only "bios32.c" where the function call for "pcibios_read_config_dword()" is made. Also I found the fn. declaration in "pci.h" and a macro mapping to "pci_read_config_dword" in "compatmac.h". I need the definition for "pcibios_read_config_dword()"........ please help

rjlee 07-03-2008 12:51 PM

Quote:

Originally Posted by giri_blr (Post 3202534)
I read the header file for the fn. "pcibios_read_config_dword()" as "bios32.h". But i couldn't found only "bios32.c" where the function call for "pcibios_read_config_dword()" is made. Also I found the fn. declaration in "pci.h" and a macro mapping to "pci_read_config_dword" in "compatmac.h". I need the definition for "pcibios_read_config_dword()"........ please help

Typing pcibios_read_config_dword declaration into Google yields as the first match
Quote:

/org/scratch/cerb/linux/include/linux/pci.h:568: warning: static declaration for `pcibios_read_config_dword' follows non-static ...
So you might try linux/pci.h in you kernel headers directory.

Hope that helps,

由obert J Lee

giri_blr 07-03-2008 11:35 PM

Quote:

Originally Posted by rjlee (Post 3203146)
Typing pcibios_read_config_dword declaration into Google yields as the first match

So you might try linux/pci.h in you kernel headers directory.

Hope that helps,

由obert J Lee

I could find te declaration tere.Related to this function I found three files :
pci.h
compatmac.h
bios32.c

Where can I find the definition just like copy_to_user()?

rjlee 07-04-2008 05:23 AM

Here's one definition, for ARM processors. The location may vary between different processors, and possibly different architecture types:

http://www.srcdoc.com/linux_2.2.26/d...ce.html#l00079

Yours,

—Robert J Lee


All times are GMT -5. The time now is 07:38 AM.