summary refs log tree commit diff
path: root/debian/diff/readlink.diff
blob: a96b0009bab28232846864582273591e9a7b33ab (plain) (blame)
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
? ANN
? changeversion
? manpagehtml.diff
? runit-0.9.6.tar.gz
? debian/readlink.diff
? src/test
Index: src/runsv.c
===================================================================
RCS file: /var/lib/cvs/runit/src/runsv.c,v
retrieving revision 1.11
diff -u -r1.11 runsv.c
--- src/runsv.c	9 Mar 2003 14:05:49 -0000	1.11
+++ src/runsv.c	4 Sep 2003 09:43:32 -0000
@@ -318,6 +318,7 @@
 int main(int argc, char **argv) {
   struct stat s;
   int fd;
+  char buf[256];
 
   progname =argv[0];
   if (! argv[1] || argv[2]) usage();
@@ -367,7 +368,21 @@
     }
   }
 
-  mkdir("supervise", 0700);
+  if (mkdir("supervise", 0700) == -1) {
+    if ((fd =readlink("supervise", buf, 256)) != -1) {
+      if (fd == 256) {
+	errno =EOVERFLOW;
+	fatal("unable to readlink ./supervise");
+      }
+      buf[fd] =0;
+      mkdir(buf, 0700);
+    }
+    else {
+      if ((errno != ENOENT) && (errno != EINVAL))
+	fatal("unable to readlink ./supervise");
+    }
+  }
+  
   if ((svd[0].fdlock =open_append("supervise/lock")) == -1)
     fatal("unable to open lock");
   if (lock_exnb(svd[0].fdlock) == -1) fatal("unable to lock");