LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to find proc mounted or not using C libraries (https://www.linuxquestions.org/questions/programming-9/how-to-find-proc-mounted-or-not-using-c-libraries-724454/)

skyknight 05-07-2009 01:29 PM

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

rriggs 05-07-2009 06:57 PM

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.

skyknight 05-08-2009 05:28 AM

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

theNbomr 05-08-2009 11:08 AM

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.

rriggs 05-08-2009 07:47 PM

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.

syg00 05-08-2009 08:55 PM

Quote:

Originally Posted by theNbomr (Post 3534692)
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.

jiml8 05-10-2009 11:43 AM

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.

syg00 05-10-2009 07:00 PM

Quote:

Originally Posted by jiml8 (Post 3536233)
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.

skyknight 05-10-2009 11:47 PM

Quote:

Originally Posted by syg00 (Post 3536471)
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

jiml8 05-11-2009 09:00 AM

Quote:

Originally Posted by syg00 (Post 3536471)
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..."

jiml8 05-11-2009 09:04 AM

Quote:

Originally Posted by skyknight (Post 3536621)
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.

skyknight 05-11-2009 11:26 PM

Quote:

Originally Posted by jiml8 (Post 3537066)
/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


All times are GMT -5. The time now is 04:37 PM.