[Tutor] Checking to see whether or not a filesystem is mounted--?
Morten Liebach
m at mongers.org
Sun Aug 8 10:20:50 CEST 2004
On 2004-08-08 02:46:08 +0200, Kalle Svensson wrote:
> Hi!
>
> [Marv Boyes]
> > Anyway, enough preamble. I'm wanting to write a small graphical applet
> > for mounting and unmounting filesystems with a button-press. Can anyone
> > suggest a method for testing whether or not a particular filesystem is
> > mounted (so I can inform the user with a message dialog)?
>
> I'd probably try reading the output of `mount`. This consists of one
> or more lines, formatted something like
>
> <device> on <mount point> type <fstype> [(<options>)]
>
> If there is a line matching the device you're interested in, the
> device is mounted. Otherwise it isn't, obviously.
>
> Symbolic links could make this more difficult, I suppose. E.g. if
> /foo is a symlink to /mnt/bar, /foo won't appear in the `mount` output
> even if /mnt/bar is mounted. I assume there are other difficulties as
> well. Otherwise it wouldn't be any fun, would it?
Try looking for the same device in /etc/fstab, that'll remove some
ambiguities.
Have a nice day
Morten
--
http://m.mongers.org/ -- http://gallery.zentience.org/
__END__
More information about the Tutor
mailing list