Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 61 lines (53 sloc) 1.461 kB
e827904 @poelzi fix endless recrusion, timer wrapper, invalid iterator
authored
1 #include "config.h"
2 #include "ulatency.h"
f81bfec @poelzi add missing file
authored
3 #include <stdio.h>
4 #include <fts.h>
5 #include <unistd.h>
e827904 @poelzi fix endless recrusion, timer wrapper, invalid iterator
authored
6 #include <glib.h>
f81bfec @poelzi add missing file
authored
7
8
9 void recursive_rmdir(const char *path, int add_level) {
10 FTS *fts;
11 FTSENT *ftsent;
12 char *const paths[] = { (char *)path, NULL };
13
14 /*
15 * This means there can't be any autofs mounts yet, so
16 * this is the first time we're being run since a reboot.
17 * Clean out any stuff left in /Network from the reboot.
18 */
19 fts = fts_open(paths, FTS_NOCHDIR|FTS_PHYSICAL,
20 NULL);
21 if (fts != NULL) {
22 while ((ftsent = fts_read(fts)) != NULL) {
23 /*
24 * We only remove directories - if
25 * there are files, we assume they're
26 * there for a purpose.
27 *
28 * We remove directories after we've
29 * removed their children, so we want
30 * to process directories visited in
31 * post-order.
32 */
33 if (ftsent->fts_info == FTS_DP &&
34 ftsent->fts_level >= FTS_ROOTLEVEL + add_level)
35 rmdir(ftsent->fts_accpath);
36 }
37 fts_close(fts);
38 }
39 }
e827904 @poelzi fix endless recrusion, timer wrapper, invalid iterator
authored
40
41
42 void u_timer_start(struct u_timer *t) {
43 if(!t->count) {
44 g_timer_continue(t->timer);
45 };
46 t->count++;
47 }
48
49 void u_timer_stop(struct u_timer *t) {
50 t->count--;
51 g_assert(t->count >= 0);
52 if(!t->count) {
53 g_timer_stop(t->timer);
54 };
55 }
56
57 void u_timer_stop_clear(struct u_timer *t) {
58 g_timer_start(t->timer);
59 g_timer_stop(t->timer);
60 }
Something went wrong with that request. Please try again.