<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Mar 11, 2020 at 6:26 PM Cyril Hrubis <<a href="mailto:chrubis@suse.cz">chrubis@suse.cz</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi!<br>
> > Also this does not even handle the case that the command is missing.<br>
> ><br>
> > Looking at the v4 version, all we need is to correctly parse each line<br>
> > from from /proc/mounts. I would just use strsep() with space as a<br>
> > delimited and took first token that starts with a slash i.e. '/', then<br>
> > we can just strcmp() it against the path. Or do I miss something?<br>
> ><br>
> <br>
> I'm afraid strcmp() can not satisfy the requirement for us. As you know LTP<br>
> creates the MNTPOINT in temp dir that means it could not accurately match<br>
> the string path which extracts from /proc/mounts with a slash.<br>
> <br>
> e.g<br>
> #define MNTPOINT "fallocate"<br>
> ...<br>
> /dev/loop4 on /tmp/FPp7kh/fallocate type xfs<br>
> (rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,noquota)<br>
> ...<br>
> strcmp("/tmp/FPp7kh/fallocate", MNTPOINT) will never ruturn 0 to us.<br>
> <br>
> What I can think of is to use strrchr() to cut the string after last '/',<br>
> but that can only work for test mount fs in LTP ways. Other situations<br>
> might not satisfy.<br>
<br>
Hmm, for that we have to have compose the path for the comparsion<br>
anyways, since unless we pass an absoule path we can never be user if we<br>
have a right match or not. There may be leftover mount points from a<br>
failed tests that have faile to cleanup properly as well.<br>
<br>
So I guess that we need one more function, with tmpdir in name, that<br>
would compose the right path for us and then call the tst_is_mntpoint().<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">+1 it makes sense to me.</div></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
I would have called that:<br>
<br>
int tst_is_mntpoint_at_tmpdir(const char *path);<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Hmm, the return value shouldn't the full right path, why return int here? or I misunderstand here?</div></div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>