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