4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
31 * This file is part of Lustre, http://www.lustre.org/
32 * Lustre is a trademark of Sun Microsystems, Inc.
37 #include <sys/types.h>
50 fprintf(stderr, "usage: %s <basename>\n", prog);
54 int main(int argc, char *argv[])
63 for (i = 0; i <= S_IFMT; i += (1 << S_SHIFT)) {
68 snprintf(name, sizeof(name), "%s-mknod%07o", argv[1], mode);
69 rc = mknod(name, mode, 0x1234);
74 case S_IFCHR: case S_IFBLK:
75 if (rc < 0 && getuid() != 0)
77 case S_IFSOCK: case S_IFIFO:
79 fprintf(stderr, "%s: ERROR mknod %s: %s\n",
80 argv[0], name, strerror(errno));
85 fprintf(stderr, "%s: ERROR stat %s: %s",
86 argv[0], name, strerror(errno));
89 if (st.st_mode != mode) {
90 fprintf(stderr, "%s: ERROR mode %s: %o != %o",
91 argv[0], name, st.st_mode, mode);
94 if (i == S_IFCHR || i == S_IFBLK) {
95 if (st.st_rdev != 0x1234) {
96 fprintf(stderr, "%s: ERROR rdev %s: "
99 (unsigned long long)st.st_rdev);
105 fprintf(stderr, "%s: ERROR unlink %s: %s",
106 argv[0], name, strerror(errno));
112 fprintf(stderr, "%s: ERROR: %s created\n",
119 for (i = 0; i <= S_IFMT; i += (1 << S_SHIFT)) {
126 snprintf(name, sizeof(name), "%s-creat%07o", argv[1], mode);
127 fd = open(name, O_CREAT|O_RDONLY, mode);
129 fprintf(stderr, "%s: ERROR creat %s: %s\n",
130 argv[0], name, strerror(errno));
134 rc = stat(name, &st);
136 fprintf(stderr, "%s: ERROR stat %s: %s",
137 argv[0], name, strerror(errno));
140 if (!S_ISREG(st.st_mode & S_IFMT)) {
141 fprintf(stderr, "%s: ERROR mode %s: %o != %o",
142 argv[0], name, st.st_mode & S_IFMT, S_IFREG);
147 fprintf(stderr, "%s: ERROR unlink %s: %s\n",
148 argv[0], name, strerror(errno));
153 for (i = 0; i <= S_IFMT; i += (1 << S_SHIFT)) {
157 snprintf(name, sizeof(name), "%s-mkdir%06o", argv[1], i | 0644);
158 rc = mkdir(name, i | 0664);
160 fprintf(stderr, "%s: ERROR mkdir %s: %s\n",
161 argv[0], name, strerror(errno));
164 rc = stat(name, &st);
166 fprintf(stderr, "%s: ERROR stat %s: %s",
167 argv[0], name, strerror(errno));
170 if (!S_ISDIR(st.st_mode)) {
171 fprintf(stderr, "%s: ERROR mode %s: %o != %o",
172 argv[0], name, st.st_mode & S_IFMT, S_IFDIR);
177 fprintf(stderr, "%s: ERROR rmdir %s: %s\n",
178 argv[0], name, strerror(errno));
183 printf("%s: SUCCESS\n", argv[0]);