Skip to content

Commit 8be7a46

Browse files
authored
Merge pull request #439 from aanderse/tmpfiles
tmpfiles: refactor into separate executable
2 parents 051ef81 + 5993b4b commit 8be7a46

6 files changed

Lines changed: 315 additions & 215 deletions

File tree

plugins/bootmisc.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#include "finit.h"
3939
#include "helpers.h"
4040
#include "plugin.h"
41-
#include "tmpfiles.h"
4241
#include "util.h"
4342
#include "utmp-api.h"
4443

@@ -163,7 +162,7 @@ static void setup(void *arg)
163162
kernel_links();
164163

165164
/* Create all system tmpfiles.d(5) */
166-
tmpfilesd();
165+
run_interactive(_PATH_TMPFILES " --create", "Creating required directories and files");
167166

168167
/* Set BOOT_TIME UTMP entry */
169168
utmp_set_boot();

src/Makefile.am

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ AM_LDFLAGS = -export-dynamic
88
endif
99

1010
sbin_PROGRAMS = finit initctl
11-
pkglibexec_PROGRAMS = getty logit runparts
11+
pkglibexec_PROGRAMS = getty logit runparts tmpfiles
1212
if SULOGIN
1313
pkglibexec_PROGRAMS += sulogin
1414
endif
@@ -43,6 +43,13 @@ sulogin_SOURCES = sulogin.c
4343
sulogin_CFLAGS = -W -Wall -Wextra -std=gnu99
4444
sulogin_LDADD = -lcrypt
4545

46+
tmpfiles_SOURCES = tmpfiles.c helpers.c util.c exec.c log.c \
47+
svc.c sig.c sm.c api.c mount.c service.c schedule.c cond.c cond-w.c pid.c plugin.c \
48+
utmp-api.c client.c cgroup.c mdadm.c tty.c iwatch.c conf.c devmon.c logrotate.c
49+
tmpfiles_CFLAGS = -W -Wall -Wextra -std=gnu99 -D__FINIT__
50+
tmpfiles_CFLAGS += $(lite_CFLAGS) $(uev_CFLAGS)
51+
tmpfiles_LDADD = $(lite_LIBS) $(uev_LIBS)
52+
4653
logit_SOURCES = logit.c logrotate.c
4754
logit_CFLAGS = -W -Wall -Wextra -Wno-unused-parameter -std=gnu99
4855
logit_CFLAGS += $(lite_CFLAGS)
@@ -66,7 +73,6 @@ finit_SOURCES = api.c cgroup.c cgroup.h \
6673
sig.c sig.h \
6774
sm.c sm.h \
6875
svc.c svc.h \
69-
tmpfiles.c tmpfiles.h \
7076
tty.c tty.h \
7177
util.c util.h \
7278
utmp-api.c utmp-api.h

src/finit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#define _PATH_RUNPARTS FINIT_EXECPATH_ "/runparts"
6060
#define _PATH_SULOGIN FINIT_EXECPATH_ "/sulogin"
6161
#define _PATH_GETTY FINIT_EXECPATH_ "/getty"
62+
#define _PATH_TMPFILES FINIT_EXECPATH_ "/tmpfiles"
6263

6364
#define CMD_SIZE 1024
6465
#define LINE_SIZE 1024

src/helpers.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#define FINIT_HELPERS_H_
2727

2828
#include <ctype.h>
29+
#include <dirent.h>
2930
#include <fcntl.h>
3031
#include <stdarg.h>
3132
#include <stdlib.h>
@@ -206,6 +207,22 @@ static inline char *fgetval(const char *line, const char *key, char *sep)
206207
return realloc(copy, len);
207208
}
208209

210+
static inline int is_dir_empty(const char *path)
211+
{
212+
struct dirent **namelist;
213+
int num;
214+
215+
num = scandir(path, &namelist, NULL, NULL);
216+
if (num < 0)
217+
return 0;
218+
219+
for (int i = 0; i < num; i++)
220+
free(namelist[i]);
221+
free(namelist);
222+
223+
return num >= 3;
224+
}
225+
209226
#endif /* FINIT_HELPERS_H_ */
210227

211228
/**

0 commit comments

Comments
 (0)