summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-05-24 05:25:33 +0200
committerLennart Poettering <lennart@poettering.net>2010-05-24 05:25:33 +0200
commit01f78473b104d28db0fa813414092bc6358ae521 (patch)
treedbc1a63d818c7420ee2a50cbd205ae90b0c7185d /src/util.c
parent871d7de47c13ee6cd78b8eefdf9128be3c740ac0 (diff)
path: add .path unit type for monitoring files
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index a8ea4a97ab..7664df59d0 100644
--- a/src/util.c
+++ b/src/util.c
@@ -2092,6 +2092,35 @@ bool is_device_path(const char *path) {
path_startswith(path, "/sys/");
}
+int dir_is_empty(const char *path) {
+ DIR *d;
+ int r;
+ struct dirent buf, *de;
+
+ if (!(d = opendir(path)))
+ return -errno;
+
+ for (;;) {
+ if ((r = readdir_r(d, &buf, &de)) > 0) {
+ r = -r;
+ break;
+ }
+
+ if (!de) {
+ r = 1;
+ break;
+ }
+
+ if (!ignore_file(de->d_name)) {
+ r = 0;
+ break;
+ }
+ }
+
+ closedir(d);
+ return r;
+}
+
static const char *const ioprio_class_table[] = {
[IOPRIO_CLASS_NONE] = "none",
[IOPRIO_CLASS_RT] = "realtime",