1210967Spjd#!/bin/sh 2210967Spjd# $FreeBSD: releng/10.3/tools/regression/pjdfstest/tests/mknod/11.t 210967 2010-08-06 20:51:39Z pjd $ 3210967Spjd 4210967Spjddesc="mknod creates device files" 5210967Spjd 6210967Spjddir=`dirname $0` 7210967Spjd. ${dir}/../misc.sh 8210967Spjd 9210967Spjdcase "${os}" in 10210967SpjdSunOS) 11210967Spjd echo "1..40" 12210967Spjd ;; 13210967Spjd*) 14210967Spjd echo "1..28" 15210967Spjd ;; 16210967Spjdesac 17210967Spjd 18210967Spjdn0=`namegen` 19210967Spjdn1=`namegen` 20210967Spjd 21210967Spjdexpect 0 mkdir ${n1} 0755 22210967Spjdcdir=`pwd` 23210967Spjdcd ${n1} 24210967Spjd 25210967Spjdfor type in c b; do 26210967Spjd case "${type}" in 27210967Spjd c) 28210967Spjd stattype="char" 29210967Spjd ;; 30210967Spjd b) 31210967Spjd stattype="block" 32210967Spjd ;; 33210967Spjd esac 34210967Spjd 35210967Spjd # Create char special with old-style numbers 36210967Spjd expect 0 mknod ${n0} ${type} 0755 1 2 37210967Spjd expect ${stattype},0755 lstat ${n0} type,mode 38210967Spjd expect 1,2 lstat ${n0} major,minor 39210967Spjd expect EEXIST mknod ${n0} ${type} 0777 3 4 40210967Spjd expect 0 unlink ${n0} 41210967Spjd 42210967Spjd case "${os}" in 43210967Spjd SunOS) 44210967Spjd # Create char special with new-style numbers 45210967Spjd expect 0 mknod ${n0} ${type} 0755 4095 4095 46210967Spjd expect ${stattype},0755 lstat ${n0} type,mode 47210967Spjd expect 4095,4095 lstat ${n0} major,minor 48210967Spjd expect EEXIST mknod ${n0} ${type} 0777 4000 4000 49210967Spjd expect 0 unlink ${n0} 50210967Spjd 51210967Spjd # mknod returns EINVAL if device's numbers are too big 52210967Spjd # for 32-bit solaris !! 53210967Spjd expect EINVAL mknod ${n0} ${type} 0755 4096 262144 54210967Spjd ;; 55210967Spjd esac 56210967Spjd 57210967Spjd # POSIX: Upon successful completion, mknod(2) shall mark for update the 58210967Spjd # st_atime, st_ctime, and st_mtime fields of the file. Also, the st_ctime and 59210967Spjd # st_mtime fields of the directory that contains the new entry shall be marked 60210967Spjd # for update. 61210967Spjd expect 0 chown . 0 0 62210967Spjd time=`${fstest} stat . ctime` 63210967Spjd sleep 1 64210967Spjd expect 0 mknod ${n0} ${type} 0755 1 2 65210967Spjd atime=`${fstest} stat ${n0} atime` 66210967Spjd test_check $time -lt $atime 67210967Spjd mtime=`${fstest} stat ${n0} mtime` 68210967Spjd test_check $time -lt $mtime 69210967Spjd ctime=`${fstest} stat ${n0} ctime` 70210967Spjd test_check $time -lt $ctime 71210967Spjd mtime=`${fstest} stat . mtime` 72210967Spjd test_check $time -lt $mtime 73210967Spjd ctime=`${fstest} stat . ctime` 74210967Spjd test_check $time -lt $ctime 75210967Spjd expect 0 unlink ${n0} 76210967Spjddone 77210967Spjd 78210967Spjdcd ${cdir} 79210967Spjdexpect 0 rmdir ${n1} 80