Re: Re: ZeroFill(.../pg_xlog/xlogtemp.20148) failed: No such file or directory

From: "Denis A(dot) Doroshenko" <d(dot)doroshenko(at)omnitel(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Re: ZeroFill(.../pg_xlog/xlogtemp.20148) failed: No such file or directory
Date: 2001-05-23 20:44:57
Message-ID: 20010523224456.I22226@comrade.omnitel.lan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, May 23, 2001 at 02:04:51PM -0400, Tom Lane wrote:
> Chris Jones <chris(at)mt(dot)sri(dot)com> writes:
> > If write didn't return -1, it shouldn't have set errno. A short write
> > count isn't an error condition.
>
> On disk files it certainly is; there's no non-error reason to do that,
> and AFAICS no reason for the application to try again.

i've tried to get partial write on disk shortage condition and had no
success. on OpenBSD, if there is no space write() seems to write the
whole buffer or fail with -1/errno. i used such proggie attached to
the and (owell, i'm not sure about forks, but it adds more
simultaneosity... huh?). BTW. i didn't see anywhere i looked whetjer
write on disk files can fail after writting some part of data.

--
Denis A. Doroshenko [GPRS/IN/WAP, VAS group engineer] .-. _|_ |
[Omnitel Ltd., T.Sevcenkos st. 25, Vilnius, Lithuania] | | _ _ _ .| _ |
[Phone: +370 9863486 E-mail: d(dot)doroshenko(at)omnitel(dot)net] |_|| | || |||(/_|_

---[a.c]------------------------------------------------------------
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

#define SIZ (12345)
#define CHILDREN (5)
#define FILE "/tmp/garbage.XXXXXXXXXX"

int
main (void)
{
char *buf;
char *file;
int fd, i, j, rc;

warnx("[%d] allocating %d of memory", getpid(), SIZ);
if ( (buf = malloc(SIZ)) == NULL )
err(1, "malloc()");

file = strdup(FILE);

warnx("[%d] creating %s", getpid(), file);
if ( (fd = mkstemp(file)) == -1 )
err(1, "open()");

warnx("[%d] forking...", getpid());
for ( j = 0; j < CHILDREN; j++ ) {
if ( fork() == 0 ) {
warnx("[%d:%d]: filling %s with junk",
getppid(), j, file);

for ( i = 0; ; i++ ) {
if ( (rc = write(fd, buf, SIZ)) == -1 ) {
warn("[%d:%d] write()", getppid(), j);
break;
}

if ( rc == SIZ ) {
(void)fputc(j + '0', stderr);
continue;
}

warn("[%d:%d] write(%d written)",
getppid(), j, rc);
}

(void)close(fd);
return (0);
}
}

/* father */
while ( (j = wait(&i)) != - 1 )
;

warnx("[%d] destroying %s", getpid(), file);
(void)close(fd);
(void)unlink(file);

return (0);
}

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ian Lance Taylor 2001-05-23 20:54:27 Re: Re: ZeroFill(.../pg_xlog/xlogtemp.20148) failed: No such file or directory
Previous Message Tom Lane 2001-05-23 20:34:07 Re: Re: ZeroFill(.../pg_xlog/xlogtemp.20148) failed: No such file or directory