Avoid ftruncate to work around broken UMSDOS file system.

This commit is contained in:
Alexandre Julliard 2001-11-07 20:25:12 +00:00
parent c9228e1076
commit c4be541dfa
1 changed files with 7 additions and 4 deletions

View File

@ -812,8 +812,8 @@ DECL_HANDLER(init_thread)
/* set the shared buffer for a thread */ /* set the shared buffer for a thread */
DECL_HANDLER(set_thread_buffer) DECL_HANDLER(set_thread_buffer)
{ {
unsigned int size = MAX_REQUEST_LENGTH; const unsigned int size = MAX_REQUEST_LENGTH;
unsigned int offset = 0; const unsigned int offset = 0;
int fd = thread_get_inflight_fd( current, req->fd ); int fd = thread_get_inflight_fd( current, req->fd );
req->size = size; req->size = size;
@ -821,8 +821,10 @@ DECL_HANDLER(set_thread_buffer)
if (fd != -1) if (fd != -1)
{ {
if (ftruncate( fd, size ) == -1) file_set_error(); static const char zero;
else
/* grow the file to the requested size */
if (lseek( fd, size - 1, SEEK_SET ) != -1 && write( fd, &zero, 1 ) == 1)
{ {
void *buffer = mmap( 0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset ); void *buffer = mmap( 0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, offset );
if (buffer == (void *)-1) file_set_error(); if (buffer == (void *)-1) file_set_error();
@ -832,6 +834,7 @@ DECL_HANDLER(set_thread_buffer)
current->buffer = buffer; current->buffer = buffer;
} }
} }
else file_set_error();
close( fd ); close( fd );
} }
else set_error( STATUS_INVALID_HANDLE ); else set_error( STATUS_INVALID_HANDLE );