Initial fix of upstream merge.
This commit is contained in:
@@ -177,7 +177,7 @@ print(const char *path)
|
||||
typech = '?';
|
||||
}
|
||||
|
||||
printf("%crwx------ %2d root %-8llu",
|
||||
printf("%crwx------ %2d root %-7llu ",
|
||||
typech,
|
||||
statbuf.st_nlink,
|
||||
statbuf.st_size);
|
||||
|
@@ -197,11 +197,9 @@ dumpdata(void)
|
||||
|
||||
indexsize = dolseek(indexfd, indexname, 0, SEEK_CUR);
|
||||
pos = indexsize;
|
||||
while (1) {
|
||||
assert(pos % sizeof(x) == 0);
|
||||
while (pos > 0) {
|
||||
pos -= sizeof(x);
|
||||
if (pos == 0) {
|
||||
break;
|
||||
}
|
||||
assert(pos >= 0);
|
||||
dolseek(indexfd, indexname, pos, SEEK_SET);
|
||||
|
||||
|
@@ -69,6 +69,11 @@ pipe_unaligned(void)
|
||||
|
||||
rv = pipe((int *)ptr);
|
||||
report_survival(rv, errno, &result);
|
||||
if (rv == 0) {
|
||||
memmove(fds, ptr, 2*sizeof(int));
|
||||
close(fds[0]);
|
||||
close(fds[1]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@@ -46,7 +46,7 @@
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
static char writebuf[40] = "Twiddle dee dee, Twiddle dum dum.......\n";
|
||||
static char writebuf[41] = "Twiddle dee dee, Twiddle dum dum.......\n";
|
||||
static char readbuf[41];
|
||||
|
||||
const char *file;
|
||||
|
@@ -152,12 +152,20 @@ void
|
||||
test(int nowait)
|
||||
{
|
||||
int pid0, pid1, pid2, pid3;
|
||||
int depth = 0;
|
||||
|
||||
/*
|
||||
* Caution: This generates processes geometrically.
|
||||
*
|
||||
* It is unrolled to encourage gcc to registerize the pids,
|
||||
* to prevent wait/exit problems if fork corrupts memory.
|
||||
*
|
||||
* Note: if the depth prints trigger and show that the depth
|
||||
* is too small, the most likely explanation is that the fork
|
||||
* child is returning from the write() inside putchar()
|
||||
* instead of from fork() and thus skipping the depth++. This
|
||||
* is a fairly common problem caused by races in the kernel
|
||||
* fork code.
|
||||
*/
|
||||
|
||||
/*
|
||||
@@ -184,18 +192,37 @@ test(int nowait)
|
||||
pid0 = dofork();
|
||||
nprintf(".");
|
||||
write(fd, "A", 1);
|
||||
depth++;
|
||||
if (depth != 1) {
|
||||
warnx("depth %d, should be 1", depth);
|
||||
}
|
||||
check();
|
||||
|
||||
pid1 = dofork();
|
||||
nprintf(".");
|
||||
write(fd, "B", 1);
|
||||
depth++;
|
||||
if (depth != 2) {
|
||||
warnx("depth %d, should be 2", depth);
|
||||
}
|
||||
check();
|
||||
|
||||
pid2 = dofork();
|
||||
nprintf(".");
|
||||
write(fd, "C", 1);
|
||||
depth++;
|
||||
if (depth != 3) {
|
||||
warnx("depth %d, should be 3", depth);
|
||||
}
|
||||
check();
|
||||
|
||||
pid3 = dofork();
|
||||
nprintf(".");
|
||||
write(fd, "D", 1);
|
||||
depth++;
|
||||
if (depth != 4) {
|
||||
warnx("depth %d, should be 4", depth);
|
||||
}
|
||||
check();
|
||||
|
||||
/*
|
||||
|
@@ -31,7 +31,7 @@
|
||||
* hog.c
|
||||
* Spawned by several other user programs to test time-slicing.
|
||||
*
|
||||
* This does not differ from guzzle in any important way.
|
||||
* Loops consuming CPU cycles.
|
||||
*/
|
||||
|
||||
int
|
||||
|
@@ -134,6 +134,7 @@ semP(struct usem *sem, size_t num)
|
||||
if (read(sem->fd, c, num) < 0) {
|
||||
err(1, "%s: read", sem->name);
|
||||
}
|
||||
(void)c;
|
||||
}
|
||||
|
||||
static
|
||||
|
@@ -273,16 +273,24 @@ static
|
||||
void
|
||||
semP(struct usem *sem, size_t num)
|
||||
{
|
||||
if (read(sem->fd, NULL, num) < 0) {
|
||||
char c[num];
|
||||
|
||||
if (read(sem->fd, c, num) < 0) {
|
||||
err(1, "%s: read", sem->name);
|
||||
}
|
||||
(void)c;
|
||||
}
|
||||
|
||||
static
|
||||
void
|
||||
semV(struct usem *sem, size_t num)
|
||||
{
|
||||
if (write(sem->fd, NULL, num) < 0) {
|
||||
char c[num];
|
||||
|
||||
/* semfs does not use these values, but be conservative */
|
||||
memset(c, 0, num);
|
||||
|
||||
if (write(sem->fd, c, num) < 0) {
|
||||
err(1, "%s: write", sem->name);
|
||||
}
|
||||
}
|
||||
@@ -326,7 +334,12 @@ makeprocs(bool dowait)
|
||||
for (i=0; i<NJOBS; i++) {
|
||||
pids[i] = fork();
|
||||
if (pids[i]<0) {
|
||||
warn("fork");
|
||||
warn("fork (process %d)", i);
|
||||
if (dowait) {
|
||||
semopen(&s1);
|
||||
semV(&s1, 1);
|
||||
semclose(&s1);
|
||||
}
|
||||
}
|
||||
if (pids[i]==0) {
|
||||
/* child */
|
||||
|
@@ -35,6 +35,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <err.h>
|
||||
|
||||
@@ -84,9 +85,9 @@ void
|
||||
Pn(struct usem *sem, unsigned count)
|
||||
{
|
||||
ssize_t r;
|
||||
char c;
|
||||
char c[count];
|
||||
|
||||
r = read(sem->fd, &c, count);
|
||||
r = read(sem->fd, c, count);
|
||||
if (r < 0) {
|
||||
err(1, "%s: read", sem->name);
|
||||
}
|
||||
@@ -105,9 +106,12 @@ void
|
||||
Vn(struct usem *sem, unsigned count)
|
||||
{
|
||||
ssize_t r;
|
||||
char c;
|
||||
char c[count];
|
||||
|
||||
r = write(sem->fd, &c, count);
|
||||
/* semfs does not use these values, but be conservative */
|
||||
memset(c, 0, count);
|
||||
|
||||
r = write(sem->fd, c, count);
|
||||
if (r < 0) {
|
||||
err(1, "%s: write", sem->name);
|
||||
}
|
||||
|
Reference in New Issue
Block a user