blob: 069ed78783f2ec03905c04b9388135bea0620d57 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
/* ISC license. */
#include <string.h>
#include <errno.h>
#include <skalibs/direntry.h>
#include <skalibs/strerr.h>
#include <s6-rc/repo.h>
int s6rc_repo_touch (char const *repo)
{
DIR *dir ;
size_t repolen = strlen(repo) ;
char sources[repolen + 9] ;
memcpy(sources, repo, repolen) ;
memcpy(sources + repolen, "/sources", 9) ;
dir = opendir(sources) ;
if (!dir)
{
strerr_warnfu2sys("opendir ", sources) ;
return 0 ;
}
for (;;)
{
direntry *d ;
errno = 0 ;
d = readdir(dir) ;
if (!d) break ;
if (d->d_name[0] == '.') continue ;
if (!s6rc_repo_touchset(repo, d->d_name))
{
dir_close(dir) ;
return 0 ;
}
}
dir_close(dir) ;
if (errno)
{
strerr_warnfu2sys("readdir ", sources) ;
return 0 ;
}
return 1 ;
}
|