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.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
27 * This file is part of Lustre, http://www.lustre.org/
28 * Lustre is a trademark of Sun Microsystems, Inc.
33 #include <sys/types.h>
46 fprintf(stderr, "usage: %s <basename>\n", prog);
50 int main(int argc, char *argv[])
59 for (i = 0; i <= S_IFMT; i += (1 << S_SHIFT)) {
64 snprintf(name, sizeof(name), "%s-mknod%07o", argv[1], mode);
65 rc = mknod(name, mode, 0x1234);
70 case S_IFCHR: case S_IFBLK:
71 if (rc < 0 && getuid() != 0)
73 case S_IFSOCK: case S_IFIFO:
75 fprintf(stderr, "%s: ERROR mknod %s: %s\n",
76 argv[0], name, strerror(errno));
81 fprintf(stderr, "%s: ERROR stat %s: %s",
82 argv[0], name, strerror(errno));
85 if (st.st_mode != mode) {
86 fprintf(stderr, "%s: ERROR mode %s: %o != %o",
87 argv[0], name, st.st_mode, mode);
90 if (i == S_IFCHR || i == S_IFBLK) {
91 if (st.st_rdev != 0x1234) {
92 fprintf(stderr, "%s: ERROR rdev %s: "
95 (unsigned long long)st.st_rdev);
101 fprintf(stderr, "%s: ERROR unlink %s: %s",
102 argv[0], name, strerror(errno));
108 fprintf(stderr, "%s: ERROR: %s created\n",
115 for (i = 0; i <= S_IFMT; i += (1 << S_SHIFT)) {
122 snprintf(name, sizeof(name), "%s-creat%07o", argv[1], mode);
123 fd = open(name, O_CREAT|O_RDONLY, mode);
125 fprintf(stderr, "%s: ERROR creat %s: %s\n",
126 argv[0], name, strerror(errno));
130 rc = stat(name, &st);
132 fprintf(stderr, "%s: ERROR stat %s: %s",
133 argv[0], name, strerror(errno));
136 if (!S_ISREG(st.st_mode & S_IFMT)) {
137 fprintf(stderr, "%s: ERROR mode %s: %o != %o",
138 argv[0], name, st.st_mode & S_IFMT, S_IFREG);
143 fprintf(stderr, "%s: ERROR unlink %s: %s\n",
144 argv[0], name, strerror(errno));
149 for (i = 0; i <= S_IFMT; i += (1 << S_SHIFT)) {
153 snprintf(name, sizeof(name), "%s-mkdir%06o", argv[1], i | 0644);
154 rc = mkdir(name, i | 0664);
156 fprintf(stderr, "%s: ERROR mkdir %s: %s\n",
157 argv[0], name, strerror(errno));
160 rc = stat(name, &st);
162 fprintf(stderr, "%s: ERROR stat %s: %s",
163 argv[0], name, strerror(errno));
166 if (!S_ISDIR(st.st_mode)) {
167 fprintf(stderr, "%s: ERROR mode %s: %o != %o",
168 argv[0], name, st.st_mode & S_IFMT, S_IFDIR);
173 fprintf(stderr, "%s: ERROR rmdir %s: %s\n",
174 argv[0], name, strerror(errno));
179 printf("%s: SUCCESS\n", argv[0]);