Whamcloud - gitweb
Branch b1_6
[fs/lustre-release.git] / lustre / tests / munlink.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  */
4 #include <stdio.h>
5 #include <sys/types.h>
6 #include <sys/stat.h>
7 #include <errno.h>
8 #include <string.h>
9 #include <fcntl.h>
10 #include <unistd.h>
11
12 int main(int argc, char ** argv)
13 {
14         int rc = 0, i;
15
16         if (argc < 2) {
17                 printf("Usage %s filename {filename ...}\n", argv[0]);
18                 return 1;
19         }
20
21         for (i = 1; i < argc; i++) {
22                 rc = unlink(argv[i]);
23                 if (rc) {
24                         printf("unlink(%s): %s ", argv[i], strerror(errno));
25                         rc = access(argv[i], F_OK);
26                         if (rc && errno == ENOENT)
27                                 printf("(unlinked anyways)\n");
28                         else if (rc == 0)
29                                 printf("(still exists)\n");
30                         else
31                                 printf("(%s looking up)\n", strerror(errno));
32                 }
33         }
34         return rc;
35 }