140a8ac8fSEnji Cooper#!/bin/sh 2*3416500aSEnji Cooper# vim: filetype=sh noexpandtab ts=8 sw=8 340a8ac8fSEnji Cooper# $FreeBSD: head/tools/regression/pjdfstest/tests/mknod/11.t 211352 2010-08-15 21:24:17Z pjd $ 440a8ac8fSEnji Cooper 540a8ac8fSEnji Cooperdesc="mknod creates device files" 640a8ac8fSEnji Cooper 740a8ac8fSEnji Cooperdir=`dirname $0` 840a8ac8fSEnji Cooper. ${dir}/../misc.sh 940a8ac8fSEnji Cooper 1040a8ac8fSEnji Coopercase "${os}" in 1140a8ac8fSEnji CooperSunOS) 1240a8ac8fSEnji Cooper echo "1..40" 1340a8ac8fSEnji Cooper ;; 1440a8ac8fSEnji Cooper*) 1540a8ac8fSEnji Cooper echo "1..28" 1640a8ac8fSEnji Cooper ;; 1740a8ac8fSEnji Cooperesac 1840a8ac8fSEnji Cooper 1940a8ac8fSEnji Coopern0=`namegen` 2040a8ac8fSEnji Coopern1=`namegen` 2140a8ac8fSEnji Cooper 2240a8ac8fSEnji Cooperexpect 0 mkdir ${n1} 0755 2340a8ac8fSEnji Coopercdir=`pwd` 2440a8ac8fSEnji Coopercd ${n1} 2540a8ac8fSEnji Cooper 2640a8ac8fSEnji Cooperfor type in c b; do 2740a8ac8fSEnji Cooper case "${type}" in 2840a8ac8fSEnji Cooper c) 2940a8ac8fSEnji Cooper stattype="char" 3040a8ac8fSEnji Cooper ;; 3140a8ac8fSEnji Cooper b) 3240a8ac8fSEnji Cooper stattype="block" 3340a8ac8fSEnji Cooper ;; 3440a8ac8fSEnji Cooper esac 3540a8ac8fSEnji Cooper 3640a8ac8fSEnji Cooper # Create char special with old-style numbers 3740a8ac8fSEnji Cooper expect 0 mknod ${n0} ${type} 0755 1 2 3840a8ac8fSEnji Cooper expect ${stattype},0755 lstat ${n0} type,mode 3940a8ac8fSEnji Cooper expect 1,2 lstat ${n0} major,minor 4040a8ac8fSEnji Cooper expect EEXIST mknod ${n0} ${type} 0777 3 4 4140a8ac8fSEnji Cooper expect 0 unlink ${n0} 4240a8ac8fSEnji Cooper 4340a8ac8fSEnji Cooper case "${os}" in 4440a8ac8fSEnji Cooper SunOS) 4540a8ac8fSEnji Cooper # Create char special with new-style numbers 4640a8ac8fSEnji Cooper expect 0 mknod ${n0} ${type} 0755 4095 4095 4740a8ac8fSEnji Cooper expect ${stattype},0755 lstat ${n0} type,mode 4840a8ac8fSEnji Cooper expect 4095,4095 lstat ${n0} major,minor 4940a8ac8fSEnji Cooper expect EEXIST mknod ${n0} ${type} 0777 4000 4000 5040a8ac8fSEnji Cooper expect 0 unlink ${n0} 5140a8ac8fSEnji Cooper 5240a8ac8fSEnji Cooper # mknod returns EINVAL if device's numbers are too big 5340a8ac8fSEnji Cooper # for 32-bit solaris !! 5440a8ac8fSEnji Cooper expect EINVAL mknod ${n0} ${type} 0755 4096 262144 5540a8ac8fSEnji Cooper ;; 5640a8ac8fSEnji Cooper esac 5740a8ac8fSEnji Cooper 5840a8ac8fSEnji Cooper # POSIX: Upon successful completion, mknod(2) shall mark for update the 5940a8ac8fSEnji Cooper # st_atime, st_ctime, and st_mtime fields of the file. Also, the st_ctime and 6040a8ac8fSEnji Cooper # st_mtime fields of the directory that contains the new entry shall be marked 6140a8ac8fSEnji Cooper # for update. 6240a8ac8fSEnji Cooper expect 0 chown . 0 0 6340a8ac8fSEnji Cooper time=`${fstest} stat . ctime` 6440a8ac8fSEnji Cooper sleep 1 6540a8ac8fSEnji Cooper expect 0 mknod ${n0} ${type} 0755 1 2 6640a8ac8fSEnji Cooper atime=`${fstest} stat ${n0} atime` 6740a8ac8fSEnji Cooper test_check $time -lt $atime 6840a8ac8fSEnji Cooper mtime=`${fstest} stat ${n0} mtime` 6940a8ac8fSEnji Cooper test_check $time -lt $mtime 7040a8ac8fSEnji Cooper ctime=`${fstest} stat ${n0} ctime` 7140a8ac8fSEnji Cooper test_check $time -lt $ctime 7240a8ac8fSEnji Cooper mtime=`${fstest} stat . mtime` 7340a8ac8fSEnji Cooper test_check $time -lt $mtime 7440a8ac8fSEnji Cooper ctime=`${fstest} stat . ctime` 7540a8ac8fSEnji Cooper test_check $time -lt $ctime 7640a8ac8fSEnji Cooper expect 0 unlink ${n0} 7740a8ac8fSEnji Cooperdone 7840a8ac8fSEnji Cooper 7940a8ac8fSEnji Coopercd ${cdir} 8040a8ac8fSEnji Cooperexpect 0 rmdir ${n1} 81