From: Stef Bon <stef@bononline.nl>
To: Ian Kent <raven@themaw.net>
Cc: autofs@linux.kernel.org
Subject: Re: How to determine a path is a mountpoint.
Date: Wed, 17 Feb 2010 13:43:31 +0100 [thread overview]
Message-ID: <201002171343.31360.stef@bononline.nl> (raw)
In-Reply-To: <4B7AD5DC.3010307@themaw.net>
On Tuesday 16 February 2010 18:29:00 Ian Kent wrote:
> On 02/16/2010 09:20 PM, Stef Bon wrote:
> > On Tuesday 16 February 2010 04:04:17 Ian Kent wrote:
> >> On 02/16/2010 05:53 AM, Stef Bon wrote:
> >>> Hello,
> >>
> >> Yes, checking /proc/mounts is slow but is the only way when using older
> >> versions of the kernel module.
> >>
> >> In a recent source tree, have a look at lib/mounts.c:is_mounted() and
> >> lib/dev-ioctl-lib.c, and in particular dev_ioctl_ismountpoint().
> >>
> >> Ian
> >
> > Thanks for you fast answer.
> >
> > I've checked the code and found the functions you're pointed, they are
> > indeed what I'm looking for.
> >
> > The function is_mounted looks like an internal function. It makes use of
> > a struct ioctl_ops, which is initialised with get_ioctl_ops. I do not
> > understand this, cause this function does not use any parameter (like
> > path!) so how does this function determine it's a mountpoint?
>
> Read lib/dev-ioctl-lib.c, that's why I mentioned it, it's not that long.
>
> It implements a set of functions for autofs control operations.
>
> Many of them can't be called by just any process but the
> dev_ioctl_ismountpoint() function can. It may not look that simple but
> if you take some time to understand what it is doing you can take the
> bits you need and that will end up being fairly simple.
>
> The one problem you do have is that if the kernel doesn't have the new
> device ioctl interface you will need to scan /proc/mounts, the same as
> is done by the is_mounted() function if it sees the new functionality
> isn't available.
Ok, but some helpe here is welcome. I've learned C just some months ago, and
programming devices is new to me.
Look at dev_ioctl_ismountpoint.
The parameters it's using are logopt, ioctlfd, path and mountpoint.
logopt has something to do with logging, and is important, but not the topic.
ioctlfd is the filedescriptor for the fifo(?) in /var/run:
/var/run/autofs.fifo-mnt-mount.md5key-sbon-mount
in /proc/1705/fd :
9 -> /var/run/autofs.fifo-mnt-mount.md5key-sbon-mount
and 15 -> /var/run/autofs.fifo-mnt-mount.md5key-root-mount
futher path is of course the path to be examined. Is it absolute or relative
and mountpoint is the value which is combination of DEV_IOCTL_IS_MOUNTED,
DEV_IOCTL_IS_AUTOFS and DEV_IOCTL_IS_OTHER.
Is my analysis good???
To be sure, the value's I'm looking for are autofs managed mountpoints
(DEV_IOCTL_IS_AUTOFS is 1) and the path is a mountpoint, which means
a resource is actually mounted here. (DEV_IOCTL_IS_OTHER).
I'm using a setup where the autofs managed directories are one level deep,
nothing more.
But does this function really return a path is a mountpoint. In my module,
it's already clear that it is an autofs managed dir. In my module autofs
managed dirs are of the form /mnt/mount.md5key/%USERID%/mount/%md5key%
where %md5key% is the md5sum of the resource record.
My fuse module checks the dirname of the path is equal to
/mnt/mount.md5key/%USERID%, and the basename is 32 long, and exists.
Resource records, containing all the information about a resource (local like
USB and remote like SMB and FTP) necessary to mount it.
Now I want to add a test in my fusemodule fuse-workspace-union about this
autofsmanaged directory is a an active mountpoint, or not active (expired/not
activated...).
It's not that important, but I want extra cosmetics. When mounted, I want the
module to show another icon than when not mounted.
Stef
>
> Ian
next prev parent reply other threads:[~2010-02-17 12:43 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-15 21:53 How to determine a path is a mountpoint Stef Bon
2010-02-16 3:04 ` Ian Kent
2010-02-16 13:20 ` Stef Bon
2010-02-16 17:29 ` Ian Kent
2010-02-17 12:43 ` Stef Bon [this message]
2010-02-17 14:25 ` Ian Kent
2010-02-18 23:18 ` Stef Bon
2010-02-19 3:57 ` Ian Kent
2010-02-19 14:11 ` Stef Bon
[not found] ` <201002211428.39077.stef@bononline.nl>
2010-02-22 3:54 ` Ian Kent
2010-02-22 16:30 ` Stef Bon
2010-02-22 16:38 ` Ian Kent
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201002171343.31360.stef@bononline.nl \
--to=stef@bononline.nl \
--cc=autofs@linux.kernel.org \
--cc=raven@themaw.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.