LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-07-2009, 01:29 PM   #1
skyknight
LQ Newbie
 
Registered: Sep 2008
Posts: 17

Rep: Reputation: 1
Question how to find proc mounted or not using C libraries


Hi Friends,

I want to know how to find whether proc or sys is mounted using C libraries.

I came across this file in kernel source tree[1] which showed me some idea.

But i dont know from where the CONFIG_ACPI_PROCFS_POWER or CONFIG_ACPI_SYSFS_POWER defined.

I like to use them in my project[2] for finding whether proc is mounted or not because my project totally depends on proc.

[1]
http://git.kernel.org/?p=linux/kerne...9efbb7;hb=HEAD

[2]
http://webattery.sf.net


Thanks,

Alagunambi Welkin
 
Old 05-07-2009, 06:57 PM   #2
rriggs
Member
 
Registered: Mar 2009
Location: Colorado, US
Distribution: Fedora 13, Fedora 14, RHEL6 Beta
Posts: 46

Rep: Reputation: 17
Why don't you just try to open the files in the proc or sys filesystem? That will tell you if they are there and readable. The open will fail with ENOENT if the file doesn't exist.
 
Old 05-08-2009, 05:28 AM   #3
skyknight
LQ Newbie
 
Registered: Sep 2008
Posts: 17

Original Poster
Rep: Reputation: 1
Hi,

Thanks for your reply.

I can do what you told, but in some distributions they are using sysfs insted of procfs so inorder to find which file system is used I need solution.


Alagunambi Welkin
 
Old 05-08-2009, 11:08 AM   #4
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
For those of us unacquainted with the differences, perhaps you could briefly explain them, and also how you would distinguish between them in some other context, such as with commandline tools, etc. This sounds like something that changed across kernel versions; maybe just checking the kernel version would suffice.
--- rod.
 
Old 05-08-2009, 07:47 PM   #5
rriggs
Member
 
Registered: Mar 2009
Location: Colorado, US
Distribution: Fedora 13, Fedora 14, RHEL6 Beta
Posts: 46

Rep: Reputation: 17
Quote:
I can do what you told, but in some distributions they are using sysfs insted of procfs so inorder to find which file system is used I need solution.
My reply was the solution. Try one. If it fails, try the other.
 
Old 05-08-2009, 08:55 PM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,140

Rep: Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123
Quote:
Originally Posted by theNbomr View Post
For those of us unacquainted with the differences, perhaps you could briefly explain them
This is probably as good as any. There is also doco under ../Documentation in the source tree.
 
Old 05-10-2009, 11:43 AM   #7
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
As of 2.6.29, both /proc and /sys are available in the kernel. I do not know if any distros turn one or the other off; I suppose that is possible in the kernel compilation but if true it seems it would break a lot of things.
 
Old 05-10-2009, 07:00 PM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,140

Rep: Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123Reputation: 4123
Quote:
Originally Posted by jiml8 View Post
As of 2.6.29, both /proc and /sys are available in the kernel..
I'm somewhat confused by this statement - both have been available "forever". At least since the 2.5 development kernels.
 
Old 05-10-2009, 11:47 PM   #9
skyknight
LQ Newbie
 
Registered: Sep 2008
Posts: 17

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by syg00 View Post
I'm somewhat confused by this statement - both have been available "forever". At least since the 2.5 development kernels.
ya its true that both are available but the fact is procfs have only process details, but for hardware related stuffs sysfs is used if you can see the following link you can understand. But we can select procfs to have hardware details.

http://git.kernel.org/?p=linux/kerne...9efbb7;hb=HEAD

Here kernel developer clearly mentioned what are the headers to use when procfs has hardware details, or sysfs has hardware details.

Thanks every one for your kind information.


Alagunambi Welkin
 
Old 05-11-2009, 09:00 AM   #10
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by syg00 View Post
I'm somewhat confused by this statement - both have been available "forever". At least since the 2.5 development kernels.
Perhaps I should have phrased it a bit differently: "As of 2.6.29, both /proc and /sys are STILL available in the kernel..."
 
Old 05-11-2009, 09:04 AM   #11
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
Quote:
Originally Posted by skyknight View Post
ya its true that both are available but the fact is procfs have only process details, but for hardware related stuffs sysfs is used if you can see the following link you can understand. But we can select procfs to have hardware details.

http://git.kernel.org/?p=linux/kerne...9efbb7;hb=HEAD

Here kernel developer clearly mentioned what are the headers to use when procfs has hardware details, or sysfs has hardware details.

Thanks every one for your kind information.


Alagunambi Welkin
/proc has a lot of hardware information in it. /sys is more-or-less a reorganization of /proc, and the kernel developers insist that /sys is a more rational structure (I suppose that is true). Kernel developers are encouraging use of /sys rather than /proc, so at some point I suppose /proc will become deprecated. It is hard to see, however, how /proc will ever go away, given the extensive use that everyone makes of it.
 
Old 05-11-2009, 11:26 PM   #12
skyknight
LQ Newbie
 
Registered: Sep 2008
Posts: 17

Original Poster
Rep: Reputation: 1
Unhappy

Quote:
Originally Posted by jiml8 View Post
/proc has a lot of hardware information in it. /sys is more-or-less a reorganization of /proc, and the kernel developers insist that /sys is a more rational structure (I suppose that is true). Kernel developers are encouraging use of /sys rather than /proc, so at some point I suppose /proc will become deprecated. It is hard to see, however, how /proc will ever go away, given the extensive use that everyone makes of it.

But i still didnt get the answer how to find hardware details are in procfs or in sysfs
 
  


Reply



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
proc, dev and others not mounted on boot after HD changed auroraglacialis Linux - Kernel 2 08-06-2008 08:57 AM
how to see the resource consumption of shared libraries in /proc, linuxdoniv Programming 1 03-23-2008 08:14 PM
find error in /proc BlueSpirit Slackware 7 10-14-2006 10:16 AM
proc and devpts mounted? shanenin Linux - Software 1 07-26-2005 06:25 PM
redhat 9.0 unbootable /proc not mounted cvanbrederode Linux - General 2 01-08-2004 12:20 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:34 AM.

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
Open Source Consulting | Domain Registration