Avoid ftruncate to work around broken UMSDOS file system.
This commit is contained in:
parent
c9228e1076
commit
c4be541dfa
|
@ -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 );
|
||||||
|
|
Loading…
Reference in New Issue