• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * hold_inode.c --- test program which holds an inode or directory
3  * open.
4  *
5  * Copyright (C) 2000 Theodore Ts'o.
6  *
7  * %Begin-Header%
8  * This file may be redistributed under the terms of the GNU Public
9  * License.
10  * %End-Header%
11  */
12 
13 #include <unistd.h>
14 #include <stdio.h>
15 #include <dirent.h>
16 #include <sys/types.h>
17 #include <sys/stat.h>
18 #include <fcntl.h>
19 
20 
main(int argc,char ** argv)21 main(int argc, char **argv)
22 {
23 	struct stat	statbuf;
24 	char *filename;
25 
26 	if (argc != 2) {
27 		fprintf(stderr, "Usage: %s dir\n", argv[0]);
28 		exit(1);
29 	}
30 	filename = argv[1];
31 	if (stat(filename, &statbuf) < 0) {
32 		perror(filename);
33 		exit(1);
34 	}
35 	if (S_ISDIR(statbuf.st_mode)) {
36 		if (!opendir(filename)) {
37 			perror(filename);
38 			exit(1);
39 		}
40 	} else {
41 		if (open(filename, O_RDONLY) < 0) {
42 			perror(filename);
43 			exit(1);
44 		}
45 	}
46 	sleep(30);
47 }
48