OBS User unknown 2007-01-12 18:23:43 +00:00 committed by Git OBS Bridge
parent 89c55072f6
commit 5d24fd33c7
4 changed files with 56 additions and 19 deletions

View File

@ -6,6 +6,7 @@
# #
### BEGIN INIT INFO ### BEGIN INIT INFO
# Provides: boot.sysctl # Provides: boot.sysctl
# Required-Start:
# Should-Start: setserial boot.isapnp $local_fs # Should-Start: setserial boot.isapnp $local_fs
# Required-Stop: # Required-Stop:
# Default-Start: B # Default-Start: B

View File

@ -9,15 +9,22 @@
if(unlikely(fd==-1)) return -1; if(unlikely(fd==-1)) return -1;
num_read = read(fd, ret, cap - 1); num_read = read(fd, ret, cap - 1);
close(fd); close(fd);
@@ -423,37 +423,41 @@ static int file2str(const char *director @@ -421,40 +421,58 @@ static int file2str(const char *director
return num_read;
}
+#define PROC_READ_MAY_EINTR 0 /* AFAIK reading /proc can catch EINTR
+ * or ERESTARTSYS and therefore read
+ * can be shorten before reaching EOF ?? */
+
static char** file2strvec(const char* directory, const char* what) { static char** file2strvec(const char* directory, const char* what) {
char buf[2048]; /* read buf bytes at a time */ char buf[2048]; /* read buf bytes at a time */
- char *p, *rbuf = 0, *endbuf, **q, **ret; - char *p, *rbuf = 0, *endbuf, **q, **ret;
- int fd, tot = 0, n, c, end_of_file = 0; - int fd, tot = 0, n, c, end_of_file = 0;
- int align;
+ char *p, *rbuf = (char*)0, *endbuf, **q, **ret; + char *p, *rbuf = (char*)0, *endbuf, **q, **ret;
+ int fd, tot = 0, n, c; + int fd, c;
int align; + ssize_t n, align, tot = 0;
sprintf(buf, "%s/%s", directory, what); sprintf(buf, "%s/%s", directory, what);
- fd = open(buf, O_RDONLY, 0); - fd = open(buf, O_RDONLY, 0);
@ -25,27 +32,28 @@
if(fd==-1) return NULL; if(fd==-1) return NULL;
/* read whole file into a memory buffer, allocating as we go */ /* read whole file into a memory buffer, allocating as we go */
while ((n = read(fd, buf, sizeof buf - 1)) > 0) { - while ((n = read(fd, buf, sizeof buf - 1)) > 0) {
- if (n < (int)(sizeof buf - 1)) - if (n < (int)(sizeof buf - 1))
- end_of_file = 1; - end_of_file = 1;
- if (n == 0 && rbuf == 0) - if (n == 0 && rbuf == 0)
- return NULL; /* process died between our open and read */ - return NULL; /* process died between our open and read */
+ do {
+ n = read(fd, buf, sizeof(buf) - 1);
if (n < 0) { if (n < 0) {
- if (rbuf)
- free(rbuf);
- return NULL; /* read error */
+#if defined(PROC_READ_MAY_EINTR) && (PROC_READ_MAY_EINTR > 0)
+ if (errno == EINTR) + if (errno == EINTR)
+ continue; + continue;
if (rbuf) +#endif
free(rbuf); + tot = 0;
- return NULL; /* read error */ + break; /* read error! */
+ return NULL; /* read error! */
+ } + }
+ if (n == 0) { + if (n == 0) {
+ if(rbuf == (char*)0) + if(rbuf == (char*)0)
+ return NULL; /* process died between our open and read */ + tot = 0; /* process died between our open and read */
+ break; /* we're done */ + break; /* we're done */
+ }
+ if (n < (int)(sizeof(buf) - 1)) {
+ if (buf[n-1]) /* last read char not null */
+ buf[n++] = '\0'; /* so append null-terminator */
} }
- if (end_of_file && buf[n-1]) /* last read char not null */ - if (end_of_file && buf[n-1]) /* last read char not null */
- buf[n++] = '\0'; /* so append null-terminator */ - buf[n++] = '\0'; /* so append null-terminator */
@ -54,19 +62,33 @@
tot += n; /* increment total byte ctr */ tot += n; /* increment total byte ctr */
- if (end_of_file) - if (end_of_file)
- break; - break;
} - }
+#if defined(PROC_READ_MAY_EINTR) && (PROC_READ_MAY_EINTR > 0)
+ } while (n > 0);
+#else
+ } while (n == (sizeof(buf) - 1));
+#endif
+
close(fd); close(fd);
- if (n <= 0 && !end_of_file) { - if (n <= 0 && !end_of_file) {
- if (rbuf) free(rbuf); - if (rbuf) free(rbuf);
- return NULL; /* read error */ - return NULL; /* read error */
+
+ if (tot == 0) { + if (tot == 0) {
+ if (rbuf) + if (rbuf)
+ free(rbuf); + free(rbuf);
+ return NULL; /* read error? */ + return NULL; /* read error? */
} }
+
+ if (rbuf[tot-1]) { /* last read char not null */
+ rbuf = xrealloc(rbuf, tot + 1); /* allocate more memory */
+ rbuf[tot++] = '\0'; /* and append null-terminator */
+ }
+
endbuf = rbuf + tot; /* count space for pointers */ endbuf = rbuf + tot; /* count space for pointers */
align = (sizeof(char*)-1) - ((tot + sizeof(char*)-1) & (sizeof(char*)-1)); align = (sizeof(char*)-1) - ((tot + sizeof(char*)-1) & (sizeof(char*)-1));
@@ -482,7 +486,7 @@ int read_cmdline(char *restrict const ds for (c = 0, p = rbuf; p < endbuf; p++)
@@ -482,7 +500,7 @@ int read_cmdline(char *restrict const ds
unsigned n = 0; unsigned n = 0;
dst[0] = '\0'; dst[0] = '\0';
snprintf(name, sizeof name, "/proc/%u/cmdline", pid); snprintf(name, sizeof name, "/proc/%u/cmdline", pid);

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Fri Jan 12 19:07:33 CET 2007 - werner@suse.de
- Add missing Required-Start to boot.sysctl [#231677]
-------------------------------------------------------------------
Thu Aug 3 14:41:54 CEST 2006 - werner@suse.de
- Read upto EOF [#194598]
------------------------------------------------------------------- -------------------------------------------------------------------
Fri Jul 28 13:31:56 CEST 2006 - werner@suse.de Fri Jul 28 13:31:56 CEST 2006 - werner@suse.de

View File

@ -1,7 +1,7 @@
# #
# spec file for package procps (Version 3.2.7) # spec file for package procps (Version 3.2.7)
# #
# Copyright (c) 2006 SUSE LINUX Products GmbH, Nuernberg, Germany. # Copyright (c) 2007 SUSE LINUX Products GmbH, Nuernberg, Germany.
# This file and all modifications and additions to the pristine # This file and all modifications and additions to the pristine
# package are under the same license as the package itself. # package are under the same license as the package itself.
# #
@ -12,12 +12,12 @@
Name: procps Name: procps
URL: http://procps.sf.net URL: http://procps.sf.net
License: GPL, LGPL License: GNU General Public License (GPL), GNU Library General Public License v. 2.0 and 2.1 (LGPL)
Group: System/Monitoring Group: System/Monitoring
PreReq: %fillup_prereq %insserv_prereq PreReq: %fillup_prereq %insserv_prereq
Autoreqprov: on Autoreqprov: on
Version: 3.2.7 Version: 3.2.7
Release: 3 Release: 26
Summary: ps utilities for /proc Summary: ps utilities for /proc
Provides: ps Provides: ps
Obsoletes: ps Obsoletes: ps
@ -151,6 +151,10 @@ rm -rf $RPM_BUILD_ROOT
%_mandir/man8/sysctl.8.gz %_mandir/man8/sysctl.8.gz
%changelog -n procps %changelog -n procps
* Fri Jan 12 2007 - werner@suse.de
- Add missing Required-Start to boot.sysctl [#231677]
* Thu Aug 03 2006 - werner@suse.de
- Read upto EOF [#194598]
* Fri Jul 28 2006 - werner@suse.de * Fri Jul 28 2006 - werner@suse.de
- Don't stop reading if the read buffer boundary is reached [#194598] - Don't stop reading if the read buffer boundary is reached [#194598]
* Fri Jul 28 2006 - olh@suse.de * Fri Jul 28 2006 - olh@suse.de
@ -400,7 +404,7 @@ rm -rf $RPM_BUILD_ROOT
- port all required patches to 21.2 - port all required patches to 21.2
* Tue Sep 10 2002 - adrian@suse.de * Tue Sep 10 2002 - adrian@suse.de
- fix split alias - fix split alias
-Obsoletes: ps:/usr/X11R6/bin/xcpustate -Obsoletes: ps:/usr/X11R6/bin/xcpustate
+Provides: ps:/usr/X11R6/bin/xcpustate +Provides: ps:/usr/X11R6/bin/xcpustate
* Thu Aug 22 2002 - kukuk@suse.de * Thu Aug 22 2002 - kukuk@suse.de
- fix PreRequires. - fix PreRequires.