[LTP] [PATCH V5 01/10] tst_device: Add tst_is_mounted() helper

Viresh Kumar viresh.kumar@linaro.org
Wed Mar 11 08:31:13 CET 2020


On 07-03-20, 20:42, Li Wang wrote:
> On Fri, Mar 6, 2020 at 8:45 PM Cyril Hrubis <chrubis@suse.cz> wrote:
> 
> > ...
> > >
> > > +int tst_is_mounted(const char *path)
> > > +{
> > > +     char cmd[PATH_MAX];
> > > +     int ret;
> > > +
> > > +     snprintf(cmd, sizeof(cmd), "mountpoint -q %s", path);
> > > +     ret = tst_system(cmd);
> >
> > I'm not sure that depending on mountpoint command is right choice, there
> > are all kinds of embedded systems out there that may be missing it.
> 
> 
> Good point, we'd better avoid involving other packages as the dependence of
> LTP.
> 
> 
> > Also this does not even handle the case that the command is missing.
> >
> > Looking at the v4 version, all we need is to correctly parse each line
> > from from /proc/mounts. I would just use strsep() with space as a
> > delimited and took first token that starts with a slash i.e. '/', then
> > we can just strcmp() it against the path. Or do I miss something?
> >
> 
> I'm afraid strcmp() can not satisfy the requirement for us. As you know LTP
> creates the MNTPOINT in temp dir that means it could not accurately match
> the string path which extracts from /proc/mounts with a slash.
> 
> e.g
> #define MNTPOINT "fallocate"
> ...
> /dev/loop4 on /tmp/FPp7kh/fallocate type xfs
> (rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota)
> ...
> strcmp("/tmp/FPp7kh/fallocate", MNTPOINT) will never ruturn 0 to us.
> 
> What I can think of is to use strrchr() to cut the string after last '/',
> but that can only work for test mount fs in LTP ways. Other situations
> might not satisfy.

@Cyril, can we please finalize what you guys want me to do here ? I
don't really want to repost the patch, which still has issues :)

-- 
viresh


More information about the ltp mailing list