1#!/bin/sh
| 1#!/bin/sh
|
2# $FreeBSD: head/tools/regression/fstest/tests/link/00.t 185227 2008-11-23 20:07:00Z pjd $
| 2# $FreeBSD: head/tools/regression/fstest/tests/link/00.t 211180 2010-08-11 16:34:44Z pjd $
|
3 4desc="link creates hardlinks" 5 6dir=`dirname $0` 7. ${dir}/../misc.sh 8
| 3 4desc="link creates hardlinks" 5 6dir=`dirname $0` 7. ${dir}/../misc.sh 8
|
9echo "1..82"
| 9echo "1..217"
|
10 11n0=`namegen` 12n1=`namegen` 13n2=`namegen` 14n3=`namegen` 15 16expect 0 mkdir ${n3} 0755 17cdir=`pwd` 18cd ${n3} 19
| 10 11n0=`namegen` 12n1=`namegen` 13n2=`namegen` 14n3=`namegen` 15 16expect 0 mkdir ${n3} 0755 17cdir=`pwd` 18cd ${n3} 19
|
20expect 0 create ${n0} 0644 21expect regular,0644,1 lstat ${n0} type,mode,nlink
| 20for type in regular fifo block char socket; do 21 create_file ${type} ${n0} 0 0 22 expect ${type},1 lstat ${n0} type,nlink
|
22
| 23
|
23expect 0 link ${n0} ${n1} 24expect regular,0644,2 lstat ${n0} type,mode,nlink 25expect regular,0644,2 lstat ${n1} type,mode,nlink
| 24 expect 0 link ${n0} ${n1} 25 expect ${type},2 lstat ${n0} type,nlink 26 expect ${type},2 lstat ${n1} type,nlink
|
26
| 27
|
27expect 0 link ${n1} ${n2} 28expect regular,0644,3 lstat ${n0} type,mode,nlink 29expect regular,0644,3 lstat ${n1} type,mode,nlink 30expect regular,0644,3 lstat ${n2} type,mode,nlink
| 28 expect 0 link ${n1} ${n2} 29 expect ${type},3 lstat ${n0} type,nlink 30 expect ${type},3 lstat ${n1} type,nlink 31 expect ${type},3 lstat ${n2} type,nlink
|
31
| 32
|
32expect 0 chmod ${n1} 0201 33expect 0 chown ${n1} 65534 65533
| 33 expect 0 chmod ${n1} 0201 34 expect 0 chown ${n1} 65534 65533
|
34
| 35
|
35expect regular,0201,3,65534,65533 lstat ${n0} type,mode,nlink,uid,gid 36expect regular,0201,3,65534,65533 lstat ${n1} type,mode,nlink,uid,gid 37expect regular,0201,3,65534,65533 lstat ${n2} type,mode,nlink,uid,gid
| 36 expect ${type},0201,3,65534,65533 lstat ${n0} type,mode,nlink,uid,gid 37 expect ${type},0201,3,65534,65533 lstat ${n1} type,mode,nlink,uid,gid 38 expect ${type},0201,3,65534,65533 lstat ${n2} type,mode,nlink,uid,gid
|
38
| 39
|
39expect 0 unlink ${n0} 40expect ENOENT lstat ${n0} type,mode,nlink,uid,gid 41expect regular,0201,2,65534,65533 lstat ${n1} type,mode,nlink,uid,gid 42expect regular,0201,2,65534,65533 lstat ${n2} type,mode,nlink,uid,gid
| 40 expect 0 unlink ${n0} 41 expect ENOENT lstat ${n0} type,mode,nlink,uid,gid 42 expect ${type},0201,2,65534,65533 lstat ${n1} type,mode,nlink,uid,gid 43 expect ${type},0201,2,65534,65533 lstat ${n2} type,mode,nlink,uid,gid
|
43
| 44
|
44expect 0 unlink ${n2} 45expect ENOENT lstat ${n0} type,mode,nlink,uid,gid 46expect regular,0201,1,65534,65533 lstat ${n1} type,mode,nlink,uid,gid 47expect ENOENT lstat ${n2} type,mode,nlink,uid,gid
| 45 expect 0 unlink ${n2} 46 expect ENOENT lstat ${n0} type,mode,nlink,uid,gid 47 expect ${type},0201,1,65534,65533 lstat ${n1} type,mode,nlink,uid,gid 48 expect ENOENT lstat ${n2} type,mode,nlink,uid,gid
|
48
| 49
|
49expect 0 unlink ${n1} 50expect ENOENT lstat ${n0} type,mode,nlink,uid,gid 51expect ENOENT lstat ${n1} type,mode,nlink,uid,gid 52expect ENOENT lstat ${n2} type,mode,nlink,uid,gid
| 50 expect 0 unlink ${n1} 51 expect ENOENT lstat ${n0} type,mode,nlink,uid,gid 52 expect ENOENT lstat ${n1} type,mode,nlink,uid,gid 53 expect ENOENT lstat ${n2} type,mode,nlink,uid,gid 54done
|
53
| 55
|
54expect 0 mkfifo ${n0} 0644 55expect fifo,0644,1 lstat ${n0} type,mode,nlink 56 57expect 0 link ${n0} ${n1} 58expect fifo,0644,2 lstat ${n0} type,mode,nlink 59expect fifo,0644,2 lstat ${n1} type,mode,nlink 60 61expect 0 link ${n1} ${n2} 62expect fifo,0644,3 lstat ${n0} type,mode,nlink 63expect fifo,0644,3 lstat ${n1} type,mode,nlink 64expect fifo,0644,3 lstat ${n2} type,mode,nlink 65 66expect 0 chmod ${n1} 0201 67expect 0 chown ${n1} 65534 65533 68 69expect fifo,0201,3,65534,65533 lstat ${n0} type,mode,nlink,uid,gid 70expect fifo,0201,3,65534,65533 lstat ${n1} type,mode,nlink,uid,gid 71expect fifo,0201,3,65534,65533 lstat ${n2} type,mode,nlink,uid,gid 72 73expect 0 unlink ${n0} 74expect ENOENT lstat ${n0} type,mode,nlink,uid,gid 75expect fifo,0201,2,65534,65533 lstat ${n1} type,mode,nlink,uid,gid 76expect fifo,0201,2,65534,65533 lstat ${n2} type,mode,nlink,uid,gid 77 78expect 0 unlink ${n2} 79expect ENOENT lstat ${n0} type,mode,nlink,uid,gid 80expect fifo,0201,1,65534,65533 lstat ${n1} type,mode,nlink,uid,gid 81expect ENOENT lstat ${n2} type,mode,nlink,uid,gid 82 83expect 0 unlink ${n1} 84expect ENOENT lstat ${n0} type,mode,nlink,uid,gid 85expect ENOENT lstat ${n1} type,mode,nlink,uid,gid 86expect ENOENT lstat ${n2} type,mode,nlink,uid,gid 87
| |
88# successful link(2) updates ctime.
| 56# successful link(2) updates ctime.
|
89expect 0 create ${n0} 0644 90ctime1=`${fstest} stat ${n0} ctime` 91dctime1=`${fstest} stat . ctime` 92dmtime1=`${fstest} stat . mtime` 93sleep 1 94expect 0 link ${n0} ${n1} 95ctime2=`${fstest} stat ${n0} ctime` 96test_check $ctime1 -lt $ctime2 97dctime2=`${fstest} stat . ctime` 98test_check $dctime1 -lt $dctime2 99dmtime2=`${fstest} stat . mtime` 100test_check $dctime1 -lt $dmtime2 101expect 0 unlink ${n0} 102expect 0 unlink ${n1}
| 57for type in regular fifo block char socket; do 58 create_file ${type} ${n0} 0 0 59 ctime1=`${fstest} stat ${n0} ctime` 60 dctime1=`${fstest} stat . ctime` 61 dmtime1=`${fstest} stat . mtime` 62 sleep 1 63 expect 0 link ${n0} ${n1} 64 ctime2=`${fstest} stat ${n0} ctime` 65 test_check $ctime1 -lt $ctime2 66 dctime2=`${fstest} stat . ctime` 67 test_check $dctime1 -lt $dctime2 68 dmtime2=`${fstest} stat . mtime` 69 test_check $dctime1 -lt $dmtime2 70 expect 0 unlink ${n0} 71 expect 0 unlink ${n1} 72done
|
103
| 73
|
104expect 0 mkfifo ${n0} 0644 105ctime1=`${fstest} stat ${n0} ctime` 106dctime1=`${fstest} stat . ctime` 107dmtime1=`${fstest} stat . mtime` 108sleep 1 109expect 0 link ${n0} ${n1} 110ctime2=`${fstest} stat ${n0} ctime` 111test_check $ctime1 -lt $ctime2 112dctime2=`${fstest} stat . ctime` 113test_check $dctime1 -lt $dctime2 114dmtime2=`${fstest} stat . mtime` 115test_check $dctime1 -lt $dmtime2 116expect 0 unlink ${n0} 117expect 0 unlink ${n1} 118
| |
119# unsuccessful link(2) does not update ctime.
| 74# unsuccessful link(2) does not update ctime.
|
120expect 0 create ${n0} 0644 121expect 0 -- chown ${n0} 65534 -1 122ctime1=`${fstest} stat ${n0} ctime` 123dctime1=`${fstest} stat . ctime` 124dmtime1=`${fstest} stat . mtime` 125sleep 1 126expect EACCES -u 65534 link ${n0} ${n1} 127ctime2=`${fstest} stat ${n0} ctime` 128test_check $ctime1 -eq $ctime2 129dctime2=`${fstest} stat . ctime` 130test_check $dctime1 -eq $dctime2 131dmtime2=`${fstest} stat . mtime` 132test_check $dctime1 -eq $dmtime2 133expect 0 unlink ${n0}
| 75for type in regular fifo block char socket; do 76 create_file ${type} ${n0} 0 0 77 expect 0 -- chown ${n0} 65534 -1 78 ctime1=`${fstest} stat ${n0} ctime` 79 dctime1=`${fstest} stat . ctime` 80 dmtime1=`${fstest} stat . mtime` 81 sleep 1 82 expect EACCES -u 65534 link ${n0} ${n1} 83 ctime2=`${fstest} stat ${n0} ctime` 84 test_check $ctime1 -eq $ctime2 85 dctime2=`${fstest} stat . ctime` 86 test_check $dctime1 -eq $dctime2 87 dmtime2=`${fstest} stat . mtime` 88 test_check $dctime1 -eq $dmtime2 89 expect 0 unlink ${n0} 90done
|
134
| 91
|
135expect 0 mkfifo ${n0} 0644 136expect 0 -- chown ${n0} 65534 -1 137ctime1=`${fstest} stat ${n0} ctime` 138dctime1=`${fstest} stat . ctime` 139dmtime1=`${fstest} stat . mtime` 140sleep 1 141expect EACCES -u 65534 link ${n0} ${n1} 142ctime2=`${fstest} stat ${n0} ctime` 143test_check $ctime1 -eq $ctime2 144dctime2=`${fstest} stat . ctime` 145test_check $dctime1 -eq $dctime2 146dmtime2=`${fstest} stat . mtime` 147test_check $dctime1 -eq $dmtime2 148expect 0 unlink ${n0} 149
| |
150cd ${cdir} 151expect 0 rmdir ${n3}
| 92cd ${cdir} 93expect 0 rmdir ${n3}
|