Changeset 10830


Ignore:
Timestamp:
Sep 22, 2008, 3:24:56 PM (11 years ago)
Author:
gb
Message:

Use writebuf(), not write(), to write a section to disk. (I think
that write() can generally return a positive value smaller than
write()'s last arg; we try to handle this in lisp I/O code, it
can't hurt to be defensive about it here, and may explain why
win64 sometimes writes images that seem to be missing data.)
The code that called write checked to see if the return value
equaled the argument and returned errno if not, but errno would
be 0 on a short write.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lisp-kernel/image.c

    r10819 r10830  
    370370}
    371371 
    372  
     372natural
     373writebuf(int fd, char *bytes, natural n)
     374{
     375  natural remain = n;
     376  int result;
     377
     378  while (remain) {
     379    result = write(fd, bytes, remain);
     380    if (result < 0) {
     381      return errno;
     382    }
     383    bytes += result;
     384    remain -= result;
     385  }
     386  return 0;
     387}
     388
    373389OSErr
    374390save_application(unsigned fd)
     
    451467
    452468  for (i = 0; i < NUM_IMAGE_SECTIONS; i++) {
    453     natural n, nstatic;
     469    natural n;
    454470    a = areas[i];
    455471    seek_to_next_page(fd);
    456472    n = sections[i].memory_size;
    457     nstatic = sections[i].static_dnodes;
    458     if (write(fd, a->low, n) != n) {
     473    if (writebuf(fd, a->low, n)) {
    459474        return errno;
    460475    }
Note: See TracChangeset for help on using the changeset viewer.