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