471,357 Members | 1,210 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,357 software developers and data experts.

Getting mount stats for filesystems

Hi, I am trying to find a way to figure out whether a certain remote
filesystem is mounted using tcp vs. udp in Python. I've looked at the
statvfs call and module but they don't give me anything useful (the
F_FLAGS field for both a tcp and a udp filesystem is the same.

I could, of course, get the output of mount and parse that but I would
prefer something more elegant.

Thanks for your help!

--
Mitko Haralanov mi***@qlogic.com
Senior Software Engineer 650.934.8064
System Interconnect Group http://www.qlogic.com

==========================================
Remember, UNIX spelled backwards is XINU.
-- Mt.
Jun 5 '07 #1
7 2713
Mitko Haralanov schrieb:
Hi, I am trying to find a way to figure out whether a certain remote
filesystem is mounted using tcp vs. udp in Python. I've looked at the
statvfs call and module but they don't give me anything useful (the
F_FLAGS field for both a tcp and a udp filesystem is the same.

I could, of course, get the output of mount and parse that but I would
prefer something more elegant.
I'm not quite sure what you want to achieve. You are on machine B,
and you want to find out whether a remote file system (on machine A)
is mounted remotely (say, from machine C)?

How do you answer that question with mount(8)?

Also, what is a tcp filesystem?

Regards,
Martin
Jun 5 '07 #2
On Tue, 05 Jun 2007 09:19:08 +0200
"Martin v. Löwis" <ma****@v.loewis.dewrote:
I'm not quite sure what you want to achieve. You are on machine B,
and you want to find out whether a remote file system (on machine A)
is mounted remotely (say, from machine C)?
Ok, let me try to explain:

I am on machine A, which has a NFS mounted filesystem hosted on machine
B. All I need to find out is whether the NFS filesystem is mounted
using tcp or udp.

--
Mitko Haralanov mi***@qlogic.com
Senior Software Engineer 650.934.8064
System Interconnect Group http://www.qlogic.com

==========================================
Paul: If rubbin' frozen dirt in your crotch is wrong, hey,
I don't wanna be right.
Jun 5 '07 #3
I am on machine A, which has a NFS mounted filesystem hosted on machine
B. All I need to find out is whether the NFS filesystem is mounted
using tcp or udp.
Ah, ok. I recommend to parse /proc/mounts.

Regards,
Martin
Jun 5 '07 #4
On Tue, 05 Jun 2007 20:14:01 +0200
"Martin v. Löwis" <ma****@v.loewis.dewrote:
Ah, ok. I recommend to parse /proc/mounts.
I was looking for something that reminded me less of Perl and more of C
but haven't been able to find such a method.

--
Mitko Haralanov mi***@qlogic.com
Senior Software Engineer 650.934.8064
System Interconnect Group http://www.qlogic.com

==========================================
.... A booming voice says, "Wrong, cretin!", and you notice that you
have turned into a pile of dust.
Jun 5 '07 #5
Mitko Haralanov schrieb:
On Tue, 05 Jun 2007 20:14:01 +0200
"Martin v. Löwis" <ma****@v.loewis.dewrote:
>Ah, ok. I recommend to parse /proc/mounts.

I was looking for something that reminded me less of Perl and more of C
but haven't been able to find such a method.
You could try to invoke getmntent(3). I'm not aware of a Python wrapper
for it, so you either try to write one yourself in C, or use ctypes to
write it in Python.

Regards,
Martin
Jun 5 '07 #6
On Tue, 05 Jun 2007 21:32:21 +0200
"Martin v. Löwis" <ma****@v.loewis.dewrote:
You could try to invoke getmntent(3). I'm not aware of a Python wrapper
for it, so you either try to write one yourself in C, or use ctypes to
write it in Python.
I am looking at ctypes and it might do what I need but I can't figure
out a way to convert a Python File object to a C FILE pointer (which is
the needed argument for getmntent).

Any ideas?

--
Mitko Haralanov mi***@qlogic.com
Senior Software Engineer 650.934.8064
System Interconnect Group http://www.qlogic.com

==========================================
Fry: That clover helped my rat-fink brother steal my dream of going
into space. Now I'll never get there.
Leela: You went there this morning for donuts.
Jun 5 '07 #7
I am looking at ctypes and it might do what I need but I can't figure
out a way to convert a Python File object to a C FILE pointer (which is
the needed argument for getmntent).

Any ideas?
I think you are supposed to pass the pointer to getmntent that you
obtained from setmntent (likely asking for read-only access).

Regards,
Martin
Jun 5 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by dan glenn | last post: by
1 post views Thread by tkpmep | last post: by
22 posts views Thread by Dale Pennington | last post: by
3 posts views Thread by tguclu | last post: by
3 posts views Thread by m.smith_1999 | last post: by
reply views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.