]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - tools/regression/pjdfstest/tests/mknod/11.t
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / tools / regression / pjdfstest / tests / mknod / 11.t
1 #!/bin/sh
2 # $FreeBSD$
3
4 desc="mknod creates device files"
5
6 dir=`dirname $0`
7 . ${dir}/../misc.sh
8
9 case "${os}" in
10 SunOS)
11         echo "1..40"
12         ;;
13 *)
14         echo "1..28"
15         ;;
16 esac
17
18 n0=`namegen`
19 n1=`namegen`
20
21 expect 0 mkdir ${n1} 0755
22 cdir=`pwd`
23 cd ${n1}
24
25 for type in c b; do
26         case "${type}" in
27         c)
28                 stattype="char"
29                 ;;
30         b)
31                 stattype="block"
32                 ;;
33         esac
34
35         # Create char special with old-style numbers
36         expect 0 mknod ${n0} ${type} 0755 1 2
37         expect ${stattype},0755 lstat ${n0} type,mode
38         expect 1,2 lstat ${n0} major,minor
39         expect EEXIST mknod ${n0} ${type} 0777 3 4
40         expect 0 unlink ${n0}
41
42         case "${os}" in
43         SunOS)
44                 # Create char special with new-style numbers
45                 expect 0 mknod ${n0} ${type} 0755 4095 4095
46                 expect ${stattype},0755 lstat ${n0} type,mode
47                 expect 4095,4095 lstat ${n0} major,minor
48                 expect EEXIST mknod ${n0} ${type} 0777 4000 4000
49                 expect 0 unlink ${n0}
50
51                 # mknod returns EINVAL if device's numbers are too big
52                 # for 32-bit solaris !!
53                 expect EINVAL mknod ${n0} ${type} 0755 4096 262144
54                 ;;
55         esac
56
57         # POSIX: Upon successful completion, mknod(2) shall mark for update the
58         # st_atime, st_ctime, and st_mtime fields of the file. Also, the st_ctime and
59         # st_mtime fields of the directory that contains the new entry shall be marked
60         # for update.
61         expect 0 chown . 0 0
62         time=`${fstest} stat . ctime`
63         sleep 1
64         expect 0 mknod ${n0} ${type} 0755 1 2
65         atime=`${fstest} stat ${n0} atime`
66         test_check $time -lt $atime
67         mtime=`${fstest} stat ${n0} mtime`
68         test_check $time -lt $mtime
69         ctime=`${fstest} stat ${n0} ctime`
70         test_check $time -lt $ctime
71         mtime=`${fstest} stat . mtime`
72         test_check $time -lt $mtime
73         ctime=`${fstest} stat . ctime`
74         test_check $time -lt $ctime
75         expect 0 unlink ${n0}
76 done
77
78 cd ${cdir}
79 expect 0 rmdir ${n1}