LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-01-2008, 05:54 AM   #1
giri_blr
LQ Newbie
 
Registered: Jul 2008
Posts: 24

Rep: Reputation: 15
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.
 
Old 07-01-2008, 06:47 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
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.
 
Old 07-01-2008, 08:38 AM   #3
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,991

Rep: Reputation: 76
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.
 
Old 07-01-2008, 11:28 PM   #4
giri_blr
LQ Newbie
 
Registered: Jul 2008
Posts: 24

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by rjlee View Post
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.
 
Old 07-02-2008, 06:03 AM   #5
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,991

Rep: Reputation: 76
Quote:
Originally Posted by giri_blr View Post
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
 
Old 07-02-2008, 07:20 AM   #6
giri_blr
LQ Newbie
 
Registered: Jul 2008
Posts: 24

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by rjlee View Post
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...
 
Old 07-02-2008, 07:50 AM   #7
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,991

Rep: Reputation: 76
Quote:
Originally Posted by giri_blr View Post
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
 
Old 07-03-2008, 01:01 AM   #8
giri_blr
LQ Newbie
 
Registered: Jul 2008
Posts: 24

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by rjlee View Post
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
 
Old 07-03-2008, 12:51 PM   #9
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,991

Rep: Reputation: 76
Quote:
Originally Posted by giri_blr View Post
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
 
Old 07-03-2008, 11:35 PM   #10
giri_blr
LQ Newbie
 
Registered: Jul 2008
Posts: 24

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by rjlee View Post
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()?
 
Old 07-04-2008, 05:23 AM   #11
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,991

Rep: Reputation: 76
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Iptables and Mail funtion novice06 Linux - Security 9 03-23-2006 03:48 AM
error coding a funtion in c shams Programming 2 07-27-2004 09:47 PM
error: use funtion socket c in Qt Designer? nhan Programming 0 01-07-2004 02:30 AM
C funtion to obtain a process ID Linh Programming 5 06-18-2003 02:37 PM
Numbered Keypad doesn't funtion. l0f33t Linux - Hardware 1 05-25-2003 11:16 AM


All times are GMT -5. The time now is 09:14 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration