summaryrefslogtreecommitdiff
path: root/net-misc/clockspeed/files/clockspeed-0.62-gentoo.patch
blob: 59c9dfcbf4ec2da216c285c00b0ad32590f443c8 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
--- clockspeed-0.62/INSTALL
+++ clockspeed-0.62/INSTALL
@@ -4,8 +4,8 @@
 
 Things you have to decide before starting:
 
-* Where the clockspeed package will be installed, normally
-/usr/local/clockspeed. To change this directory, edit conf-home now.
+* Where the clockspeed package will be installed, normally /usr. 
+To change this directory, edit conf-home now.
 
 
 How to install:
@@ -16,9 +16,9 @@
     or with gethrtime(). The compiler must support a 64-bit type, either
     long or long long.
 
- 2. Install the programs, the man pages, and /etc/leapsecs.dat:
+ 2. Install the programs, the man pages, and /var/lib/clockspeed/leapsecs.dat:
        # make setup check
-    Put /usr/local/clockspeed/bin into $PATH.
+    Put /usr/bin into $PATH.
 
 
 How to test:
@@ -39,20 +39,20 @@
  5. Start clockspeed:
        # clockspeed &
     Give clockspeed a time measurement:
-       # sntpclock 1.2.3.4 > /usr/local/clockspeed/adjust &
+       # sntpclock 1.2.3.4 > /var/lib/clockspeed/adjust &
 
  6. After a few hours, give clockspeed a second time measurement:
-       # sntpclock 1.2.3.4 > /usr/local/clockspeed/adjust &
+       # sntpclock 1.2.3.4 > /var/lib/clockspeed/adjust &
     You can run sntpclock as a non-root user, if you change
-    /usr/local/clockspeed/adjust to be owned by that user. I recommend
+    /var/lib/clockspeed/adjust to be owned by that user. I recommend
     this for security.
 
  7. After a few days, check how well clockspeed has adjusted your clock:
        % sntpclock 1.2.3.4 | clockview
     Check how many attoseconds clockspeed thinks are in one tick:
-       % clockview < /usr/local/clockspeed/etc/atto
+       % clockview < /var/lib/clockspeed/atto
     Give it another time measurement:
-       # sntpclock 1.2.3.4 > /usr/local/clockspeed/adjust &
+       # sntpclock 1.2.3.4 > /var/lib/clockspeed/adjust &
 
  8. Repeat step 7 after a few weeks, then after a few months. Your clock
     should now be synchronized to the remote clock to within a few
@@ -70,7 +70,7 @@
     Here 5.6.7.8 is the master's IP address. Set the client's clock:
        # clockadd < adjustment
     Finally, run clockspeed as in step 5, and do
-       % taiclock 5.6.7.8 > /usr/local/clockspeed/adjust &
+       % taiclock 5.6.7.8 > /var/lib/clockspeed/adjust &
     after a few days.
 
 
--- clockspeed-0.62/Makefile
+++ clockspeed-0.62/Makefile
@@ -7,8 +7,8 @@
 auto-ccld.sh: \
 conf-cc conf-ld warn-auto.sh
 	( cat warn-auto.sh; \
-	echo CC=\'`head -1 conf-cc`\'; \
-	echo LD=\'`head -1 conf-ld`\' \
+	echo CC=\'`head -n 1 conf-cc`\'; \
+	echo LD=\'`head -n 1 conf-ld`\' \
 	) > auto-ccld.sh
 
 auto-str: \
@@ -21,7 +21,7 @@
 
 auto_home.c: \
 auto-str conf-home
-	./auto-str auto_home `head -1 conf-home` > auto_home.c
+	./auto-str auto_home `head -n 1 conf-home` > auto_home.c
 
 auto_home.o: \
 compile auto_home.c
--- clockspeed-0.62/clockspeed.1
+++ clockspeed-0.62/clockspeed.1
@@ -12,7 +12,7 @@
 
 .B clockspeed
 reads the real-time measurements from
-.BR /usr/local/clockspeed/adjust .
+.BR /var/lib/clockspeed/adjust .
 Each real-time measurement must be a single 16-byte packet,
 expressed as a TAI64NA time adjustment to the local UNIX clock.
 
@@ -24,12 +24,12 @@
 .B clockspeed
 can figure out the number of real attoseconds per tick.
 It saves this number in TAI64NA format in
-.BR /usr/local/clockspeed/etc/atto ,
+.BR /var/lib/clockspeed/atto ,
 overwriting
-.B /usr/local/clockspeed/etc/atto.tmp
+.B /var/lib/clockspeed/atto.tmp
 for reliability.
 It reads
-.B /usr/local/clockspeed/etc/atto
+.B /var/lib/clockspeed/atto
 when it starts up again.
 
 .B clockspeed
--- clockspeed-0.62/clockspeed.c
+++ clockspeed-0.62/clockspeed.c
@@ -83,7 +83,7 @@
   if (deriv <= 0) return;
   if (deriv > 200000000) return; /* 5Hz ticks? be serious */
 
-  fd = open_trunc("etc/atto.tmp");
+  fd = open_trunc("/var/lib/clockspeed/atto.tmp");
   if (fd == -1) return;
 
   buf[0] = 0;
@@ -119,7 +119,7 @@
   if (fsync(fd) == -1) { close(fd); return; }
   if (close(fd) == -1) return; /* NFS stupidity */
 
-  rename("etc/atto.tmp","etc/atto"); /* if it fails, bummer */
+  rename("/var/lib/clockspeed/atto.tmp","/var/lib/clockspeed/atto"); /* if it fails, bummer */
 }
 
 void main()
@@ -136,16 +136,16 @@
   if (chdir(auto_home) == -1) _exit(1);
   umask(033);
 
-  if (open_read("etc/atto") == 0) {
+  if (open_read("/var/lib/clockspeed/atto") == 0) {
     r = read(0,buf,sizeof buf);
     if (r == sizeof buf)
       deriv = nano(buf);
     close(0);
   }
 
-  if (fifo_make("adjust",0600) == -1) if (errno != error_exist) _exit(1);
-  if (open_read("adjust") != 0) _exit(1);
-  if (open_write("adjust") == -1) _exit(1);
+  if (fifo_make("/var/lib/clockspeed/adjust",0600) == -1) if (errno != error_exist) _exit(1);
+  if (open_read("/var/lib/clockspeed/adjust") != 0) _exit(1);
+  if (open_write("/var/lib/clockspeed/adjust") == -1) _exit(1);
 
   now(&first);
 
--- clockspeed-0.62/clockview.c
+++ clockspeed-0.62/clockview.c
@@ -1,5 +1,5 @@
 #include <sys/types.h>
-#include <sys/time.h>
+#include <time.h>
 #include "substdio.h"
 #include "readwrite.h"
 #include "strerr.h"
--- clockspeed-0.62/conf-home
+++ clockspeed-0.62/conf-home
@@ -1,4 +1,4 @@
-/usr/local/clockspeed
+/usr
 
 This is the clockspeed home directory. Programs will be installed in
 .../bin.
--- clockspeed-0.62/error.h
+++ clockspeed-0.62/error.h
@@ -1,7 +1,7 @@
 #ifndef ERROR_H
 #define ERROR_H
 
-extern int errno;
+#include <errno.h>
 
 extern int error_intr;
 extern int error_nomem;
--- clockspeed-0.62/hier.c
+++ clockspeed-0.62/hier.c
@@ -2,7 +2,9 @@
 
 void hier()
 {
-  c("/","etc","leapsecs.dat",-1,-1,0644);
+  d("/var/lib","clockspeed",-1,-1,0755);
+  
+  c("/","var/lib/clockspeed","leapsecs.dat",-1,-1,0644);
 
   h(auto_home,-1,-1,0755);
 
--- clockspeed-0.62/leapsecs.3
+++ clockspeed-0.62/leapsecs.3
@@ -52,10 +52,10 @@
 
 .B leapsecs_read
 reads the leap-second table from
-.BR /etc/leapsecs.dat .
+.BR /var/lib/clockspeed/leapsecs.dat .
 It returns 0 on success, -1 on error.
 If
-.B /etc/leapsecs.dat
+.B /var/lib/clockspeed/leapsecs.dat
 does not exist,
 .B leapsecs_read
 treats it as an empty file.
--- clockspeed-0.62/leapsecs_read.c
+++ clockspeed-0.62/leapsecs_read.c
@@ -2,7 +2,6 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <errno.h>
-extern int errno;
 #include "tai.h"
 #include "leapsecs.h"
 
@@ -18,7 +17,7 @@
   int i;
   struct tai u;
 
-  fd = open("/etc/leapsecs.dat",O_RDONLY | O_NDELAY);
+  fd = open("/var/lib/clockspeed/leapsecs.dat",O_RDONLY | O_NDELAY);
   if (fd == -1) {
     if (errno != ENOENT) return -1;
     if (leapsecs) free(leapsecs);