1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
15 #include <sys/types.h>
23 int main(int argc, char **argv)
30 fprintf(stderr, "usage: %s dirname1\n", argv[0]);
36 //create the directory
37 fprintf(stderr, "creating directory %s\n", dname1);
38 rc = mkdir(dname1, 0744);
40 fprintf(stderr, "creating %s fails: %s\n",
41 dname1, strerror(errno));
45 sprintf(fname, "%s/0", dname1);
46 fprintf(stderr, "creating file %s\n", fname);
47 fd = creat(fname, 0666);
49 fprintf(stderr, "creation %s fails: %s\n",
50 fname, strerror(errno));
56 fprintf(stderr, "opening directory\n");
57 fddir1 = open(dname1, O_RDONLY | O_DIRECTORY);
59 fprintf(stderr, "open %s fails: %s\n",
60 dname1, strerror(errno));
65 fprintf(stderr, "unlinking %s\n", dname1);
68 fprintf(stderr, "unlinked non-empty %s successfully\n",
73 if (access(dname1, F_OK) != 0){
74 fprintf(stderr, "can't access %s: %s\n",
75 dname1, strerror(errno));
79 fprintf(stderr, "Ok, everything goes well.\n");