From 481ce84e6cf3050793b382ffdaacd471c35e7923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sat, 18 Jan 2003 14:20:05 +0000 Subject: [PATCH] A very basic node monitoring test - directly uses the kernel calls (since there is no libbe.so yet). Doesn't even query the port; just causes send_notification() in the kernel to be called which will print out some info. Added to the build. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2487 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/apps/Jamfile | 1 + src/kernel/apps/monitor_test.c | 44 ++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 src/kernel/apps/monitor_test.c diff --git a/src/kernel/apps/Jamfile b/src/kernel/apps/Jamfile index 418f3ed69b..7af96fdf6a 100644 --- a/src/kernel/apps/Jamfile +++ b/src/kernel/apps/Jamfile @@ -4,6 +4,7 @@ KernelObjects false_main.c fibo_main.c init.c + monitor_test.c true_main.c sig_test.c select_test.c diff --git a/src/kernel/apps/monitor_test.c b/src/kernel/apps/monitor_test.c new file mode 100644 index 0000000000..7adc786875 --- /dev/null +++ b/src/kernel/apps/monitor_test.c @@ -0,0 +1,44 @@ +/* tests node monitor functionality (very basic test!) */ + +/* +** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ + + +#include +#include +#include + +#include +#include +#include + + +int +main(int argc, char **argv) +{ + struct stat st; + if (stat("/", &st) < 0) { + fprintf(stderr, "Could not stat root!\n"); + return -1; + } + + printf("watch file: device = %ld, node = %Ld\n", st.st_dev, st.st_ino); + + if (sys_start_watching(st.st_dev, st.st_ino, B_WATCH_DIRECTORY, 1, 2) < B_OK) { + fprintf(stderr, "Could not start watching!\n"); + return -1; + } + + mkdir("/temp_test", 0755); + rmdir("/temp_test"); + + if (sys_stop_watching(st.st_dev, st.st_ino, 0, 1, 2) < B_OK) { + fprintf(stderr, "Could not stop watching!\n"); + return -1; + } + + return 0; +} +