diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2016-03-17 01:00:04 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2016-03-17 01:00:04 +0000 |
commit | 76bf614a1a7e81434bfa70b90e0d728a00478431 (patch) | |
tree | 0bf0987e4e5c2f9aa7806ce4ee085012ca4daee9 /src/libs6rc/s6rc_servicedir_unsupervise.c | |
parent | 3cf69b8cea7778196db5c2616c6e7d8c73fa62fa (diff) | |
download | s6-rc-76bf614a1a7e81434bfa70b90e0d728a00478431.tar.xz |
Add rollback to s6rc_servicedir_manage; it should now be transactional
Diffstat (limited to 'src/libs6rc/s6rc_servicedir_unsupervise.c')
-rw-r--r-- | src/libs6rc/s6rc_servicedir_unsupervise.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/libs6rc/s6rc_servicedir_unsupervise.c b/src/libs6rc/s6rc_servicedir_unsupervise.c new file mode 100644 index 0000000..14a1164 --- /dev/null +++ b/src/libs6rc/s6rc_servicedir_unsupervise.c @@ -0,0 +1,23 @@ +/* ISC license. */ + +#include <unistd.h> +#include <skalibs/bytestr.h> +#include <s6/s6-supervise.h> +#include <s6-rc/s6rc-servicedir.h> + +void s6rc_servicedir_unsupervise (char const *live, char const *name, int keepsupervisor) +{ + unsigned int namelen = str_len(name) ; + unsigned int livelen = str_len(live) ; + char fn[livelen + 14 + namelen] ; + byte_copy(fn, livelen, live) ; + byte_copy(fn + livelen, 9, "/scandir/") ; + byte_copy(fn + livelen + 9, namelen + 1, name) ; + unlink(fn) ; + if (!keepsupervisor) + { + byte_copy(fn + livelen + 1, 12, "servicedirs/") ; + byte_copy(fn + livelen + 13, namelen + 1, name) ; + s6_svc_writectl(fn, S6_SUPERVISE_CTLDIR, "x", 1) ; + } +} |