FullFilesystemSanityGutsy
Attachment 'glibc.patch'
Download 1 diff --exclude='*~' -ruN orig/glibc-2.5/debian/patches/any/local-enospck.diff glibc-2.5/debian/patches/any/local-enospck.diff
2 --- orig/glibc-2.5/debian/patches/any/local-enospck.diff 1970-01-01 01:00:00.000000000 +0100
3 +++ glibc-2.5/debian/patches/any/local-enospck.diff 2007-06-15 17:46:56.000000000 +0100
4 @@ -0,0 +1,371 @@
5 +--- /dev/null 2006-10-18 16:35:35.000000000 +0100
6 ++++ ./glibc-2.5/sysdeps/unix/enospck.c 2007-06-15 17:22:31.000000000 +0100
7 +@@ -0,0 +1,275 @@
8 ++
9 ++#define __libc_open __enospck_aside___libc_open
10 ++#define __open __enospck_aside___open
11 ++#define open __enospck_aside_open
12 ++#define __libc_open64 __enospck_aside___libc_open64
13 ++#define __open64 __enospck_aside___open64
14 ++#define open64 __enospck_aside_open64
15 ++#define __libc_write __enospck_aside___libc_write
16 ++#define __write __enospck_aside___write
17 ++#define write __enospck_aside_write
18 ++
19 ++#include <stdlib.h>
20 ++#include <unistd.h>
21 ++#include <string.h>
22 ++#include <limits.h>
23 ++#include <stdio.h>
24 ++#include <sys/uio.h>
25 ++#include <stdarg.h>
26 ++#include <errno.h>
27 ++#include <fcntl.h>
28 ++
29 ++#undef __libc_open
30 ++#undef __open
31 ++#undef open
32 ++#undef __libc_open64
33 ++#undef __open64
34 ++#undef open64
35 ++#undef __libc_write
36 ++#undef __write
37 ++#undef write
38 ++
39 ++#define SOMECALL(syscallname, rtype, argprotos, argnames, xinfos) \
40 ++ extern rtype __enospck_real_##syscallname(argprotos); \
41 ++ rtype __enospck_wrap_##syscallname(argprotos) { \
42 ++ rtype r= __enospck_real_##syscallname(argnames); \
43 ++ if (r>=0) return r; \
44 ++ __enospck_check(#syscallname xinfos, (void(*)(void))0); \
45 ++ return r; \
46 ++ }
47 ++
48 ++#define COMMA ,
49 ++#define XI(kind,val) , __enospck_format_##kind, (const void*)&(val)
50 ++
51 ++typedef void xifmter(char **bp, const void *val);
52 ++void __enospck_check(const char *syscallname, ...);
53 ++
54 ++static void p_string(char **bp, const char *ip) {
55 ++ int c;
56 ++ while ((c= *ip++)) *(*bp)++= c;
57 ++}
58 ++static void p_integer(char **obp, unsigned long ul, int base) {
59 ++ char buf[sizeof(ul) * 2 + 1], *bp;
60 ++ const char hex[16]= "0123456789abcdef";
61 ++
62 ++ bp= buf;
63 ++ while (ul) {
64 ++ if (base==16) {
65 ++ *bp++= hex[ul & 0x0fUL];
66 ++ ul >>= 4;
67 ++ } else {
68 ++ *bp++= hex[ul % base];
69 ++ ul /= base;
70 ++ }
71 ++ }
72 ++ while (bp > buf) {
73 ++ *(*obp)++= *--bp;
74 ++ }
75 ++}
76 ++
77 ++static void __enospck_format_str(char **bp, const void *val) {
78 ++ const char *str= val;
79 ++ int i= 400;
80 ++ int c;
81 ++ p_string(bp,"`");
82 ++ while ((c= *str++)) {
83 ++ if (!--i) { bp-=2; p_string(bp, "'.."); break; }
84 ++ *(*bp)++= c;
85 ++ }
86 ++ p_string(bp,"'");
87 ++}
88 ++
89 ++static void __enospck_format_fd(char **bp, const void *val) {
90 ++ int fd= *(const int*)val;
91 ++ struct stat stab;
92 ++ int r;
93 ++ char psb[100], *psb_bp;
94 ++ char readlink_buf[PATH_MAX];
95 ++
96 ++ p_string(bp,"fd");
97 ++ p_integer(bp,fd,10);
98 ++ r= __fstat(fd, &stab);
99 ++ if (r) {
100 ++ p_string(bp,"!fstat=");
101 ++ p_integer(bp,errno,10);
102 ++ p_string(bp,"!");
103 ++ } else {
104 ++ p_string(bp,"=[");
105 ++ p_integer(bp,stab.st_dev,16);
106 ++ p_string(bp,":");
107 ++ p_integer(bp,stab.st_ino,10);
108 ++ p_string(bp,"]");
109 ++ }
110 ++ psb_bp= psb;
111 ++ p_string(&psb_bp, "/proc/self/fd/");
112 ++ p_integer(&psb_bp,fd,10);
113 ++ *psb_bp++= 0;
114 ++
115 ++ r= __readlink(psb, readlink_buf, sizeof(readlink_buf));
116 ++ if (r<0) {
117 ++ p_string(bp,"!readlink=");
118 ++ p_integer(bp,errno,10);
119 ++ p_string(bp,"!");
120 ++ } else {
121 ++ p_string(bp,"=`");
122 ++ if (r == sizeof(readlink_buf)) {
123 ++ readlink_buf[sizeof(readlink_buf)-2]= 0;
124 ++ p_string(bp,readlink_buf);
125 ++ p_string(bp,"'..");
126 ++ } else {
127 ++ readlink_buf[r]= 0;
128 ++ p_string(bp,readlink_buf);
129 ++ p_string(bp,"'");
130 ++ }
131 ++ }
132 ++}
133 ++
134 ++#define SA(t,x) \
135 ++ strong_alias(t, x) \
136 ++ strong_alias(t, __GI_##x)
137 ++
138 ++#define WA(t,x) \
139 ++ weak_alias(t, x) \
140 ++ weak_alias(t, __GI_##x)
141 ++
142 ++SOMECALL(mkdir, int,
143 ++ const char *path COMMA mode_t mode,
144 ++ path COMMA mode,
145 ++ XI(str,*path))
146 ++SA(__enospck_wrap_mkdir, __mkdir)
147 ++WA(__enospck_wrap_mkdir, mkdir)
148 ++
149 ++SOMECALL(link, int,
150 ++ const char *oldpath COMMA const char *newpath,
151 ++ oldpath COMMA newpath,
152 ++ XI(str,*newpath))
153 ++SA(__enospck_wrap_link, __link)
154 ++WA(__enospck_wrap_link, link)
155 ++
156 ++#define SOMEOPEN(callname) \
157 ++SOMECALL(callname, int, \
158 ++ const char *path COMMA int flags COMMA mode_t mode, \
159 ++ path COMMA flags COMMA mode, \
160 ++ XI(str,*path)) \
161 ++int __enospck_wrapv_##callname(const char *path, int flags, ...) { \
162 ++ mode_t mode; \
163 ++ va_list al; \
164 ++ if (flags & O_CREAT) { \
165 ++ va_start(al,flags); \
166 ++ mode= va_arg(al,mode_t); \
167 ++ va_end(al); \
168 ++ } else { \
169 ++ mode= 0; \
170 ++ } \
171 ++ return __enospck_wrap_##callname(path,flags,mode); \
172 ++} \
173 ++
174 ++SOMEOPEN(open)
175 ++SA(__enospck_wrapv_open, __libc_open)
176 ++WA(__enospck_wrapv_open, __open)
177 ++WA(__enospck_wrapv_open, open)
178 ++
179 ++SOMEOPEN(open64)
180 ++WA(__enospck_wrapv_open64, __open64)
181 ++libc_hidden_weak (__open64)
182 ++WA(__enospck_wrapv_open64, open64)
183 ++
184 ++SOMECALL(symlink, int,
185 ++ const char *oldpath COMMA const char *newpath,
186 ++ oldpath COMMA newpath,
187 ++ XI(str,*oldpath) XI(str,*newpath))
188 ++SA(__enospck_wrap_symlink, __symlink)
189 ++WA(__enospck_wrap_symlink, symlink)
190 ++
191 ++SOMECALL(write, ssize_t,
192 ++ int fd COMMA const void *buf COMMA size_t count,
193 ++ fd COMMA buf COMMA count,
194 ++ XI(fd,fd))
195 ++SA(__enospck_wrap_write, __libc_write)
196 ++WA(__enospck_wrap_write, __write)
197 ++WA(__enospck_wrap_write,write)
198 ++
199 ++SOMECALL(writev, ssize_t,
200 ++ int fd COMMA const struct iovec *vector COMMA int count,
201 ++ fd COMMA vector COMMA count,
202 ++ XI(fd,fd))
203 ++SA(__enospck_wrap_writev, __writev)
204 ++WA(__enospck_wrap_writev, writev)
205 ++
206 ++static void p_procselfstat(char **bp) {
207 ++ int fd, r;
208 ++ char selfstat[200], *p1, *p2;
209 ++
210 ++ fd= __enospck_real_open("/proc/self/stat", O_RDONLY, 0);
211 ++ if (fd<0) goto err;
212 ++ r= read(fd, selfstat, sizeof(selfstat)-1);
213 ++ if (r<0) goto err;
214 ++
215 ++ close(fd); fd= -1;
216 ++
217 ++ for (p1=selfstat; p1 < selfstat+r; p1++)
218 ++ if (*p1 == '(') goto p1_found;
219 ++ goto fmt;
220 ++p1_found:
221 ++
222 ++ for (p2=selfstat+r; p2 > selfstat; )
223 ++ if (*--p2 == ')') goto p2_found;
224 ++ goto fmt;
225 ++p2_found:
226 ++
227 ++ *++p2= 0;
228 ++ p_string(bp,p1);
229 ++ return;
230 ++
231 ++fmt:
232 ++ p_string(bp,"!selfstatfmt");
233 ++ goto clean;
234 ++
235 ++err:
236 ++ p_string(bp,"!selfstat=");
237 ++ p_integer(bp,errno,10);
238 ++
239 ++clean:
240 ++ p_string(bp,"!");
241 ++ if (fd>=0) close(fd);
242 ++}
243 ++
244 ++void __enospck_check(const char *syscallname, ...) {
245 ++ int fd;
246 ++
247 ++ if (errno!=ENOSPC) return;
248 ++
249 ++ fd= __enospck_real_open("/etc/enospck.log", O_WRONLY|O_APPEND, 0);
250 ++ if (fd!=-1) {
251 ++ char buf[2048], *bp;
252 ++ pid_t pid;
253 ++ xifmter *fmt;
254 ++ const void *xv;
255 ++ int l;
256 ++ va_list al;
257 ++
258 ++ va_start(al, syscallname);
259 ++ bp= buf;
260 ++ pid= getpid();
261 ++ p_string(&bp,"[");
262 ++ p_integer(&bp,pid,10);
263 ++ p_procselfstat(&bp);
264 ++ p_string(&bp,"] ");
265 ++ p_string(&bp,syscallname);
266 ++ for (;;) {
267 ++ fmt= va_arg(al, xifmter*);
268 ++ if (!fmt) break;
269 ++
270 ++ xv= va_arg(al, const void*);
271 ++ p_string(&bp," ");
272 ++ fmt(&bp, xv);
273 ++ }
274 ++ va_end(al);
275 ++ p_string(&bp,"\n");
276 ++ l= bp - buf;
277 ++
278 ++ __enospck_real_write(fd, buf, l);
279 ++ close(fd);
280 ++ }
281 ++ errno= ENOSPC;
282 ++}
283 +--- ./glibc-2.5/sysdeps/unix/syscalls.list~ 2003-07-27 19:24:21.000000000 +0100
284 ++++ ./glibc-2.5/sysdeps/unix/syscalls.list 2007-06-13 15:55:37.000000000 +0100
285 +@@ -23,10 +23,10 @@
286 + getuid - getuid Ei: __getuid getuid
287 + ioctl - ioctl i:iiI __ioctl ioctl
288 + kill - kill i:ii __kill kill
289 +-link - link i:ss __link link
290 ++link - link i:ss __enospck_real_link
291 + lseek - lseek i:iii __libc_lseek __lseek lseek
292 +-mkdir - mkdir i:si __mkdir mkdir
293 +-open - open Ci:siv __libc_open __open open
294 ++mkdir - mkdir i:si __enospck_real_mkdir
295 ++open - open Ci:siv __enospck_real_open
296 + profil - profil i:piii __profil profil
297 + ptrace - ptrace i:iiii ptrace
298 + read - read Ci:ibn __libc_read __read read
299 +@@ -52,7 +52,7 @@
300 + statfs - statfs i:sp __statfs statfs
301 + swapoff - swapoff i:s swapoff
302 + swapon - swapon i:s swapon
303 +-symlink - symlink i:ss __symlink symlink
304 ++symlink - symlink i:ss __enospck_real_symlink
305 + sync - sync i: sync
306 + sys_fstat fxstat fstat i:ip __syscall_fstat
307 + sys_mknod xmknod mknod i:sii __syscall_mknod
308 +@@ -61,5 +61,5 @@
309 + uname - uname i:p __uname uname
310 + unlink - unlink i:s __unlink unlink
311 + utimes - utimes i:sp __utimes utimes
312 +-write - write Ci:ibn __libc_write __write write
313 +-writev - writev Ci:ipi __writev writev
314 ++write - write Ci:ibn __enospck_real_write
315 ++writev - writev Ci:ipi __enospck_real_writev
316 +--- ./glibc-2.5/sysdeps/unix/sysv/linux/writev.c~ 2003-09-03 04:21:26.000000000 +0100
317 ++++ ./glibc-2.5/sysdeps/unix/sysv/linux/writev.c 2007-06-13 14:36:58.000000000 +0100
318 +@@ -52,7 +52,7 @@
319 + }
320 +
321 + ssize_t
322 +-__libc_writev (fd, vector, count)
323 ++__enospck_real_writev (fd, vector, count)
324 + int fd;
325 + const struct iovec *vector;
326 + int count;
327 +@@ -68,8 +68,6 @@
328 +
329 + return result;
330 + }
331 +-strong_alias (__libc_writev, __writev)
332 +-weak_alias (__libc_writev, writev)
333 +
334 + #define __libc_writev static internal_function __atomic_writev_replacement
335 + #include <sysdeps/posix/writev.c>
336 +--- ./glibc-2.5/sysdeps/unix/Makefile~ 2006-02-28 07:05:40.000000000 +0000
337 ++++ ./glibc-2.5/sysdeps/unix/Makefile 2007-06-13 15:49:01.000000000 +0100
338 +@@ -264,6 +264,7 @@
339 +
340 + ifeq (misc,$(subdir))
341 + sysdep_routines += $(unix-extra-syscalls)
342 ++sysdep_routines += enospck
343 +
344 + ifdef unix-stub-syscalls
345 + # The system call entry points in this list are supposed to be additional
346 +--- ./glibc-2.5/sysdeps/unix/sysv/linux/open64.c~ 2002-12-15 10:22:52.000000000 +0000
347 ++++ ./glibc-2.5/sysdeps/unix/sysv/linux/open64.c 2007-06-14 19:11:19.000000000 +0100
348 +@@ -25,7 +25,7 @@
349 + /* Open FILE with access OFLAG. If OFLAG includes O_CREAT,
350 + a third argument is the file protection. */
351 + int
352 +-__libc_open64 (const char *file, int oflag, ...)
353 ++__enospck_real_open64 (const char *file, int oflag, ...)
354 + {
355 + int mode = 0;
356 +
357 +@@ -48,6 +48,3 @@
358 +
359 + return result;
360 + }
361 +-weak_alias (__libc_open64, BP_SYM (__open64))
362 +-libc_hidden_weak (BP_SYM (__open64))
363 +-weak_alias (__libc_open64, BP_SYM (open64))
364 +--- ./glibc-2.5/misc/Versions~ 2005-11-11 18:58:19.000000000 +0000
365 ++++ ./glibc-2.5/misc/Versions 2007-06-14 20:24:38.000000000 +0100
366 +@@ -134,4 +134,8 @@
367 + futimesat;
368 + __syslog_chk; __vsyslog_chk;
369 + }
370 ++ GLIBC_PRIVATE {
371 ++ # for the benefit of enospck.c
372 ++ __libc_open; __libc_write;
373 ++ }
374 + }
375 +
376 diff --exclude='*~' -ruN orig/glibc-2.5/debian/patches/series glibc-2.5/debian/patches/series
377 --- orig/glibc-2.5/debian/patches/series 2007-06-27 13:38:39.000000000 +0100
378 +++ glibc-2.5/debian/patches/series 2007-06-13 12:58:48.000000000 +0100
379 @@ -164,3 +164,5 @@
380 # Ubuntu-specific patches. These are things that we don't expect to wind up
381 # in Debian.
382 ubuntu/local-altlocaledir.diff -p1
383 +
384 +any/local-enospck.diff -p2
385
Attached Files
To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.You are not allowed to attach a file to this page.