summaryrefslogtreecommitdiff
path: root/src/libs6rc/s6rc_servicedir_copy_offline.c
blob: b5175367141b5a8c60b0eabd9c9e3e01406b45ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* ISC license. */

#include <sys/stat.h>
#include <errno.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 ;
  mode_t m = umask(0) ;
  int r = mkdir(dst, 0755) ;
  umask(m) ;
  if (r < 0 && errno != EEXIST) return 0 ;
  for (; p->name ; p++)
    if (!s6rc_servicedir_copy_one(src, dst, p)) return 0 ;
  return 1 ;
}