summaryrefslogtreecommitdiffstats
path: root/tests/progs/hold_inode.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:49:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:49:25 +0000
commit464df1d5e5ab1322e2dd0a7796939fff1aeefa9a (patch)
tree6a403684e0978f0287d7f0ec0e5aab1fd31a59e1 /tests/progs/hold_inode.c
parentInitial commit. (diff)
downloade2fsprogs-464df1d5e5ab1322e2dd0a7796939fff1aeefa9a.tar.xz
e2fsprogs-464df1d5e5ab1322e2dd0a7796939fff1aeefa9a.zip
Adding upstream version 1.47.0.upstream/1.47.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/progs/hold_inode.c')
-rw-r--r--tests/progs/hold_inode.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/progs/hold_inode.c b/tests/progs/hold_inode.c
new file mode 100644
index 0000000..792aa71
--- /dev/null
+++ b/tests/progs/hold_inode.c
@@ -0,0 +1,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);
+}