Re: [PATCH 2/2] fstests: add _require_hardlinks for all necessary tests

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



On Mon, Apr 13, 2020 at 08:33:29AM -0500, Eric Sandeen wrote:
> On 4/12/20 2:05 AM, Zorro Lang wrote:
> > On Thu, Apr 09, 2020 at 02:10:36PM -0500, Eric Sandeen wrote:
> >> Add a new _require function for hardlinks, to test hardlink support
> >> in all tests which need it.
> >>
> >> Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
> >> ---
> >>
> >> diff --git a/common/rc b/common/rc
> >> index 476d3d07..8bb9aa1f 100644
> >> --- a/common/rc
> >> +++ b/common/rc
> >> @@ -3493,6 +3493,18 @@ _require_symlinks()
> >>  	rm -f $target $link
> >>  }
> >>  
> >> +_require_hardlinks()
> >> +{
> >> +	local target=`mktemp -p $TEST_DIR`
> >> +	local link=`mktemp -p $TEST_DIR -u`
> >> +	ln `basename $target` $link
> > 
> > I really doubt if it works. Why we need the basename of the $target? It cause we
> > create a link in *current* directory, and the current directory isn't the
> > $TEST_DIR.
> > 
> > The _require_symlinks won't fail due to symlink can be created cross filesystems,
> > but hardlink can't. But that's not the _require_symlinks want to test, right?
> > 
> > So why we need the basename? Please correct me if I'm wrong.
> 
> Sigh, no I'm wrong.  I just copied _require_symlinks without looking closely, and
> dropped the "-s" for a hardlink.
> 
> I forgot that the argument to ln -s can be an arbitrary relative path,
> 
> "Symbolic links can hold arbitrary text; if later resolved, a relative link is
> interpreted in relation to its parent directory."

Wow, yes! The manual of *ln* talk about that. I even never noticed that :-P
Thanks for telling me about it. So the _require_symlinks is fine, but the
_require_hardlinks need to fixed.

Thanks,
Zorro

> 
> $ mkdir /tmp/test
> $ export TEST_DIR=/tmp/test
> $ target=`mktemp -p $TEST_DIR`
> $ link=`mktemp -p $TEST_DIR -u`
> 
> $ echo $target
> /tmp/test/tmp.zjKtdM7Y0r
> $ echo $link
> /tmp/test/tmp.sdmFq6vyyl
> 
> $ ln -s `basename $target` $link
> 
> $ ls -l /tmp/test
> total 0
> lrwxrwxrwx. 1 sandeen sandeen 14 Apr 13 08:27 tmp.sdmFq6vyyl -> tmp.zjKtdM7Y0r
> -rw-------. 1 sandeen sandeen  0 Apr 13 08:27 tmp.zjKtdM7Y0r
> 
> Thanks for catching this, and sorry for making such a mess of this series.
> 
> -Eric
> 




[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux