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 2008 Sun Microsystems, Inc. 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%06o", 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);
98 fprintf(stderr, "%s: ERROR unlink %s: %s",
99 argv[0], name, strerror(errno));
105 fprintf(stderr, "%s: ERROR: %s created\n",
112 for (i = 0; i <= S_IFMT; i += (1 << S_SHIFT)) {
119 sprintf(name, "%s-creat%06o", argv[1], mode);
120 fd = open(name, O_CREAT|O_RDONLY, mode);
122 fprintf(stderr, "%s: ERROR creat %s: %s\n",
123 argv[0], name, strerror(errno));
127 rc = stat(name, &st);
129 fprintf(stderr, "%s: ERROR stat %s: %s",
130 argv[0], name, strerror(errno));
133 if (!S_ISREG(st.st_mode & S_IFMT)) {
134 fprintf(stderr, "%s: ERROR mode %s: %o != %o",
135 argv[0], name, st.st_mode & S_IFMT, S_IFREG);
140 fprintf(stderr, "%s: ERROR unlink %s: %s\n",
141 argv[0], name, strerror(errno));
146 for (i = 0; i <= S_IFMT; i += (1 << S_SHIFT)) {
150 sprintf(name, "%s-mkdir%06o", argv[1], i | 0644);
151 rc = mkdir(name, i | 0664);
153 fprintf(stderr, "%s: ERROR mkdir %s: %s\n",
154 argv[0], name, strerror(errno));
157 rc = stat(name, &st);
159 fprintf(stderr, "%s: ERROR stat %s: %s",
160 argv[0], name, strerror(errno));
163 if (!S_ISDIR(st.st_mode)) {
164 fprintf(stderr, "%s: ERROR mode %s: %o != %o",
165 argv[0], name, st.st_mode & S_IFMT, S_IFDIR);
170 fprintf(stderr, "%s: ERROR rmdir %s: %s\n",
171 argv[0], name, strerror(errno));
176 printf("%s: SUCCESS\n", argv[0]);