File: 052_hardlink

package info (click to toggle)
fsvs 1.2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 2,964 kB
  • ctags: 1,464
  • sloc: ansic: 16,650; sh: 5,885; perl: 783; makefile: 338; python: 90
file content (64 lines) | stat: -rwxr-xr-x 1,097 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash

set -e 
$PREPARE_DEFAULT > /dev/null
$INCLUDE_FUNCS
cd $WC

logfile=$LOGDIR/052.hard


mkdir X
for a in *
do
  test -d "$a" || ln "$a" X/$RANDOM-$a
done

$BINq st
$BINq ci -m"Just hardlinks" -odelay=yes

$WC2_UP_ST_COMPARE


if [[ "$UID" == 0 ]]
then
	mkdir G

	$INFO "Testing bind mounts"
	mount --bind tree G
# We use a sub-shell, so that the mount is surely removed.
  el=$(
		$BINq ci -mbind_mount -odelay=yes > $logfile 2>&1 &&
		$WC2_UP_ST_COMPARE > $logfile 2>&1 &&
		echo OK=$?
	)
  umount G
	if [[ "$el" -ne 0 ]]
	then
	  cat $logfile
	  $ERROR "Bind mount didn't work"
	fi

# Now the same, but tell it's copied.
	$INFO "Testing bind mounts as copy"
	mkdir H
	$BINdflt cp tree H
	mount --bind tree H
# We use a sub-shell, so that the mount is surely removed.
  el=$(
		$BINq ci -mbind_copy -odelay=yes > $logfile 2>&1 &&
		$WC2_UP_ST_COMPARE > $logfile 2>&1 &&
		echo OK=$?
	)
  umount H
	if [[ "$el" -ne 0 ]]
	then
	  cat $logfile
	  $ERROR "Bind mount, telling as copy, didn't work"
	fi

  $SUCCESS "Bind mounts work."
else
  $WARN "Cannot test binding mounts as user"
fi