summaryrefslogtreecommitdiff
path: root/src/libs6rc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs6rc')
-rw-r--r--src/libs6rc/s6rc-servicedir-internal.h29
-rw-r--r--src/libs6rc/s6rc_servicedir_copy_offline.c4
-rw-r--r--src/libs6rc/s6rc_servicedir_copy_online.c9
-rw-r--r--src/libs6rc/s6rc_servicedir_internal.c52
4 files changed, 37 insertions, 57 deletions
diff --git a/src/libs6rc/s6rc-servicedir-internal.h b/src/libs6rc/s6rc-servicedir-internal.h
index a4af0b9..0c9c4d9 100644
--- a/src/libs6rc/s6rc-servicedir-internal.h
+++ b/src/libs6rc/s6rc-servicedir-internal.h
@@ -3,32 +3,9 @@
#ifndef S6RC_SERVICEDIR_INTERNAL_H
#define S6RC_SERVICEDIR_INTERNAL_H
-#include <sys/types.h>
+#include <s6/servicedir.h>
-typedef enum s6rc_filetype_e s6rc_filetype_t, *s6rc_filetype_t_ref ;
-enum s6rc_filetype_e
-{
- FILETYPE_NORMAL,
- FILETYPE_EMPTY,
- FILETYPE_UINT,
- FILETYPE_DIR
-} ;
-
-#define SVFILE_EXECUTABLE 0x01
-#define SVFILE_MANDATORY 0x02
-#define SVFILE_ATOMIC 0x04
-
-typedef struct s6rc_servicedir_desc_s s6rc_servicedir_desc_t, *s6rc_servicedir_desc_t_ref ;
-struct s6rc_servicedir_desc_s
-{
- char const *name ;
- s6rc_filetype_t type ;
- unsigned char options ;
-} ;
-
-extern s6rc_servicedir_desc_t const *s6rc_servicedir_file_list ;
-extern size_t const s6rc_servicedir_file_maxlen ;
-
-extern int s6rc_servicedir_copy_one (char const *, char const *, s6rc_servicedir_desc_t const *) ;
+extern int s6rc_servicedir_copy_one (char const *, char const *, s6_servicedir_desc const *) ;
+extern s6_servicedir_desc const *const s6rc_servicedir_file_list ;
#endif
diff --git a/src/libs6rc/s6rc_servicedir_copy_offline.c b/src/libs6rc/s6rc_servicedir_copy_offline.c
index b517536..a4f76f0 100644
--- a/src/libs6rc/s6rc_servicedir_copy_offline.c
+++ b/src/libs6rc/s6rc_servicedir_copy_offline.c
@@ -3,12 +3,14 @@
#include <sys/stat.h>
#include <errno.h>
+#include <s6/servicedir.h>
+
#include "s6rc-servicedir-internal.h"
#include <s6-rc/s6rc-servicedir.h>
int s6rc_servicedir_copy_offline (char const *src, char const *dst)
{
- s6rc_servicedir_desc_t const *p = s6rc_servicedir_file_list ;
+ s6_servicedir_desc const *p = s6rc_servicedir_file_list ;
mode_t m = umask(0) ;
int r = mkdir(dst, 0755) ;
umask(m) ;
diff --git a/src/libs6rc/s6rc_servicedir_copy_online.c b/src/libs6rc/s6rc_servicedir_copy_online.c
index 5e84079..62d7c87 100644
--- a/src/libs6rc/s6rc_servicedir_copy_online.c
+++ b/src/libs6rc/s6rc_servicedir_copy_online.c
@@ -7,6 +7,7 @@
#include <stdio.h>
#include <skalibs/djbunix.h>
+#include <s6/servicedir.h>
#include <s6-rc/s6rc-utils.h>
#include "s6rc-servicedir-internal.h"
@@ -20,9 +21,9 @@ int s6rc_servicedir_copy_online (char const *src, char const *dst)
unsigned int i = 0 ;
int wantup = 0 ;
int e ;
- char srcfn[srclen + s6rc_servicedir_file_maxlen + 6] ;
- char dstfn[dstlen + s6rc_servicedir_file_maxlen + 6] ;
- char oldfn[dstlen + s6rc_servicedir_file_maxlen + 6] ;
+ char srcfn[srclen + S6_SERVICEDIR_FILE_MAXLEN + 6] ;
+ char dstfn[dstlen + S6_SERVICEDIR_FILE_MAXLEN + 6] ;
+ char oldfn[dstlen + S6_SERVICEDIR_FILE_MAXLEN + 6] ;
memcpy(srcfn, src, srclen) ;
srcfn[srclen] = '/' ;
memcpy(dstfn, dst, dstlen + 1) ;
@@ -45,7 +46,7 @@ int s6rc_servicedir_copy_online (char const *src, char const *dst)
strcpy(dstfn + dstlen + 1, s6rc_servicedir_file_list[i].name) ;
strcpy(oldfn + dstlen + 5, s6rc_servicedir_file_list[i].name) ;
if (rename(dstfn, oldfn) < 0
- && (errno != ENOENT || s6rc_servicedir_file_list[i].options & SVFILE_MANDATORY))
+ && (errno != ENOENT || s6rc_servicedir_file_list[i].options & S6_SVFILE_MANDATORY))
{
e = errno ;
goto errrename ;
diff --git a/src/libs6rc/s6rc_servicedir_internal.c b/src/libs6rc/s6rc_servicedir_internal.c
index ba7e6b9..dfc0a44 100644
--- a/src/libs6rc/s6rc_servicedir_internal.c
+++ b/src/libs6rc/s6rc_servicedir_internal.c
@@ -7,31 +7,31 @@
#include <skalibs/posixplz.h>
#include <skalibs/types.h>
#include <skalibs/djbunix.h>
+#include <s6/servicedir.h>
#include <s6-rc/s6rc-utils.h>
#include "s6rc-servicedir-internal.h"
-static s6rc_servicedir_desc_t const svdir_file_list[] =
+static s6_servicedir_desc const svdir_file_list[] =
{
- { .name = "finish", .type = FILETYPE_NORMAL, .options = SVFILE_EXECUTABLE | SVFILE_ATOMIC },
- { .name = "finish.user", .type = FILETYPE_NORMAL, .options = SVFILE_EXECUTABLE },
- { .name = "run", .type = FILETYPE_NORMAL, .options = SVFILE_EXECUTABLE | SVFILE_MANDATORY | SVFILE_ATOMIC },
- { .name = "run.user", .type = FILETYPE_NORMAL, .options = SVFILE_EXECUTABLE },
- { .name = "notification-fd", .type = FILETYPE_UINT, .options = 0 },
- { .name = "lock-fd", .type = FILETYPE_UINT, .options = 0 },
- { .name = "timeout-kill", .type = FILETYPE_UINT, .options = 0 },
- { .name = "timeout-finish", .type = FILETYPE_UINT, .options = 0 },
- { .name = "max-death-tally", .type = FILETYPE_UINT, .options = 0 },
- { .name = "down-signal", .type = FILETYPE_NORMAL, .options = 0 },
- { .name = "data", .type = FILETYPE_DIR, .options = 0 },
- { .name = "env", .type = FILETYPE_DIR, .options = 0 },
+ { .name = "finish", .type = S6_FILETYPE_NORMAL, .options = S6_SVFILE_EXECUTABLE | S6_SVFILE_ATOMIC },
+ { .name = "finish.user", .type = S6_FILETYPE_NORMAL, .options = S6_SVFILE_EXECUTABLE },
+ { .name = "run", .type = S6_FILETYPE_NORMAL, .options = S6_SVFILE_EXECUTABLE | S6_SVFILE_MANDATORY | S6_SVFILE_ATOMIC },
+ { .name = "run.user", .type = S6_FILETYPE_NORMAL, .options = S6_SVFILE_EXECUTABLE },
+ { .name = "notification-fd", .type = S6_FILETYPE_UINT, .options = 0 },
+ { .name = "lock-fd", .type = S6_FILETYPE_UINT, .options = 0 },
+ { .name = "timeout-kill", .type = S6_FILETYPE_UINT, .options = 0 },
+ { .name = "timeout-finish", .type = S6_FILETYPE_UINT, .options = 0 },
+ { .name = "max-death-tally", .type = S6_FILETYPE_UINT, .options = 0 },
+ { .name = "down-signal", .type = S6_FILETYPE_NORMAL, .options = 0 },
+ { .name = "data", .type = S6_FILETYPE_DIR, .options = 0 },
+ { .name = "env", .type = S6_FILETYPE_DIR, .options = 0 },
{ .name = 0, .options = 0 }
} ;
-s6rc_servicedir_desc_t const *s6rc_servicedir_file_list = svdir_file_list ;
-size_t const s6rc_servicedir_file_maxlen = 16 ;
+s6_servicedir_desc const *const s6rc_servicedir_file_list = svdir_file_list ;
-int s6rc_servicedir_copy_one (char const *src, char const *dst, s6rc_servicedir_desc_t const *p)
+int s6rc_servicedir_copy_one (char const *src, char const *dst, s6_servicedir_desc const *p)
{
size_t srclen = strlen(src) ;
size_t dstlen = strlen(dst) ;
@@ -47,27 +47,27 @@ int s6rc_servicedir_copy_one (char const *src, char const *dst, s6rc_servicedir_
switch (p->type)
{
- case FILETYPE_NORMAL :
+ case S6_FILETYPE_NORMAL :
{
- unsigned int mode = p->options & SVFILE_EXECUTABLE ? 0755 : 0644 ;
- if (!(p->options & SVFILE_ATOMIC ? filecopy_suffix(srcfn, dstfn, mode, ".new") : filecopy_unsafe(srcfn, dstfn, mode)))
+ unsigned int mode = p->options & S6_SVFILE_EXECUTABLE ? 0755 : 0644 ;
+ if (!(p->options & S6_SVFILE_ATOMIC ? filecopy_suffix(srcfn, dstfn, mode, ".new") : filecopy_unsafe(srcfn, dstfn, mode)))
{
- if (errno != ENOENT || p->options & SVFILE_MANDATORY) return 0 ;
+ if (errno != ENOENT || p->options & S6_SVFILE_MANDATORY) return 0 ;
}
break ;
}
- case FILETYPE_EMPTY :
+ case S6_FILETYPE_EMPTY :
if (access(srcfn, F_OK) < 0)
{
- if (errno != ENOENT || p->options & SVFILE_MANDATORY) return 0 ;
+ if (errno != ENOENT || p->options & S6_SVFILE_MANDATORY) return 0 ;
}
else if (!touch(dstfn)) return 0 ;
break ;
- case FILETYPE_UINT :
+ case S6_FILETYPE_UINT :
{
unsigned int u ;
int r = s6rc_read_uint(srcfn, &u) ;
- if (r < 0 || (!r && p->options & SVFILE_MANDATORY)) return 0 ;
+ if (r < 0 || (!r && p->options & S6_SVFILE_MANDATORY)) return 0 ;
if (r)
{
char fmt[UINT_FMT] ;
@@ -77,10 +77,10 @@ int s6rc_servicedir_copy_one (char const *src, char const *dst, s6rc_servicedir_
}
break ;
}
- case FILETYPE_DIR :
+ case S6_FILETYPE_DIR :
if (!hiercopy(srcfn, dstfn))
{
- if (errno != ENOENT || p->options & SVFILE_MANDATORY) return 0 ;
+ if (errno != ENOENT || p->options & S6_SVFILE_MANDATORY) return 0 ;
}
break ;
default : return (errno = EDOM, 0) ;