xref: /haiku/src/tests/system/kernel/lock_node_test.cpp (revision 2b76973fa2401f7a5edf68e6470f3d3210cbcff3)
1 #include <Node.h>
2 
3 #include <stdio.h>
4 #include <string.h>
5 
6 
7 int
8 main(int argc, char **argv)
9 {
10 	if (argc != 2) {
11 		fprintf(stderr, "usage: lock_node <file>\n");
12 		return 1;
13 	}
14 
15 	BNode node;
16 	status_t status = node.SetTo(argv[1]);
17 	if (status != B_OK) {
18 		fprintf(stderr, "lock_node: could not open \"%s\": %s\n", argv[1], strerror(status));
19 		return 1;
20 	}
21 
22 	status = node.Lock();
23 	if (status != B_OK) {
24 		fprintf(stderr, "lock_node: could not lock \"%s\": %s\n", argv[1], strerror(status));
25 		return 1;
26 	}
27 
28 	puts("press <enter> to continue...");
29 	char a[5];
30 	fgets(a, 5, stdin);
31 
32 	node.Unlock();
33 	node.Unset();
34 	return 0;
35 }
36 
37