diff options
Diffstat (limited to 'tests/zfs-tests/tests/functional/tmpfile/tmpfile_stat_mode.c')
-rw-r--r-- | tests/zfs-tests/tests/functional/tmpfile/tmpfile_stat_mode.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/tests/zfs-tests/tests/functional/tmpfile/tmpfile_stat_mode.c b/tests/zfs-tests/tests/functional/tmpfile/tmpfile_stat_mode.c index 893d2639ae64..8f936d36de1f 100644 --- a/tests/zfs-tests/tests/functional/tmpfile/tmpfile_stat_mode.c +++ b/tests/zfs-tests/tests/functional/tmpfile/tmpfile_stat_mode.c @@ -6,7 +6,7 @@ * You may not use this file except in compliance with the License. * * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. + * or https://opensource.org/licenses/CDDL-1.0. * See the License for the specific language governing permissions * and limitations under the License. * @@ -37,18 +37,18 @@ /* * DESCRIPTION: - * Verify stat(2) for O_TMPFILE file considers umask. + * Verify fstat(2) for O_TMPFILE file considers umask. * * STRATEGY: * 1. open(2) with O_TMPFILE. * 2. linkat(2). - * 3. fstat(2)/stat(2) and verify .st_mode value. + * 3. fstat(2) and verify .st_mode value. */ static void test_stat_mode(mode_t mask) { - struct stat st, fst; + struct stat fst; int i, fd; char spath[1024], dpath[1024]; const char *penv[] = {"TESTDIR", "TESTFILE0"}; @@ -68,7 +68,7 @@ test_stat_mode(mode_t mask) err(2, "open(%s)", penv[0]); if (fstat(fd, &fst) == -1) - err(3, "open"); + err(3, "fstat(%s)", penv[0]); snprintf(spath, sizeof (spath), "/proc/self/fd/%d", fd); snprintf(dpath, sizeof (dpath), "%s/%s", penv[0], penv[1]); @@ -78,19 +78,23 @@ test_stat_mode(mode_t mask) err(4, "linkat"); close(fd); - if (stat(dpath, &st) == -1) - err(5, "stat"); - unlink(dpath); - - /* Verify fstat(2) result */ + /* Verify fstat(2) result at old path */ mode = fst.st_mode & 0777; if (mode != masked) - errx(6, "fstat(2) %o != %o\n", mode, masked); + errx(5, "fstat(2) %o != %o\n", mode, masked); + + fd = open(dpath, O_RDWR); + if (fd == -1) + err(6, "open(%s)", dpath); - /* Verify stat(2) result */ - mode = st.st_mode & 0777; + if (fstat(fd, &fst) == -1) + err(7, "fstat(%s)", dpath); + + /* Verify fstat(2) result at new path */ + mode = fst.st_mode & 0777; if (mode != masked) - errx(7, "stat(2) %o != %o\n", mode, masked); + errx(8, "fstat(2) %o != %o\n", mode, masked); + close(fd); } int |