1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
30 * Use is subject to license terms.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
39 #include <sys/types.h>
52 fprintf(stderr, "usage: %s <basename>\n", prog);
56 int main(int argc, char *argv[])
65 for (i = 0; i <= S_IFMT; i += (1 << S_SHIFT)) {
70 sprintf(name, "%s-mknod%07o", argv[1], mode);
71 rc = mknod(name, mode, 0x1234);
76 case S_IFCHR: case S_IFBLK:
77 if (rc < 0 && getuid() != 0)
79 case S_IFSOCK: case S_IFIFO:
81 fprintf(stderr, "%s: ERROR mknod %s: %s\n",
82 argv[0], name, strerror(errno));
87 fprintf(stderr, "%s: ERROR stat %s: %s",
88 argv[0], name, strerror(errno));
91 if (st.st_mode != mode) {
92 fprintf(stderr, "%s: ERROR mode %s: %o != %o",
93 argv[0], name, st.st_mode, mode);
96 if (i == S_IFCHR || i == S_IFBLK) {
97 if (st.st_rdev != 0x1234) {
98 fprintf(stderr, "%s: ERROR rdev %s: "
101 (unsigned long long)st.st_rdev);
107 fprintf(stderr, "%s: ERROR unlink %s: %s",
108 argv[0], name, strerror(errno));
114 fprintf(stderr, "%s: ERROR: %s created\n",
121 for (i = 0; i <= S_IFMT; i += (1 << S_SHIFT)) {
128 sprintf(name, "%s-creat%07o", argv[1], mode);
129 fd = open(name, O_CREAT|O_RDONLY, mode);
131 fprintf(stderr, "%s: ERROR creat %s: %s\n",
132 argv[0], name, strerror(errno));
136 rc = stat(name, &st);
138 fprintf(stderr, "%s: ERROR stat %s: %s",
139 argv[0], name, strerror(errno));
142 if (!S_ISREG(st.st_mode & S_IFMT)) {
143 fprintf(stderr, "%s: ERROR mode %s: %o != %o",
144 argv[0], name, st.st_mode & S_IFMT, S_IFREG);
149 fprintf(stderr, "%s: ERROR unlink %s: %s\n",
150 argv[0], name, strerror(errno));
155 for (i = 0; i <= S_IFMT; i += (1 << S_SHIFT)) {
159 sprintf(name, "%s-mkdir%06o", argv[1], i | 0644);
160 rc = mkdir(name, i | 0664);
162 fprintf(stderr, "%s: ERROR mkdir %s: %s\n",
163 argv[0], name, strerror(errno));
166 rc = stat(name, &st);
168 fprintf(stderr, "%s: ERROR stat %s: %s",
169 argv[0], name, strerror(errno));
172 if (!S_ISDIR(st.st_mode)) {
173 fprintf(stderr, "%s: ERROR mode %s: %o != %o",
174 argv[0], name, st.st_mode & S_IFMT, S_IFDIR);
179 fprintf(stderr, "%s: ERROR rmdir %s: %s\n",
180 argv[0], name, strerror(errno));
185 printf("%s: SUCCESS\n", argv[0]);