1170809Sdelphij#!/bin/sh 2170809Sdelphij# 3170809Sdelphij# $NetBSD: t_setattr,v 1.6 2006/11/09 16:20:06 jmmv Exp $ 4170809Sdelphij# 5170809Sdelphij# Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. 6170809Sdelphij# All rights reserved. 7170809Sdelphij# 8170809Sdelphij# This code is derived from software contributed to The NetBSD Foundation 9170809Sdelphij# by Julio M. Merino Vidal, developed as part of Google's Summer of Code 10170809Sdelphij# 2005 program. 11170809Sdelphij# 12170809Sdelphij# Redistribution and use in source and binary forms, with or without 13170809Sdelphij# modification, are permitted provided that the following conditions 14170809Sdelphij# are met: 15170809Sdelphij# 1. Redistributions of source code must retain the above copyright 16170809Sdelphij# notice, this list of conditions and the following disclaimer. 17170809Sdelphij# 2. Redistributions in binary form must reproduce the above copyright 18170809Sdelphij# notice, this list of conditions and the following disclaimer in the 19170809Sdelphij# documentation and/or other materials provided with the distribution. 20170809Sdelphij# 21170809Sdelphij# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 22170809Sdelphij# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 23170809Sdelphij# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24170809Sdelphij# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 25170809Sdelphij# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26170809Sdelphij# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27170809Sdelphij# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28170809Sdelphij# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29170809Sdelphij# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30170809Sdelphij# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31170809Sdelphij# POSSIBILITY OF SUCH DAMAGE. 32170809Sdelphij# 33170809Sdelphij# $FreeBSD$ 34170809Sdelphij# 35170809Sdelphij 36170809Sdelphij# 37170809Sdelphij# Verifies that the setattr vnode operation works, using several commands 38170809Sdelphij# that require this function. 39170809Sdelphij# 40170809Sdelphij 41170809Sdelphijtest_run() { 42170809Sdelphij test_mount 43170809Sdelphij 44170809Sdelphij test_name "File owner can be changed on its own" 45170809Sdelphij mkdir own || die 46170809Sdelphij eval $(stat -s own | sed -e 's|st_|ost_|g') 47170809Sdelphij chown 1234 own || die 48170809Sdelphij eval $(stat -s own) 49170809Sdelphij [ ${st_uid} -eq 1234 ] || die 50170809Sdelphij [ ${st_gid} -eq ${ost_gid} ] || die 51170809Sdelphij 52170809Sdelphij mkdir ownq || die 53170809Sdelphij echo 'chown 1234 ownq' | kqueue_monitor 1 ownq || die 54170809Sdelphij test_name "Changing a file's owner raises NOTE_ATTRIB on it" 55170809Sdelphij kqueue_check ownq NOTE_ATTRIB || die 56170809Sdelphij 57170809Sdelphij test_name "File group can be changed on its own" 58170809Sdelphij mkdir grp || die 59170809Sdelphij eval $(stat -s grp | sed -e 's|st_|ost_|g') 60170809Sdelphij chgrp 5678 grp || die 61170809Sdelphij eval $(stat -s grp) 62170809Sdelphij [ ${st_uid} -eq ${ost_uid} ] || die 63170809Sdelphij [ ${st_gid} -eq 5678 ] || die 64170809Sdelphij 65170809Sdelphij mkdir grpq || die 66170809Sdelphij echo 'chgrp 1234 grpq' | kqueue_monitor 1 grpq || die 67170809Sdelphij test_name "Changing a file's group raises NOTE_ATTRIB on it" 68170809Sdelphij kqueue_check grpq NOTE_ATTRIB || die 69170809Sdelphij 70170809Sdelphij test_name "File owner and group can be changed at once" 71170809Sdelphij mkdir owngrp || die 72170809Sdelphij chown 1234:5678 owngrp || die 73170809Sdelphij eval $(stat -s owngrp) 74170809Sdelphij [ ${st_uid} -eq 1234 ] || die 75170809Sdelphij [ ${st_gid} -eq 5678 ] || die 76170809Sdelphij 77170809Sdelphij mkdir owngrpp || die 78170809Sdelphij echo 'chown 1234:5678 owngrpp' | kqueue_monitor 1 owngrpp || die 79170809Sdelphij test_name "Changing a file's owner and group raises NOTE_ATTRIB on it" 80170809Sdelphij kqueue_check owngrpp NOTE_ATTRIB || die 81170809Sdelphij 82170809Sdelphij test_name "File mode can be changed" 83170809Sdelphij mkdir mode || die 84170809Sdelphij chmod 0000 mode || die 85170809Sdelphij eval $(stat -s mode) 86170809Sdelphij [ ${st_mode} -eq 40000 ] || die 87170809Sdelphij 88170809Sdelphij mkdir modeq || die 89170809Sdelphij echo 'chmod 0000 modeq' | kqueue_monitor 1 modeq || die 90170809Sdelphij test_name "Updating a file's mode raises NOTE_ATTRIB on it" 91170809Sdelphij kqueue_check modeq NOTE_ATTRIB || die 92170809Sdelphij 93170809Sdelphij test_name "File times can be changed" 94170809Sdelphij mkdir times || die 95170809Sdelphij TZ=GMT touch -t 200501010101 times || die 96170809Sdelphij eval $(stat -s times) 97170809Sdelphij [ ${st_atime} = ${st_mtime} ] || die 98170809Sdelphij [ ${st_atime} = 1104541260 ] || die 99170809Sdelphij 100170809Sdelphij mkdir timesq || die 101170809Sdelphij echo 'touch timesq' | kqueue_monitor 1 timesq || die 102170809Sdelphij test_name "Updating a file's times raises NOTE_ATTRIB on it" 103170809Sdelphij kqueue_check timesq NOTE_ATTRIB || die 104170809Sdelphij 105170809Sdelphij test_unmount 106170809Sdelphij} 107170809Sdelphij 108170809Sdelphij. ${SUBRDIR}/h_funcs.subr 109