Date: Thu, 14 Dec 2006 20:58:15 -0600 From: "Scot Hetzel" <swhetzel@gmail.com> To: "Divacky Roman" <xdivac02@stud.fit.vutbr.cz> Cc: emulation@freebsd.org Subject: Re: linuxolator: utimes implementation Message-ID: <790a9fff0612141858x3a0a4ce5vc348d32d9b56f343@mail.gmail.com> In-Reply-To: <20061214153029.GA36558@stud.fit.vutbr.cz> References: <790a9fff0612140333ofd0891el59f767329f291371@mail.gmail.com> <20061214153029.GA36558@stud.fit.vutbr.cz>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
On 12/14/06, Divacky Roman <xdivac02@stud.fit.vutbr.cz> wrote:
> On Thu, Dec 14, 2006 at 05:33:40AM -0600, Scot Hetzel wrote:
> > While I was running the the tests for ltp-full-20061121, I noticed
> > that the utimes function wasn't implemented in the linuxolator.
> >
> > I looked up the man page and found that it was similar to the utime
> > function, except that it allows a program to set an inode down to the
> > microsecond.
> >
> > Merging together the linux_utime and freebsd32_utimes functions, I was
> > able to create the linux_utimes function.
>
> what about this patch instead (only relevant part):
>
I'm able to compile the linux module with this patch, and I no longer
see "* utimes not implemented" when running the ltp testcases.
The attached patch to ltp-20061121 implements testcases for utimes
(based on the utime testcases). It currently is failing the utimes04,
and utimes05 testcases:
utimes04 1 FAIL : tmp_file access and modification times usec not set
utimes05 1 FAIL : tmp_file access and modification times usec not set
This might be because I'm not using the right field from the stat
function to get the access and modification times for the usec in
these testcases. If I comment out the code that checks the usec, then
these two tests pass.
Scot
--
DISCLAIMER:
No electrons were mamed while sending this message. Only slightly bruised.
[-- Attachment #2 --]
diff -ruN ltp-full-20061121-orig/runtest/ltplite ltp-full-20061121/runtest/ltplite
--- ltp-full-20061121-orig/runtest/ltplite Tue Nov 21 14:31:20 2006
+++ ltp-full-20061121/runtest/ltplite Thu Dec 14 12:59:43 2006
@@ -955,6 +955,14 @@
utime05 utime05
utime06 utime06
+utimes01 utimes01
+utimes01A symlink01 -T utimes01
+utimes02 utimes02
+utimes03 utimes03
+utimes04 utimes04
+utimes05 utimes05
+utimes06 utimes06
+
vfork01 vfork01
vfork02 vfork02
diff -ruN ltp-full-20061121-orig/runtest/stress.part3 ltp-full-20061121/runtest/stress.part3
--- ltp-full-20061121-orig/runtest/stress.part3 Tue Nov 21 14:31:20 2006
+++ ltp-full-20061121/runtest/stress.part3 Thu Dec 14 13:00:56 2006
@@ -838,6 +838,14 @@
utime05 utime05
utime06 utime06
+utimes01 utimes01
+utimes01A symlink01 -T utimes01
+utimes02 utimes02
+utimes03 utimes03
+utimes04 utimes04
+utimes05 utimes05
+utimes06 utimes06
+
vfork01 vfork01
vfork02 vfork02
diff -ruN ltp-full-20061121-orig/runtest/syscalls ltp-full-20061121/runtest/syscalls
--- ltp-full-20061121-orig/runtest/syscalls Tue Nov 21 14:31:20 2006
+++ ltp-full-20061121/runtest/syscalls Thu Dec 14 13:01:12 2006
@@ -942,6 +942,14 @@
utime05 utime05
utime06 utime06
+utimes01 utimes01
+utimes01A symlink01 -T utimes01
+utimes02 utimes02
+utimes03 utimes03
+utimes04 utimes04
+utimes05 utimes05
+utimes06 utimes06
+
vfork01 vfork01
vfork02 vfork02
diff -ruN ltp-full-20061121-orig/testcases/kernel/syscalls/symlink/symlink01.c ltp-full-20061121/testcases/kernel/syscalls/symlink/symlink01.c
--- ltp-full-20061121-orig/testcases/kernel/syscalls/symlink/symlink01.c Tue Nov 21 14:31:28 2006
+++ ltp-full-20061121/testcases/kernel/syscalls/symlink/symlink01.c Thu Dec 14 18:21:04 2006
@@ -152,6 +152,17 @@
*
* WALL CLOCK TIME : 3
*
+* TEST IDENTIFIER : utimes01 (utimes)
+*
+* TEST TITLE : Set File Access And Modify Object File Times
+* Indirectly From a Symbolic Link File
+*
+* PARENT DOCUMENT : symtds01
+*
+* TEST CASE TOTAL : 3
+*
+* WALL CLOCK TIME : 3
+*
* TEST IDENTIFIER : rename01 (rename)
*
* TEST TITLE : Rename a Symbolic Link File And Not Any Object
@@ -253,6 +264,12 @@
* 2. Receive ENOENT error when accessing non-existent directory through symbolic link file
* 3. Receive ELOOP error when nesting of symbolic links exceed maximum
*
+* For utimes
+*
+* 1. Change inode times of object file through a symbolic link file
+* 2. Receive ENOENT error when accessing non-existent directory through symbolic link file
+* 3. Receive ELOOP error when nesting of symbolic links exceed maximum
+*
* For rename
*
* 1. Rename a symbolic link file which points at no object file
@@ -277,12 +294,14 @@
*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#**/
#include <stdio.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <unistd.h>
#include <signal.h>
#include <string.h>
#include <fcntl.h> /* open(2) system call */
-#include <errno.h>
-#include <sys/types.h>
#include <utime.h> /* utime(2) system call */
+#include <sys/time.h> /* utimes(2) system call */
#include <sys/param.h>
#include <sys/stat.h> /* stat(2) and lstat(2) system calls */
@@ -307,6 +326,7 @@
void do_unlink();
void do_chmod();
void do_utime();
+void do_utimes();
void do_rename();
void do_open();
@@ -329,6 +349,7 @@
#define UNLINK "unlink01"
#define CHMOD "chmod01"
#define UTIME "utime01"
+#define UTIMES "utimes01"
#define RENAME "rename01"
#define OPEN "open01"
@@ -372,6 +393,8 @@
"Nested symbolic link access condition caught. ELOOP is returned",
"Reading a nonsymbolic link file error condition is caught. EINVAL is returned",
"lstat(2) of object file returns object file inode information",
+ "utimes(2) change of object file access and modify times through symbolic link file is ok",
+ "utimes(2) error when accessing non-existent object through symbolic link is caught",
"NULL"
};
@@ -435,7 +458,10 @@
{OPEN, 0, 0, 25, creat_both, ck_both, {O_FILE, S_FILE, O_FILE}},
{OPEN, 1, EEXIST, 26, creat_symlink, ck_symlink, {O_FILE, S_FILE, O_FILE}},
{OPEN, 1, ENOENT, 27, creat_symlink, ck_symlink, {O_FILE, S_FILE, NULL}},
- {OPEN, 1, ELOOP, 28, creat_symlink, ck_symlink, {S_FILE, S_FILE, NULL}}
+ {OPEN, 1, ELOOP, 28, creat_symlink, ck_symlink, {S_FILE, S_FILE, NULL}},
+ {UTIMES, 0, 0, 31, creat_both, ck_both, {O_FILE, S_FILE, O_FILE}},
+ {UTIMES, 1, ENOENT, 32, creat_symlink, ck_symlink, {O_FILE, S_FILE, NULL}},
+ {UTIMES, 1, ELOOP, 28, creat_symlink, ck_symlink, {S_FILE, S_FILE, NULL}}
};
/*
@@ -476,6 +502,8 @@
"Rename a Symbolic Link File And Not Any Object file" },
{ OPEN, "open", 5, &test_objects[33],
"Create/Open a File For Reading Or Writing via symlink" },
+ { UTIMES, "utimes", 3, &test_objects[38],
+ "Set File Access And Modify Object File Times via symlink" },
};
/*
@@ -1024,6 +1052,8 @@
do_rename(tc_ptr);
else if (cktcsid(tc_ptr->tcid, OPEN))
do_open(tc_ptr);
+ else if (cktcsid(tc_ptr->tcid, UTIMES))
+ do_utimes(tc_ptr);
else
tst_resm(TBROK, "Unknown test case processing actions declared");
}
@@ -1185,6 +1215,18 @@
" file through a symbolic link file was not received,",
errno, strerror(errno));
}
+ else if (cktcsid(tc_ptr->tcid, UTIMES)) {
+
+ if ((utimes(tc_ptr->fn_arg[1], NULL) == -1) && (errno == ENOENT))
+ if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST )
+ tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]);
+ else
+ Tst_count++;
+ else
+ tst_resm(TFAIL, "%s %s errno:%d %s",
+ "Expected ENOENT error condition when utimes(2) a symbolic",
+ "link which pointed at no object:", errno, strerror(errno));
+ }
else
tst_resm(TBROK, "Unknown test case processing actions declared");
}
@@ -1294,6 +1336,21 @@
"Expected ELOOP error condition when open(2) a nested symbolic link:",
errno, strerror(errno));
}
+ else if (cktcsid(tc_ptr->tcid, UTIMES)) {
+
+ TEST( utimes(tc_ptr->fn_arg[1], NULL) );
+ errno=TEST_ERRNO;
+
+ if ((TEST_RETURN == -1) && (errno == ELOOP))
+ if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST )
+ tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]);
+ else
+ Tst_count++;
+ else
+ tst_resm(TFAIL, "%s errno:%d %s",
+ "Expected ELOOP error condition when utimes(2) a nested symbolic link:",
+ errno, strerror(errno));
+ }
else
tst_resm(TBROK, "Unknown test case processing actions declared");
}
@@ -1965,6 +2022,64 @@
tst_resm(TFAIL, test_msg);
}
close(fd);
+ }
+}
+
+/***********************************************************************
+ * This routine checks out the utimes(2) system call for a successful
+ * invocation
+ *
+ * Argument is pointer to test_objects array of structures of type
+ * all_test_cases
+ ***********************************************************************/
+void
+do_utimes(tc_ptr)
+struct all_test_cases *tc_ptr;
+{
+ struct timeval times[2];
+
+ if (stat(tc_ptr->fn_arg[2], &asymlink) == -1)
+ tst_resm(TBROK, "stat(2) Failure when accessing %s object file",
+ tc_ptr->fn_arg[2]);
+ else {
+ /* Now add a few values to access and modify times */
+
+ times[0].tv_sec = asymlink.st_atime + a_time_value;
+ times[0].tv_usec = asymlink.st_atim.tv_nsec / 1000;
+ times[1].tv_sec = asymlink.st_mtime + a_time_value;
+ times[1].tv_usec = asymlink.st_mtim.tv_nsec / 1000;
+
+ /* Now hand off to utimes(2) via symbolic link file*/
+
+ if (utimes(tc_ptr->fn_arg[1], times) == -1)
+ tst_resm(TFAIL, "%s %s",
+ "utimes(2) failed to process object file access and modify",
+ "time updates through symbolic link");
+ else {
+ /* Now verify changes were made */
+
+ if (stat(tc_ptr->fn_arg[2], &statter) == -1)
+ tst_resm(TBROK,
+ "stat(2) Failure when accessing %s object file",
+ tc_ptr->fn_arg[2]);
+ else {
+ time_t temp, diff;
+
+ temp = statter.st_atime - asymlink.st_atime;
+ diff = (statter.st_mtime - asymlink.st_mtime) - temp;
+
+ if (! diff)
+ if ( TEST_RESULT != TPASS || STD_FUNCTIONAL_TEST )
+ tst_resm(TEST_RESULT, msgs[tc_ptr->pass_msg]);
+ else
+ Tst_count++;
+ else
+ tst_resm(TFAIL, "%s %s %d greater than original times",
+ "utimes(2) failed to change object file access and",
+ "modify times through symbolic link to a value",
+ a_time_value);
+ }
+ }
}
}
diff -ruN ltp-full-20061121-orig/testcases/kernel/syscalls/utimes/Makefile ltp-full-20061121/testcases/kernel/syscalls/utimes/Makefile
--- ltp-full-20061121-orig/testcases/kernel/syscalls/utimes/Makefile Wed Dec 31 18:00:00 1969
+++ ltp-full-20061121/testcases/kernel/syscalls/utimes/Makefile Tue Nov 21 14:31:28 2006
@@ -0,0 +1,31 @@
+#
+# Copyright (c) International Business Machines Corp., 2001
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+# the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+CFLAGS += -I../../../../include -Wall
+LDLIBS += -L../../../../lib -lltp
+
+SRCS = $(wildcard *.c)
+TARGETS = $(patsubst %.c,%,$(SRCS))
+
+all: $(TARGETS)
+
+install:
+ @set -e; for i in $(TARGETS); do ln -f $$i ../../../bin/$$i ; done
+
+clean:
+ rm -f $(TARGETS)
diff -ruN ltp-full-20061121-orig/testcases/kernel/syscalls/utimes/utimes01.c ltp-full-20061121/testcases/kernel/syscalls/utimes/utimes01.c
--- ltp-full-20061121-orig/testcases/kernel/syscalls/utimes/utimes01.c Wed Dec 31 18:00:00 1969
+++ ltp-full-20061121/testcases/kernel/syscalls/utimes/utimes01.c Thu Dec 14 12:36:28 2006
@@ -0,0 +1,281 @@
+/*
+ *
+ * Copyright (c) International Business Machines Corp., 2001
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ * the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * Test Name: utimes01
+ *
+ * Test Description:
+ * Verify that the system call utimes() successfully sets the modification
+ * and access times of a file to the current time, if the times argument
+ * is null, and the user ID of the process is "root".
+ *
+ * Expected Result:
+ * utimes succeeds returning zero and sets the access and modification
+ * times of the file to the current time.
+ *
+ * Algorithm:
+ * Setup:
+ * Setup signal handling.
+ * Create temporary directory.
+ * Pause for SIGUSR1 if option specified.
+ *
+ * Test:
+ * Loop if the proper options are given.
+ * Execute system call
+ * Check return code, if system call failed (return=-1)
+ * Log the errno and Issue a FAIL message.
+ * Otherwise,
+ * Verify the Functionality of system call
+ * if successful,
+ * Issue Functionality-Pass message.
+ * Otherwise,
+ * Issue Functionality-Fail message.
+ * Cleanup:
+ * Print errno log and/or timing stats if options given
+ * Delete the temporary directory created.
+ *
+ * Usage: <for command-line>
+ * utimes01 [-c n] [-e] [-f] [-i n] [-I x] [-p x] [-t]
+ * where, -c n : Run n copies concurrently.
+ * -e : Turn on errno logging.
+ * -f : Turn off functionality Testing.
+ * -i n : Execute test n times.
+ * -I x : Execute test for x seconds.
+ * -P x : Pause for x seconds between iterations.
+ * -t : Turn on syscall timing.
+ *
+ * History
+ * 07/2001 John George
+ * -Ported
+ *
+ * Restrictions:
+ * This test should be run by 'super-user' (root) only.
+ *
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/time.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <signal.h>
+#include <time.h>
+
+#include "test.h"
+#include "usctest.h"
+
+#define TEMP_FILE "tmp_file"
+#define FILE_MODE S_IRUSR | S_IRGRP | S_IROTH
+
+char *TCID="utimes01"; /* Test program identifier. */
+int TST_TOTAL=1; /* Total number of test cases. */
+extern int Tst_count; /* Test Case counter for tst_* routines */
+time_t curr_time; /* current time in seconds */
+time_t tloc; /* argument var. for time() */
+int exp_enos[]={0};
+
+void setup(); /* Main setup function of test */
+void cleanup(); /* cleanup function for the test */
+
+int
+main(int ac, char **av)
+{
+ struct stat stat_buf; /* struct buffer to hold file info. */
+ int lc; /* loop counter */
+ char *msg; /* message returned from parse_opts */
+ time_t modf_time, access_time;
+ time_t pres_time; /* file modification/access/present time */
+
+ /* Parse standard options given to run the test. */
+ msg = parse_opts(ac, av, (option_t *) NULL, NULL);
+ if (msg != (char *) NULL) {
+ tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+ tst_exit();
+ }
+
+ /* Perform global setup for test */
+ setup();
+
+ /* set the expected errnos... */
+ TEST_EXP_ENOS(exp_enos);
+
+ /* Check looping state if -i option given */
+ for (lc = 0; TEST_LOOPING(lc); lc++) {
+ /* Reset Tst_count in case we are looping. */
+ Tst_count=0;
+
+ /*
+ * Invoke utimes(2) to set TEMP_FILE access and
+ * modification times to the current time.
+ */
+ TEST(utimes(TEMP_FILE, NULL));
+
+ /* check return code of utimes(2) */
+ if (TEST_RETURN == -1) {
+ TEST_ERROR_LOG(TEST_ERRNO);
+ tst_resm(TFAIL, "utimes(%s) Failed, errno=%d : %s",
+ TEMP_FILE, TEST_ERRNO, strerror(TEST_ERRNO));
+ } else {
+ /*
+ * Perform functional verification if test
+ * executed without (-f) option.
+ */
+ if (STD_FUNCTIONAL_TEST) {
+ /*
+ * Sleep for a second so that mod time and
+ * access times will be different from the
+ * current time
+ */
+ sleep(2);
+
+ /*
+ * Get the current time now, after calling
+ * utimes(2)
+ */
+ if ((pres_time = time(&tloc)) < 0) {
+ tst_brkm(TFAIL, cleanup, "time() "
+ "failed to get present time "
+ "after utimes, error=%d", errno);
+ /*NOTREACHED*/
+ }
+
+ /*
+ * Get the modification and access times of
+ * temporary file using stat(2).
+ */
+ if (stat(TEMP_FILE, &stat_buf) < 0) {
+ tst_brkm(TFAIL, cleanup, "stat(2) of "
+ "%s failed, error:%d",
+ TEMP_FILE, TEST_ERRNO);
+ /*NOTREACHED*/
+ }
+ modf_time = stat_buf.st_mtime;
+ access_time = stat_buf.st_atime;
+
+ /* Now do the actual verification */
+ if (modf_time <= curr_time || \
+ modf_time >= pres_time || \
+ access_time <= curr_time || \
+ access_time >= pres_time) {
+ tst_resm(TFAIL, "%s access and "
+ "modification times not set",
+ TEMP_FILE);
+ } else {
+ tst_resm(TPASS, "Functionality of "
+ "utimes(%s, NULL) successful",
+ TEMP_FILE);
+ }
+ } else {
+ tst_resm(TPASS, "%s call succeeded", TCID);
+ }
+ }
+ Tst_count++;
+ } /* End for TEST_LOOPING */
+
+ /* Call cleanup() to undo setup done for the test. */
+ cleanup();
+ /*NOTREACHED*/
+
+
+ return(0);
+
+} /* End main */
+
+/*
+ * void
+ * setup() - performs all ONE TIME setup for this test.
+ * Create a temporary directory and change directory to it.
+ * Create a test file under temporary directory and close it
+ */
+void
+setup()
+{
+ int fildes; /* file handle for temp file */
+
+ /* capture signals */
+ tst_sig(FORK, DEF_HANDLER, cleanup);
+
+ /* Check that the test process id is super/root */
+ if (geteuid() != 0) {
+ tst_brkm(TBROK, NULL, "Must be super/root for this test!");
+ tst_exit();
+ }
+
+ /* Pause if that option was specified */
+ TEST_PAUSE;
+
+ /* make a temp directory and cd to it */
+ tst_tmpdir();
+
+ /* Creat a temporary file under above directory */
+ if ((fildes = creat(TEMP_FILE, FILE_MODE)) == -1) {
+ tst_brkm(TBROK, cleanup,
+ "creat(%s, %#o) Failed, errno=%d :%s",
+ TEMP_FILE, FILE_MODE, errno, strerror(errno));
+ /*NOTREACHED*/
+ }
+
+ /* Close the temporary file created */
+ if (close(fildes) < 0) {
+ tst_brkm(TBROK, cleanup,
+ "close(%s) Failed, errno=%d : %s:",
+ TEMP_FILE, errno, strerror(errno));
+ /*NOTREACHED*/
+ }
+
+ /* Get the current time */
+ if ((curr_time = time(&tloc)) < 0) {
+ tst_brkm(TBROK, cleanup,
+ "time() failed to get current time, errno=%d",
+ errno);
+ /*NOTREACHED*/
+ }
+
+ /*
+ * Sleep for a second so that mod time and access times will be
+ * different from the current time
+ */
+ sleep(2); /* sleep(1) on IA64 sometimes sleeps < 1 sec!! */
+
+} /* End setup() */
+
+/*
+ * void
+ * cleanup() - performs all ONE TIME cleanup for this test at
+ * completion or premature exit.
+ * Remove the test directory and testfile created in the setup.
+ */
+void
+cleanup()
+{
+ /*
+ * print timing stats if that option was specified.
+ * print errno log if that option was specified.
+ */
+ TEST_CLEANUP;
+
+ /* Remove tmp dir and all files in it */
+ tst_rmdir();
+
+ /* exit with return code appropriate for results */
+ tst_exit();
+} /* End cleanup() */
diff -ruN ltp-full-20061121-orig/testcases/kernel/syscalls/utimes/utimes02.c ltp-full-20061121/testcases/kernel/syscalls/utimes/utimes02.c
--- ltp-full-20061121-orig/testcases/kernel/syscalls/utimes/utimes02.c Wed Dec 31 18:00:00 1969
+++ ltp-full-20061121/testcases/kernel/syscalls/utimes/utimes02.c Thu Dec 14 12:36:14 2006
@@ -0,0 +1,299 @@
+/*
+ *
+ * Copyright (c) International Business Machines Corp., 2001
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ * the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * Test Name: utimes02
+ *
+ * Test Description:
+ * Verify that the system call utimes() successfully sets the modification
+ * and access times of a file to the current time, under the following
+ * constraints,
+ * - The times argument is null.
+ * - The user ID of the process is not "root".
+ * - The file is owned by the user ID of the process.
+ *
+ * Expected Result:
+ * utimes succeeds returning zero and sets the access and modification
+ * times of the file to the current time.
+ *
+ * Algorithm:
+ * Setup:
+ * Setup signal handling.
+ * Create temporary directory.
+ * Pause for SIGUSR1 if option specified.
+ *
+ * Test:
+ * Loop if the proper options are given.
+ * Execute system call
+ * Check return code, if system call failed (return=-1)
+ * Log the errno and Issue a FAIL message.
+ * Otherwise,
+ * Verify the Functionality of system call
+ * if successful,
+ * Issue Functionality-Pass message.
+ * Otherwise,
+ * Issue Functionality-Fail message.
+ * Cleanup:
+ * Print errno log and/or timing stats if options given
+ * Delete the temporary directory created.
+ *
+ * Usage: <for command-line>
+ * utimes02 [-c n] [-e] [-f] [-i n] [-I x] [-p x] [-t]
+ * where, -c n : Run n copies concurrently.
+ * -e : Turn on errno logging.
+ * -f : Turn off functionality Testing.
+ * -i n : Execute test n times.
+ * -I x : Execute test for x seconds.
+ * -P x : Pause for x seconds between iterations.
+ * -t : Turn on syscall timing.
+ *
+ * History
+ * 07/2001 John George
+ * -Ported
+ *
+ * Restrictions:
+ *
+ */
+
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/time.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <signal.h>
+#include <pwd.h>
+#include <time.h>
+
+#include "test.h"
+#include "usctest.h"
+
+#define TEMP_FILE "tmp_file"
+#define FILE_MODE S_IRUSR | S_IRGRP | S_IROTH
+
+char *TCID="utimes02"; /* Test program identifier. */
+int TST_TOTAL=1; /* Total number of test cases. */
+extern int Tst_count; /* Test Case counter for tst_* routines */
+time_t curr_time; /* current time in seconds */
+time_t tloc; /* argument var. for time() */
+int exp_enos[]={0};
+char nobody_uid[] = "nobody";
+struct passwd *ltpuser;
+
+
+void setup(); /* Main setup function of test */
+void cleanup(); /* cleanup function for the test */
+
+int
+main(int ac, char **av)
+{
+ struct stat stat_buf; /* struct buffer to hold file info. */
+ int lc; /* loop counter */
+ char *msg; /* message returned from parse_opts */
+ time_t modf_time, access_time;
+ time_t pres_time; /* file modification/access/present time */
+
+ /* Parse standard options given to run the test. */
+ msg = parse_opts(ac, av, (option_t *) NULL, NULL);
+ if (msg != (char *) NULL) {
+ tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+ tst_exit();
+ }
+
+ /* Perform global setup for test */
+ setup();
+
+ /* set the expected errnos... */
+ TEST_EXP_ENOS(exp_enos);
+
+ /* Check looping state if -i option given */
+ for (lc = 0; TEST_LOOPING(lc); lc++) {
+ /* Reset Tst_count in case we are looping. */
+ Tst_count=0;
+
+ /*
+ * Invoke utimes(2) to set TEMP_FILE access and
+ * modification times to the current time.
+ */
+ TEST(utimes(TEMP_FILE, NULL));
+
+ /* check return code of utimes(2) */
+ if (TEST_RETURN == -1) {
+ TEST_ERROR_LOG(TEST_ERRNO);
+ tst_resm(TFAIL, "utimes(%s) Failed, errno=%d : %s",
+ TEMP_FILE, TEST_ERRNO, strerror(TEST_ERRNO));
+ } else {
+ /*
+ * Perform functional verification if test
+ * executed without (-f) option.
+ */
+ if (STD_FUNCTIONAL_TEST) {
+ /*
+ * Sleep for a second so that mod time and
+ * access times will be different from the
+ * current time
+ */
+ sleep(2);
+
+ /*
+ * Get the current time now, after calling
+ * utimes(2)
+ */
+ if ((pres_time = time(&tloc)) < 0) {
+ tst_brkm(TFAIL, cleanup, "time() "
+ "failed to get present time "
+ "after utimes, error=%d",
+ errno);
+ /*NOTREACHED*/
+ }
+
+ /*
+ * Get the modification and access times of
+ * temporary file using stat(2).
+ */
+ if (stat(TEMP_FILE, &stat_buf) < 0) {
+ tst_brkm(TFAIL, cleanup, "stat(2) of "
+ "%s failed, errno:%d",
+ TEMP_FILE, TEST_ERRNO);
+ /*NOTREACHED*/
+ }
+ modf_time = stat_buf.st_mtime;
+ access_time = stat_buf.st_atime;
+
+ /* Now do the actual verification */
+ if (modf_time <= curr_time || \
+ modf_time >= pres_time || \
+ access_time <= curr_time || \
+ access_time >= pres_time) {
+ tst_resm(TFAIL, "%s access and "
+ "modification times not set",
+ TEMP_FILE);
+ } else {
+ tst_resm(TPASS, "Functionality of "
+ "utimes(%s, NULL) successful",
+ TEMP_FILE);
+ }
+ } else {
+ tst_resm(TPASS, "%s call succeeded", TCID);
+ }
+ }
+ Tst_count++;
+ } /* End for TEST_LOOPING */
+
+ /* Call cleanup() to undo setup done for the test. */
+ cleanup();
+ /*NOTREACHED*/
+
+
+ return(0);
+
+} /* End main */
+
+/*
+ * void
+ * setup() - performs all ONE TIME setup for this test.
+ * Create a temporary directory and change directory to it.
+ * Create a test file under temporary directory and close it
+ */
+void
+setup()
+{
+ int fildes; /* file handle for temp file */
+
+ /* capture signals */
+ tst_sig(FORK, DEF_HANDLER, cleanup);
+
+ /* Switch to nobody user for correct error code collection */
+ if (geteuid() != 0) {
+ tst_brkm(TBROK, tst_exit, "Test must be run as root");
+ }
+ ltpuser = getpwnam(nobody_uid);
+ if (setuid(ltpuser->pw_uid) == -1) {
+ tst_resm(TINFO, "setuid failed to "
+ "to set the effective uid to %d",
+ ltpuser->pw_uid);
+ perror("setuid");
+ }
+
+
+ /* Pause if that option was specified
+ * TEST_PAUSE contains the code to fork the test with the -i option.
+ * You want to make sure you do this before you create your temporary
+ * directory.
+ */
+ TEST_PAUSE;
+
+ /* make a temp directory and cd to it */
+ tst_tmpdir();
+
+ /* Creat a temporary file under above directory */
+ if ((fildes = creat(TEMP_FILE, FILE_MODE)) == -1) {
+ tst_brkm(TBROK, cleanup,
+ "creat(%s, %#o) Failed, errno=%d :%s",
+ TEMP_FILE, FILE_MODE, errno, strerror(errno));
+ /*NOTREACHED*/
+ }
+
+ /* Close the temporary file created */
+ if (close(fildes) < 0) {
+ tst_brkm(TBROK, cleanup,
+ "close(%s) Failed, errno=%d : %s:",
+ TEMP_FILE, errno, strerror(errno));
+ /*NOTREACHED*/
+ }
+
+ /* Get the current time */
+ if ((curr_time = time(&tloc)) < 0) {
+ tst_brkm(TBROK, cleanup,
+ "time() failed to get current time, errno=%d",
+ errno);
+ /*NOTREACHED*/
+ }
+
+ /*
+ * Sleep for a second so that mod time and access times will be
+ * different from the current time
+ */
+ sleep(2); /* sleep(1) on IA64 sometimes sleeps < 1 sec!! */
+
+} /* End setup() */
+
+/*
+ * void
+ * cleanup() - performs all ONE TIME cleanup for this test at
+ * completion or premature exit.
+ * Remove the test directory and testfile created in the setup.
+ */
+void
+cleanup()
+{
+ /*
+ * print timing stats if that option was specified.
+ * print errno log if that option was specified.
+ */
+ TEST_CLEANUP;
+
+ /* Remove tmp dir and all files in it */
+ tst_rmdir();
+
+ /* exit with return code appropriate for results */
+ tst_exit();
+} /* End cleanup() */
diff -ruN ltp-full-20061121-orig/testcases/kernel/syscalls/utimes/utimes03.c ltp-full-20061121/testcases/kernel/syscalls/utimes/utimes03.c
--- ltp-full-20061121-orig/testcases/kernel/syscalls/utimes/utimes03.c Wed Dec 31 18:00:00 1969
+++ ltp-full-20061121/testcases/kernel/syscalls/utimes/utimes03.c Thu Dec 14 12:35:59 2006
@@ -0,0 +1,376 @@
+/*
+ *
+ * Copyright (c) International Business Machines Corp., 2001
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ * the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * Test Name: utimes03
+ *
+ * Test Description:
+ * Verify that the system call utimes() successfully sets the modification
+ * and access times of a file to the current time, under the following
+ * constraints,
+ * - The times argument is null.
+ * - The user ID of the process is not "root".
+ * - The file is not owned by the user ID of the process.
+ * - The user ID of the process has write access to the file.
+ *
+ * Expected Result:
+ * utimes succeeds returning zero and sets the access and modificatio
+ * times of the file to the current time.
+ *
+ * Algorithm:
+ * Setup:
+ * Setup signal handling.
+ * Create temporary directory.
+ * Pause for SIGUSR1 if option specified.
+ *
+ * Test:
+ * Loop if the proper options are given.
+ * Execute system call
+ * Check return code, if system call failed (return=-1)
+ * Log the errno and Issue a FAIL message.
+ * Otherwise,
+ * Verify the Functionality of system call
+ * if successful,
+ * Issue Functionality-Pass message.
+ * Otherwise,
+ * Issue Functionality-Fail message.
+ * Cleanup:
+ * Print errno log and/or timing stats if options given
+ * Delete the temporary directory created.
+ *
+ * Usage: <for command-line>
+ * utimes03 [-c n] [-e] [-f] [-i n] [-I x] [-p x] [-t]
+ * where, -c n : Run n copies concurrently.
+ * -e : Turn on errno logging.
+ * -f : Turn off functionality Testing.
+ * -i n : Execute test n times.
+ * -I x : Execute test for x seconds.
+ * -P x : Pause for x seconds between iterations.
+ * -t : Turn on syscall timing.
+ *
+ * History
+ * 07/2001 John George
+ * -Ported
+ *
+ * Restrictions:
+ * This test should be run by root only.
+ * nobody and bin must be valid users.
+ *
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <pwd.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <wait.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <time.h>
+
+#include "test.h"
+#include "usctest.h"
+
+#define TEMP_FILE "tmp_file"
+#define FILE_MODE S_IRWXU | S_IRGRP | S_IWGRP| S_IROTH | S_IWOTH
+#define LTPUSER1 "nobody"
+#define LTPUSER2 "bin"
+
+char *TCID="utimes03"; /* Test program identifier. */
+int TST_TOTAL=1; /* Total number of test cases. */
+extern int Tst_count; /* Test Case counter for tst_* routines */
+time_t curr_time; /* current time in seconds */
+time_t tloc; /* argument var. for time() */
+int exp_enos[]={0};
+
+struct passwd *ltpuser; /* password struct for ltpusers */
+uid_t user_uid; /* user id of ltpuser */
+gid_t group_gid; /* group id of ltpuser */
+int status;
+
+void setup(); /* Main setup function of test */
+void cleanup(); /* cleanup function for the test */
+
+int
+main(int ac, char **av)
+{
+ struct stat stat_buf; /* struct buffer to hold file info. */
+ int lc; /* loop counter */
+ char *msg; /* message returned from parse_opts */
+ time_t modf_time, access_time;
+ time_t pres_time; /* file modification/access/present time */
+ pid_t pid;
+
+ /* Parse standard options given to run the test. */
+ msg = parse_opts(ac, av, (option_t *) NULL, NULL);
+ if (msg != (char *) NULL) {
+ tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+ tst_exit();
+ }
+
+ /* Perform global setup for test */
+ setup();
+
+ /* set the expected errnos... */
+ TEST_EXP_ENOS(exp_enos);
+
+ pid = FORK_OR_VFORK();
+
+ if (pid == -1) {
+ tst_brkm(TBROK, cleanup, "fork() failed");
+ } else if (pid == 0) {
+ if ((ltpuser = getpwnam(LTPUSER1)) == NULL) {
+ tst_brkm(TBROK,cleanup,"%s not found in /etc/passwd",
+ LTPUSER1);
+ }
+
+ /* get uid/gid of user accordingly */
+ user_uid = ltpuser->pw_uid;
+
+ seteuid(user_uid);
+
+ /* Check looping state if -i option given */
+ for (lc = 0; TEST_LOOPING(lc); lc++) {
+ /* Reset Tst_count in case we are looping. */
+ Tst_count=0;
+
+ /*
+ * Invoke utimes(2) to set TEMP_FILE access and
+ * modification times to the current time.
+ */
+ TEST(utimes(TEMP_FILE, NULL));
+
+ /* check return code of utimes(2) */
+ if (TEST_RETURN == -1) {
+ TEST_ERROR_LOG(TEST_ERRNO);
+ tst_resm(TFAIL,
+ "utimes(%s) Failed, errno=%d : %s",
+ TEMP_FILE, TEST_ERRNO,
+ strerror(TEST_ERRNO));
+ } else {
+ /*
+ * Perform functional verification if test
+ * executed without (-f) option.
+ */
+ if (STD_FUNCTIONAL_TEST) {
+ /*
+ * Sleep for a second so that mod time
+ * and access times will be different
+ * from the current time.
+ */
+ sleep(2);
+
+ /*
+ * Get the current time now, after
+ * calling utimes(2)
+ */
+ if ((pres_time = time(&tloc)) < 0) {
+ tst_brkm(TFAIL, cleanup,
+ "time() failed to get "
+ "present time after "
+ "utimes, error=%d",
+ errno);
+ /*NOTREACHED*/
+ }
+
+ /*
+ * Get the modification and access
+ * times of temporary file using
+ * stat(2).
+ */
+ if (stat(TEMP_FILE, &stat_buf) < 0) {
+ tst_brkm(TFAIL, cleanup,
+ "stat(2) of %s failed, "
+ "error:%d", TEMP_FILE,
+ TEST_ERRNO);
+ /*NOTREACHED*/
+ }
+ modf_time = stat_buf.st_mtime;
+ access_time = stat_buf.st_atime;
+
+ /* Now do the actual verification */
+ if (modf_time <= curr_time || \
+ modf_time >= pres_time || \
+ access_time <= curr_time || \
+ access_time >= pres_time) {
+ tst_resm(TFAIL, "%s access and "
+ "modification times "
+ "not set", TEMP_FILE);
+ } else {
+ tst_resm(TPASS, "Functionality "
+ "of utimes(%s, NULL) "
+ "successful",
+ TEMP_FILE);
+ }
+ } else {
+ tst_resm(TPASS, "%s call succeeded",
+ TCID);
+ }
+ }
+ Tst_count++; /* incr. TEST_LOOP counter */
+ } /* End for TEST_LOOPING */
+ } else {
+ waitpid(pid, &status, 0);
+ _exit(0); /*
+ * Exit here and let the child clean up.
+ * This allows the errno information set
+ * by the TEST_ERROR_LOG macro and the
+ * PASS/FAIL status to be preserved for
+ * use during cleanup.
+ */
+ }
+ /* Call cleanup() to undo setup done for the test. */
+ cleanup();
+ /*NOTREACHED*/
+
+
+ return(0);
+
+} /* End main */
+
+/*
+ * void
+ * setup() - performs all ONE TIME setup for this test.
+ * Create a temporary directory and change directory to it.
+ * Create a test file under temporary directory and close it
+ * Change the ownership of testfile to that of "bin" user.
+ * Record the current time.
+ */
+void
+setup()
+{
+ int fildes; /* file handle for temp file */
+ char *tmpd = NULL;
+
+ /* capture signals */
+ tst_sig(FORK, DEF_HANDLER, cleanup);
+
+ /* Check that the test process id is not super/root */
+ if (geteuid() != 0) {
+ tst_brkm(TBROK, NULL, "Must be root for this test!");
+ tst_exit();
+ }
+
+ /* Pause if that option was specified
+ * TEST_PAUSE contains the code to fork the test with the -i option.
+ * You want to make sure you do this before you create your temporary
+ * directory.
+ */
+ TEST_PAUSE;
+
+ /* make a temp directory and cd to it */
+ tst_tmpdir();
+
+ /* get the name of the temporary directory */
+ if ((tmpd = getcwd(tmpd, 0)) == NULL) {
+ tst_brkm(TBROK, tst_exit, "getcwd failed");
+ }
+
+ /* Creat a temporary file under above directory */
+ if ((fildes = creat(TEMP_FILE, FILE_MODE)) == -1) {
+ tst_brkm(TBROK, cleanup,
+ "creat(%s, %#o) Failed, errno=%d :%s",
+ TEMP_FILE, FILE_MODE, errno, strerror(errno));
+ /*NOTREACHED*/
+ }
+
+ /* Close the temporary file created */
+ if (close(fildes) < 0) {
+ tst_brkm(TBROK, cleanup,
+ "close(%s) Failed, errno=%d : %s:",
+ TEMP_FILE, errno, strerror(errno));
+ /*NOTREACHED*/
+ }
+
+ /*
+ * Make sure that specified Mode permissions set as
+ * umask value may be different.
+ */
+ if (chmod(TEMP_FILE, FILE_MODE) < 0) {
+ tst_brkm(TBROK, cleanup,
+ "chmod(%s) Failed, errno=%d : %s:",
+ TEMP_FILE, errno, strerror(errno));
+ /*NOTREACHED*/
+ }
+
+ if (chmod(tmpd, 0711) != 0) {
+ tst_brkm(TBROK, cleanup, "chmod() failed");
+ }
+
+ if ((ltpuser = getpwnam(LTPUSER2)) == NULL) {
+ tst_brkm(TBROK, cleanup, "%s not found in /etc/passwd",
+ LTPUSER2);
+ /*NOTREACHED*/
+ }
+
+ /* get uid/gid of user accordingly */
+ user_uid = ltpuser->pw_uid;
+ group_gid = ltpuser->pw_gid;
+
+ /*
+ * Change the ownership of test directory/file specified by
+ * pathname to that of user_uid and group_gid.
+ */
+ if (chown(TEMP_FILE, user_uid, group_gid) < 0) {
+ tst_brkm(TBROK, cleanup, "chown() of %s failed, error %d",
+ TEMP_FILE, errno);
+ /*NOTREACHED*/
+ }
+
+ /* Get the current time */
+ if ((curr_time = time(&tloc)) < 0) {
+ tst_brkm(TBROK, cleanup,
+ "time() failed to get current time, errno=%d", errno);
+ /*NOTREACHED*/
+ }
+
+ /*
+ * Sleep for a second so that mod time and access times will be
+ * different from the current time
+ */
+ sleep(2); /* sleep(1) on IA64 sometimes sleeps < 1 sec!! */
+
+} /* End setup() */
+
+/*
+ * void
+ * cleanup() - performs all ONE TIME cleanup for this test at
+ * completion or premature exit.
+ * Remove the test directory and testfile created in the setup.
+ */
+void
+cleanup()
+{
+ seteuid(0);
+ /*
+ * print timing stats if that option was specified.
+ * print errno log if that option was specified.
+ */
+ TEST_CLEANUP;
+
+ /* Remove tmp dir and all files in it */
+ tst_rmdir();
+
+ /* exit with return code appropriate for results */
+ tst_exit();
+} /* End cleanup() */
diff -ruN ltp-full-20061121-orig/testcases/kernel/syscalls/utimes/utimes04.c ltp-full-20061121/testcases/kernel/syscalls/utimes/utimes04.c
--- ltp-full-20061121-orig/testcases/kernel/syscalls/utimes/utimes04.c Wed Dec 31 18:00:00 1969
+++ ltp-full-20061121/testcases/kernel/syscalls/utimes/utimes04.c Thu Dec 14 20:16:40 2006
@@ -0,0 +1,261 @@
+/*
+ *
+ * Copyright (c) International Business Machines Corp., 2001
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ * the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * Test Name: utimes04
+ *
+ * Test Description:
+ * Verify that the system call utimes() successfully sets the modification
+ * and access times of a file to the time specified by times argument, if
+ * the times argument is not null, and the user ID of the process is "root".
+ *
+ * Expected Result:
+ * utimes succeeds returning zero and sets the access and modification
+ * times of the file to that specified by the times argument.
+ *
+ * Algorithm:
+ * Setup:
+ * Setup signal handling.
+ * Create temporary directory.
+ * Pause for SIGUSR1 if option specified.
+ *
+ * Test:
+ * Loop if the proper options are given.
+ * Execute system call
+ * Check return code, if system call failed (return=-1)
+ * Log the errno and Issue a FAIL message.
+ * Otherwise,
+ * Verify the Functionality of system call
+ * if successful,
+ * Issue Functionality-Pass message.
+ * Otherwise,
+ * Issue Functionality-Fail message.
+ * Cleanup:
+ * Print errno log and/or timing stats if options given
+ * Delete the temporary directory created.
+ *
+ * Usage: <for command-line>
+ * utimes04 [-c n] [-e] [-f] [-i n] [-I x] [-p x] [-t]
+ * where, -c n : Run n copies concurrently.
+ * -e : Turn on errno logging.
+ * -f : Turn off functionality Testing.
+ * -i n : Execute test n times.
+ * -I x : Execute test for x seconds.
+ * -P x : Pause for x seconds between iterations.
+ * -t : Turn on syscall timing.
+ *
+ * History
+ * 07/2001 John George
+ * -Ported
+ *
+ * Restrictions:
+ * This test should be run by 'super-user' (root) only.
+ *
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/time.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <signal.h>
+
+#include "test.h"
+#include "usctest.h"
+
+#define TEMP_FILE "tmp_file"
+#define FILE_MODE S_IRUSR | S_IRGRP | S_IROTH
+#define NEW_TIME 10000
+#define NEW_TIME_USEC 100
+
+char *TCID="utimes04"; /* Test program identifier. */
+int TST_TOTAL=1; /* Total number of test cases. */
+extern int Tst_count; /* Test Case counter for tst_* routines */
+int exp_enos[]={0};
+struct timeval times[2]; /* struct. buffer for utimes() */
+
+void setup(); /* Main setup function of test */
+void cleanup(); /* cleanup function for the test */
+
+int
+main(int ac, char **av)
+{
+ struct stat stat_buf; /* struct buffer to hold file info. */
+ int lc; /* loop counter */
+ char *msg; /* message returned from parse_opts */
+ time_t modf_time, access_time;
+ long modf_time_usec, access_time_usec;
+ /* file modification/access time */
+
+ /* Parse standard options given to run the test. */
+ msg = parse_opts(ac, av, (option_t *) NULL, NULL);
+ if (msg != (char *) NULL) {
+ tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+ tst_exit();
+ }
+
+ /* Perform global setup for test */
+ setup();
+
+ /* set the expected errnos... */
+ TEST_EXP_ENOS(exp_enos);
+
+ /* Check looping state if -i option given */
+ for (lc = 0; TEST_LOOPING(lc); lc++) {
+ /* Reset Tst_count in case we are looping. */
+ Tst_count=0;
+
+ /*
+ * Invoke utimes(2) to set TEMP_FILE access and
+ * modification times to that specified by
+ * times argument.
+ */
+ TEST(utimes(TEMP_FILE, times));
+
+ /* check return code of utimes(2) */
+ if (TEST_RETURN == -1) {
+ TEST_ERROR_LOG(TEST_ERRNO);
+ tst_resm(TFAIL, "utimes(%s) Failed, errno=%d : %s",
+ TEMP_FILE, TEST_ERRNO, strerror(TEST_ERRNO));
+ } else {
+ /*
+ * Perform functional verification if test
+ * executed without (-f) option.
+ */
+ if (STD_FUNCTIONAL_TEST) {
+ /*
+ * Get the modification and access times of
+ * temporary file using stat(2).
+ */
+ if (stat(TEMP_FILE, &stat_buf) < 0) {
+ tst_brkm(TFAIL, cleanup,
+ "stat(2) of %s failed, "
+ "error:%d", TEMP_FILE,
+ TEST_ERRNO);
+ /*NOTREACHED*/
+ }
+ modf_time = stat_buf.st_mtime;
+ modf_time_usec = stat_buf.st_mtim.tv_nsec / 1000;
+ access_time = stat_buf.st_atime;
+ access_time_usec = stat_buf.st_atim.tv_nsec / 1000;
+
+ /* Now do the actual verification */
+ if ((modf_time != NEW_TIME) || \
+ (access_time != NEW_TIME)) {
+ tst_resm(TFAIL, "%s access and "
+ "modification times not set",
+ TEMP_FILE);
+ } else if ((modf_time_usec != NEW_TIME_USEC) || \
+ (access_time_usec != NEW_TIME_USEC)) {
+ tst_resm(TFAIL, "%s access and "
+ "modification times usec not set",
+ TEMP_FILE);
+ } else {
+ tst_resm(TPASS, "Functionality of "
+ "utimes(%s, times) successful",
+ TEMP_FILE);
+ }
+ } else {
+ tst_resm(TPASS, "%s call succeeded", TCID);
+ }
+ }
+ Tst_count++; /* incr TEST_LOOP counter */
+ } /* End for TEST_LOOPING */
+
+ /* Call cleanup() to undo setup done for the test. */
+ cleanup();
+ /*NOTREACHED*/
+
+
+ return(0);
+
+} /* End main */
+
+/*
+ * void
+ * setup() - performs all ONE TIME setup for this test.
+ * Create a temporary directory and change directory to it.
+ * Create a test file under temporary directory and close it
+ */
+void
+setup()
+{
+ int fildes; /* file handle for temp file */
+
+ /* capture signals */
+ tst_sig(NOFORK, DEF_HANDLER, cleanup);
+
+ /* Check that the test process id is super/root */
+ if (geteuid() != 0) {
+ tst_brkm(TBROK, NULL, "Must be super/root for this test!");
+ tst_exit();
+ }
+
+ /* Pause if that option was specified */
+ TEST_PAUSE;
+
+ /* make a temp directory and cd to it */
+ tst_tmpdir();
+
+ /* Creat a temporary file under above directory */
+ if ((fildes = creat(TEMP_FILE, FILE_MODE)) == -1) {
+ tst_brkm(TBROK, cleanup,
+ "creat(%s, %#o) Failed, errno=%d :%s",
+ TEMP_FILE, FILE_MODE, errno, strerror(errno));
+ }
+
+ /* Close the temporary file created */
+ if (close(fildes) < 0) {
+ tst_brkm(TBROK, cleanup,
+ "close(%s) Failed, errno=%d : %s:",
+ TEMP_FILE, errno, strerror(errno));
+ }
+
+ /* Initialize the modification and access time in the times arg */
+ times[0].tv_sec = NEW_TIME;
+ times[0].tv_usec = NEW_TIME_USEC;
+ times[1].tv_sec = NEW_TIME;
+ times[1].tv_usec = NEW_TIME_USEC;
+
+} /* End setup() */
+
+/*
+ * void
+ * cleanup() - performs all ONE TIME cleanup for this test at
+ * completion or premature exit.
+ * Remove the test directory and testfile created in the setup.
+ */
+void
+cleanup()
+{
+ /*
+ * print timing stats if that option was specified.
+ * print errno log if that option was specified.
+ */
+ TEST_CLEANUP;
+
+ /* Remove tmp dir and all files in it */
+ tst_rmdir();
+
+ /* exit with return code appropriate for results */
+ tst_exit();
+} /* End cleanup() */
diff -ruN ltp-full-20061121-orig/testcases/kernel/syscalls/utimes/utimes05.c ltp-full-20061121/testcases/kernel/syscalls/utimes/utimes05.c
--- ltp-full-20061121-orig/testcases/kernel/syscalls/utimes/utimes05.c Wed Dec 31 18:00:00 1969
+++ ltp-full-20061121/testcases/kernel/syscalls/utimes/utimes05.c Thu Dec 14 20:18:02 2006
@@ -0,0 +1,274 @@
+/*
+ *
+ * Copyright (c) International Business Machines Corp., 2001
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ * the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * Test Name: utimes05
+ *
+ * Test Description:
+ * Verify that the system call utimes() successfully sets the modification
+ * and access times of a file to the value specified by the times argument
+ * under the following constraints,
+ * - The times argument is not null,
+ * - The user ID of the process is not "root".
+ * - The file is owned by the user ID of the process.
+ *
+ * Expected Result:
+ * utimes succeeds returning zero and sets the access and modification
+ * times of the file to that specified by the times argument.
+ *
+ * Algorithm:
+ * Setup:
+ * Setup signal handling.
+ * Create temporary directory.
+ * Pause for SIGUSR1 if option specified.
+ *
+ * Test:
+ * Loop if the proper options are given.
+ * Execute system call
+ * Check return code, if system call failed (return=-1)
+ * Log the errno and Issue a FAIL message.
+ * Otherwise,
+ * Verify the Functionality of system call
+ * if successful,
+ * Issue Functionality-Pass message.
+ * Otherwise,
+ * Issue Functionality-Fail message.
+ * Cleanup:
+ * Print errno log and/or timing stats if options given
+ * Delete the temporary directory created.
+ *
+ * Usage: <for command-line>
+ * utimes05 [-c n] [-e] [-f] [-i n] [-I x] [-p x] [-t]
+ * where, -c n : Run n copies concurrently.
+ * -e : Turn on errno logging.
+ * -f : Turn off functionality Testing.
+ * -i n : Execute test n times.
+ * -I x : Execute test for x seconds.
+ * -P x : Pause for x seconds between iterations.
+ * -t : Turn on syscall timing.
+ *
+ * History
+ * 07/2001 John George
+ * -Ported
+ *
+ * Restrictions:
+ *
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/time.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <signal.h>
+#include <pwd.h>
+
+#include "test.h"
+#include "usctest.h"
+
+#define TEMP_FILE "tmp_file"
+#define FILE_MODE S_IRUSR | S_IRGRP | S_IROTH
+#define NEW_TIME 10000
+#define NEW_TIME_USEC 100
+
+char *TCID="utimes05"; /* Test program identifier. */
+int TST_TOTAL=1; /* Total number of test cases. */
+extern int Tst_count; /* Test Case counter for tst_* routines */
+int exp_enos[]={0};
+char nobody_uid[] = "nobody";
+struct passwd *ltpuser;
+
+
+struct timeval times[2]; /* struct. buffer for utimes() */
+
+void setup(); /* Main setup function of test */
+void cleanup(); /* cleanup function for the test */
+
+int
+main(int ac, char **av)
+{
+ struct stat stat_buf; /* struct buffer to hold file info. */
+ int lc; /* loop counter */
+ char *msg; /* message returned from parse_opts */
+ time_t modf_time, access_time;
+ long modf_time_usec, access_time_usec;
+ /* file modification/access time */
+
+ /* Parse standard options given to run the test. */
+ msg = parse_opts(ac, av, (option_t *) NULL, NULL);
+ if (msg != (char *) NULL) {
+ tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+ tst_exit();
+ }
+
+ /* Perform global setup for test */
+ setup();
+
+ /* set the expected errnos... */
+ TEST_EXP_ENOS(exp_enos);
+
+ /* Check looping state if -i option given */
+ for (lc = 0; TEST_LOOPING(lc); lc++) {
+ /* Reset Tst_count in case we are looping. */
+ Tst_count=0;
+
+ /*
+ * Invoke utimes(2) to set TEMP_FILE access and
+ * modification times to that specified by
+ * times argument.
+ */
+ TEST(utimes(TEMP_FILE, times));
+
+ /* check return code of utimes(2) */
+ if (TEST_RETURN == -1) {
+ TEST_ERROR_LOG(TEST_ERRNO);
+ tst_resm(TFAIL, "utimes(%s) Failed, errno=%d : %s",
+ TEMP_FILE, TEST_ERRNO, strerror(TEST_ERRNO));
+ } else {
+ /*
+ * Perform functional verification if test
+ * executed without (-f) option.
+ */
+ if (STD_FUNCTIONAL_TEST) {
+ /*
+ * Get the modification and access times of
+ * temporary file using stat(2).
+ */
+ if (stat(TEMP_FILE, &stat_buf) < 0) {
+ tst_brkm(TFAIL, cleanup, "stat(2) of "
+ "%s failed, error:%d",
+ TEMP_FILE, TEST_ERRNO);
+ /*NOTREACHED*/
+ }
+ modf_time = stat_buf.st_mtime;
+ modf_time_usec = stat_buf.st_mtim.tv_nsec / 1000;
+ access_time = stat_buf.st_atime;
+ access_time_usec = stat_buf.st_atim.tv_nsec / 1000;
+
+ /* Now do the actual verification */
+ if ((modf_time != NEW_TIME) || \
+ (access_time != NEW_TIME)) {
+ tst_resm(TFAIL, "%s access and "
+ "modification times not set",
+ TEMP_FILE);
+ } else if ((modf_time_usec != NEW_TIME_USEC) || \
+ (access_time_usec != NEW_TIME_USEC)) {
+ tst_resm(TFAIL, "%s access and "
+ "modification times usec not set",
+ TEMP_FILE);
+ } else {
+ tst_resm(TPASS, "Functionality of "
+ "utimes(%s, times) successful",
+ TEMP_FILE);
+ }
+ } else {
+ tst_resm(TPASS, "%s call succeeded", TCID);
+ }
+ }
+ Tst_count++; /* incr TEST_LOOP counter */
+ } /* End for TEST_LOOPING */
+
+ /* Call cleanup() to undo setup done for the test. */
+ cleanup();
+ /*NOTREACHED*/
+
+
+ return(0);
+
+} /* End main */
+
+/*
+ * void
+ * setup() - performs all ONE TIME setup for this test.
+ * Create a temporary directory and change directory to it.
+ * Create a test file under temporary directory and close it
+ */
+void
+setup()
+{
+ int fildes; /* file handle for temp file */
+
+ /* capture signals */
+ tst_sig(FORK, DEF_HANDLER, cleanup);
+
+ /* Switch to nobody user for correct error code collection */
+ if (geteuid() != 0) {
+ tst_brkm(TBROK, tst_exit, "Test must be run as root");
+ }
+ ltpuser = getpwnam(nobody_uid);
+ if (setuid(ltpuser->pw_uid) == -1) {
+ tst_resm(TINFO, "setuid failed to "
+ "to set the effective uid to %d",
+ ltpuser->pw_uid);
+ perror("setuid");
+ }
+
+
+ /* Pause if that option was specified */
+ TEST_PAUSE;
+
+ /* make a temp directory and cd to it */
+ tst_tmpdir();
+
+ /* Creat a temporary file under above directory */
+ if ((fildes = creat(TEMP_FILE, FILE_MODE)) == -1) {
+ tst_brkm(TBROK, cleanup,
+ "creat(%s, %#o) Failed, errno=%d :%s",
+ TEMP_FILE, FILE_MODE, errno, strerror(errno));
+ }
+
+ /* Close the temporary file created */
+ if (close(fildes) < 0) {
+ tst_brkm(TBROK, cleanup,
+ "close(%s) Failed, errno=%d : %s:",
+ TEMP_FILE, errno, strerror(errno));
+ }
+
+ /* Initialize the modification and access time in the times arg */
+ times[0].tv_sec = NEW_TIME;
+ times[0].tv_usec = NEW_TIME_USEC;
+ times[1].tv_sec = NEW_TIME;
+ times[1].tv_usec = NEW_TIME_USEC;
+
+} /* End setup() */
+
+/*
+ * void
+ * cleanup() - performs all ONE TIME cleanup for this test at
+ * completion or premature exit.
+ * Remove the test directory and testfile created in the setup.
+ */
+void
+cleanup()
+{
+ /*
+ * print timing stats if that option was specified.
+ * print errno log if that option was specified.
+ */
+ TEST_CLEANUP;
+
+ /* Remove tmp dir and all files in it */
+ tst_rmdir();
+
+ /* exit with return code appropriate for results */
+ tst_exit();
+} /* End cleanup() */
diff -ruN ltp-full-20061121-orig/testcases/kernel/syscalls/utimes/utimes06.c ltp-full-20061121/testcases/kernel/syscalls/utimes/utimes06.c
--- ltp-full-20061121-orig/testcases/kernel/syscalls/utimes/utimes06.c Wed Dec 31 18:00:00 1969
+++ ltp-full-20061121/testcases/kernel/syscalls/utimes/utimes06.c Thu Dec 14 12:40:45 2006
@@ -0,0 +1,337 @@
+/*
+ *
+ * Copyright (c) International Business Machines Corp., 2001
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ * the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/*
+ * Test Name: utimes06
+ *
+ * Test Description:
+ * 1. Verify that the system call utimes() fails to set the modification
+ * and access times of a file to the current time, under the following
+ * constraints,
+ * - The times argument is null.
+ * - The user ID of the process is not "root".
+ * - The file is not owned by the user ID of the process.
+ * - The user ID of the process does not have write access to the
+ * file.
+ * 2. Verify that the system call utimes() fails to set the modification
+ * and access times of a file if the specified file doesn't exist.
+ *
+ * Expected Result:
+ * 1. utimes should fail with -1 return value and sets errno EACCES.
+ * 2. utimes should fail with -1 return value and sets errno ENOENT.
+ *
+ * Algorithm:
+ * Setup:
+ * Setup signal handling.
+ * Create temporary directory.
+ * Pause for SIGUSR1 if option specified.
+ *
+ * Test:
+ * Loop if the proper options are given.
+ * Execute system call
+ * Check return code, if system call failed (return=-1)
+ * if errno set == expected errno
+ * Issue sys call fails with expected return value and errno.
+ * Otherwise,
+ * Issue sys call fails with unexpected errno.
+ * Otherwise,
+ * Issue sys call returns unexpected value.
+ *
+ * Cleanup:
+ * Print errno log and/or timing stats if options given
+ * Delete the temporary directory(s)/file(s) created.
+ *
+ * Usage: <for command-line>
+ * utimes06 [-c n] [-e] [-i n] [-I x] [-p x] [-t]
+ * where, -c n : Run n copies concurrently.
+ * -e : Turn on errno logging.
+ * -i n : Execute test n times.
+ * -I x : Execute test for x seconds.
+ * -P x : Pause for x seconds between iterations.
+ * -t : Turn on syscall timing.
+ *
+ * History
+ * 07/2001 John George
+ * -Ported
+ *
+ * Restrictions:
+ * This test must be executed by root.
+ * nobody and bin must be valid users.
+ */
+
+#include <errno.h>
+#include <fcntl.h>
+#include <pwd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <wait.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include "test.h"
+#include "usctest.h"
+
+#define LTPUSER1 "nobody"
+#define LTPUSER2 "bin"
+#define TEMP_FILE "tmp_file"
+#define FILE_MODE S_IRUSR | S_IRGRP | S_IROTH
+
+char *TCID="utimes06"; /* Test program identifier. */
+int TST_TOTAL=2; /* Total number of test cases. */
+extern int Tst_count; /* Test Case counter for tst_* routines */
+time_t curr_time; /* current time in seconds */
+time_t tloc; /* argument var. for time() */
+int exp_enos[]={EACCES, ENOENT, 0};
+
+struct passwd *ltpuser; /* password struct for ltpusers */
+uid_t user_uid; /* user id of ltpuser */
+gid_t group_gid; /* group id of ltpuser */
+int status;
+
+int setup1(); /* setup function to test error EACCES */
+int no_setup();
+
+struct test_case_t { /* test case struct. to hold ref. test cond's*/
+ char *pathname;
+ char *desc;
+ int exp_errno;
+ int (*setupfunc)();
+} Test_cases[] = {
+ { TEMP_FILE, "Permission denied to modify file time", EACCES, setup1 },
+ { "", "Specified file doesn't exist", ENOENT, no_setup },
+ { NULL, NULL, 0, NULL}
+};
+
+void setup(); /* Main setup function of test */
+void cleanup(); /* cleanup function for the test */
+
+int
+main(int ac, char **av)
+{
+ int lc; /* loop counter */
+ char *msg; /* message returned from parse_opts */
+ char *file_name; /* testfile name */
+ char *test_desc; /* test specific error message */
+ int ind; /* counter to test different test conditions */
+ int pid;
+
+ /* Parse standard options given to run the test. */
+ msg = parse_opts(ac, av, (option_t *) NULL, NULL);
+ if (msg != (char *) NULL) {
+ tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
+ tst_exit();
+ }
+
+ /* Perform global setup for test */
+ setup();
+
+ /* set the expected errnos... */
+ TEST_EXP_ENOS(exp_enos);
+
+ pid = FORK_OR_VFORK();
+
+ if (pid == -1) {
+ tst_brkm(TBROK, cleanup, "fork() failed");
+ /*NOTREACHED*/
+ } else if (pid == 0) {
+ if ((ltpuser = getpwnam(LTPUSER1)) == NULL) {
+ tst_brkm(TBROK,cleanup,"%s not found in /etc/passwd",
+ LTPUSER1);
+ /*NOTREACHED*/
+ }
+
+ /* get uid of user */
+ user_uid = ltpuser->pw_uid;
+
+ seteuid(user_uid);
+
+ /* Check looping state if -i option given */
+ for (lc = 0; TEST_LOOPING(lc); lc++) {
+ /* Reset Tst_count in case we are looping. */
+ Tst_count=0;
+
+ for (ind = 0; Test_cases[ind].desc != NULL; ind++) {
+ file_name = Test_cases[ind].pathname;
+ test_desc = Test_cases[ind].desc;
+
+ /*
+ * Call utimes(2) to test different test
+ * conditions. Verify that it fails with -1
+ * return value and sets appropriate errno.
+ */
+ TEST(utimes(file_name, NULL));
+
+ /* Check return code from utimes(2) */
+ if (TEST_RETURN == -1) {
+ TEST_ERROR_LOG(TEST_ERRNO);
+ if (TEST_ERRNO ==
+ Test_cases[ind].exp_errno) {
+ tst_resm(TPASS, "utimes() "
+ "fails, %s, errno:%d",
+ test_desc, TEST_ERRNO);
+ } else {
+ tst_resm(TFAIL, "utimes(2) "
+ "fails, %s, errno:%d, "
+ "expected errno:%d",
+ test_desc, TEST_ERRNO,
+ Test_cases[ind].exp_errno);
+ }
+ } else {
+ tst_resm(TFAIL, "utimes(2) returned %d, "
+ "expected -1, errno:%d",
+ TEST_RETURN,
+ Test_cases[ind].exp_errno);
+ }
+ } /* End of TEST CASE LOOPING. */
+
+ Tst_count++; /* incr TEST_LOOP counter */
+
+ } /* End for TEST_LOOPING */
+ } else {
+ waitpid(pid, &status, 0);
+ _exit(0); /*
+ * Exit here and let the child clean up.
+ * This allows the errno information set
+ * by the TEST_ERROR_LOG macro and the
+ * PASS/FAIL status to be preserved for
+ * use during cleanup.
+ */
+ }
+ /* Call cleanup() to undo setup done for the test. */
+ cleanup();
+ /*NOTREACHED*/
+
+
+ return(0);
+
+} /* End main */
+
+/*
+ * void
+ * setup() - performs all ONE TIME setup for this test.
+ * Create a temporary directory and change directory to it.
+ * Invoke individual test setup functions according to the order
+ * set in test struct. definition.
+ */
+void
+setup()
+{
+ int ind; /* counter for setup functions */
+
+ /* capture signals */
+ tst_sig(FORK, DEF_HANDLER, cleanup);
+
+ /* Check that the test process id is non-super/root */
+ if (geteuid() != 0) {
+ tst_brkm(TBROK, NULL, "Must be root for this test!");
+ tst_exit();
+ }
+
+ /* Pause if that option was specified */
+ TEST_PAUSE;
+
+ /* make a temp directory and cd to it */
+ tst_tmpdir();
+
+ /* call individual setup functions */
+ for (ind = 0; Test_cases[ind].desc != NULL; ind++) {
+ Test_cases[ind].setupfunc();
+ }
+} /* End setup() */
+
+/*
+ * int
+ * no_setup() - Some test conditions for utimes(2) do not any setup.
+ * Hence, this function just returns 0.
+ */
+int
+no_setup()
+{
+ return 0;
+}
+
+/*
+ * int
+ * setup1() - setup function for a test condition for which utimes(2)
+ * returns -1 and sets errno to EACCES.
+ * Create a testfile under temporary directory and change the ownership of
+ * testfile to "bin".
+ */
+int
+setup1()
+{
+ int fildes; /* file handle for temp file */
+
+ /* Creat a temporary file under above directory */
+ if ((fildes = creat(TEMP_FILE, FILE_MODE)) == -1) {
+ tst_brkm(TBROK, cleanup, "creat(%s, %#o) Failed, errno=%d :%s",
+ TEMP_FILE, FILE_MODE, errno, strerror(errno));
+ }
+
+ /* Close the temporary file created */
+ if (close(fildes) < 0) {
+ tst_brkm(TBROK, cleanup, "close(%s) Failed, errno=%d : %s:",
+ TEMP_FILE, errno, strerror(errno));
+ }
+
+ if ((ltpuser = getpwnam(LTPUSER2)) == NULL) {
+ tst_brkm(TBROK, cleanup, "%s not found in /etc/passwd",
+ LTPUSER2);
+ /*NOTREACHED*/
+ }
+
+ /* get uid/gid of user accordingly */
+ user_uid = ltpuser->pw_uid;
+ group_gid = ltpuser->pw_gid;
+
+ if (chown(TEMP_FILE, user_uid, group_gid) < 0) {
+ tst_brkm(TBROK, cleanup, "chown() of %s failed, error %d",
+ TEMP_FILE, errno);
+ /*NOTREACHED*/
+ }
+
+ return 0;
+} /* End of setup1 */
+
+/*
+ * void
+ * cleanup() - performs all ONE TIME cleanup for this test at
+ * completion or premature exit.
+ * Remove the test directory and testfile created in the setup.
+ */
+void
+cleanup()
+{
+ seteuid(0);
+ /*
+ * print timing stats if that option was specified.
+ * print errno log if that option was specified.
+ */
+ TEST_CLEANUP;
+
+ /* Remove tmp dir and all files in it */
+ tst_rmdir();
+
+ /* exit with return code appropriate for results */
+ tst_exit();
+} /* End cleanup() */
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?790a9fff0612141858x3a0a4ce5vc348d32d9b56f343>
