4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
30 * A read operation and directory update operation performed
31 * concurrently on the same directory can lead to deadlock
32 * on a UFS logging file system, but not on a ZFS file system.
35 #include <sys/types.h>
45 static char dirpath
[256];
48 main(int argc
, char **argv
)
55 static const int op_num
= 5;
58 (void) printf("Usage: %s <mount point>\n", argv
[0]);
61 for (i
= 0; i
< 256; i
++) {
66 if (strlen(cp1
) >= (sizeof (dirpath
) - strlen("TMP_DIR"))) {
67 (void) printf("The string length of mount point is "
71 (void) strcpy(&dirpath
[0], (const char *)cp1
);
72 (void) strcat(&dirpath
[strlen(dirpath
)], "TMP_DIR");
74 ret
= mkdir(dirpath
, 0777);
76 if (errno
!= EEXIST
) {
77 (void) printf("%s: mkdir(<%s>, 0777) failed: errno "
78 "(decimal)=%d\n", argv
[0], dirpath
, errno
);
82 testdd
= open(dirpath
, O_RDONLY
|O_RSYNC
|O_SYNC
|O_DSYNC
);
84 (void) printf("%s: open(<%s>, O_RDONLY|O_RSYNC|O_SYNC|O_DSYNC)"
85 " failed: errno (decimal)=%d\n", argv
[0], dirpath
, errno
);
92 int fd
= open(dirpath
, O_RDONLY
|O_RSYNC
|O_SYNC
|O_DSYNC
);
98 (void) printf("%s: open <%s> again failed:"
99 " errno = %d\n", argv
[0], dirpath
, errno
);
105 rdret
= read(fd
, buf
, 16);
107 (void) printf("readdir failed");
112 } else if (pid
== 0) {
113 int fd
= open(dirpath
, O_RDONLY
);
118 (void) printf("%s: open(<%s>, O_RDONLY) again failed:"
119 " errno (decimal)=%d\n", argv
[0], dirpath
, errno
);
125 chownret
= fchown(fd
, 0, 0);
126 if (chownret
== -1) {
127 (void) printf("chown failed");