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.
42 #include <sys/types.h>
49 int main(int argc, char **argv)
51 char *dname1, *dname2;
52 int fddev1, fddev2, rc;
56 if (argc < 2 || argc > 3) {
57 fprintf(stderr, "usage: %s filename1 [filename2]\n", argv[0]);
67 //create the special file (right now only test on pipe)
68 fprintf(stderr, "creating special file %s\n", dname1);
69 rc = mknod(dname1, 0777|S_IFIFO, 0);
71 fprintf(stderr, "creating %s fails: %s\n",
72 dname1, strerror(errno));
76 // open the special file again
77 fprintf(stderr, "opening file\n");
78 fddev1 = open(dname1, O_RDONLY | O_NONBLOCK);
80 fprintf(stderr, "open %s fails: %s\n",
81 dname1, strerror(errno));
85 // doesn't matter if the two dirs are the same??
86 fddev2 = open(dname2, O_RDONLY | O_NONBLOCK);
88 fprintf(stderr, "open %s fails: %s\n",
89 dname2, strerror(errno));
93 // delete the special file
94 fprintf (stderr, "unlinking %s\n", dname1);
97 fprintf(stderr, "unlink %s error: %s\n",
98 dname1, strerror(errno));
102 if (access(dname2, F_OK) == 0) {
103 fprintf(stderr, "%s still exists\n", dname2);
107 if (access(dname1, F_OK) == 0) {
108 fprintf(stderr, "%s still exists\n", dname1);
112 // fchmod one special file
113 rc = fchmod (fddev1, 0777);
115 fprintf(stderr, "fchmod unlinked special file %s fails: %s\n",
116 dname1, strerror(errno));
120 // fstat two files to check if they are the same
121 rc = fstat(fddev1, &st1);
123 fprintf(stderr, "fstat unlinked special file %s fails: %s\n",
124 dname1, strerror(errno));
128 rc = fstat(fddev2, &st2);
130 fprintf(stderr, "fstat file %s fails: %s\n",
131 dname2, strerror(errno));
136 /* We cannot do this any longer, we do not store open special nodes
137 * on MDS after unlink */
138 if (st1.st_mode != st2.st_mode) { // can we do this?
139 fprintf(stderr, "fstat different value on %s and %s\n", dname1, dname2);
144 fprintf(stderr, "Ok, everything goes well.\n");