parent
266d5e0be3
commit
94fad13adb
|
@ -505,7 +505,10 @@ class Plugin : public Libc::Plugin
|
||||||
case FR_OK: {
|
case FR_OK: {
|
||||||
Plugin_context *context = new (Genode::env()->heap())
|
Plugin_context *context = new (Genode::env()->heap())
|
||||||
File_plugin_context(pathname, ffat_file);
|
File_plugin_context(pathname, ffat_file);
|
||||||
return Libc::file_descriptor_allocator()->alloc(this, context);
|
Libc::File_descriptor *fd = Libc::file_descriptor_allocator()->alloc(this, context);
|
||||||
|
if ((flags & O_TRUNC) && (ftruncate(fd, 0) == -1))
|
||||||
|
return 0;
|
||||||
|
return fd;
|
||||||
}
|
}
|
||||||
case FR_NO_FILE: {
|
case FR_NO_FILE: {
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -550,8 +550,10 @@ class Plugin : public Libc::Plugin
|
||||||
Plugin_context *context = new (Genode::env()->heap())
|
Plugin_context *context = new (Genode::env()->heap())
|
||||||
Plugin_context(handle);
|
Plugin_context(handle);
|
||||||
|
|
||||||
return Libc::file_descriptor_allocator()->alloc(this, context);
|
Libc::File_descriptor *fd = Libc::file_descriptor_allocator()->alloc(this, context);
|
||||||
|
if ((flags & O_TRUNC) && (ftruncate(fd, 0) == -1))
|
||||||
|
return 0;
|
||||||
|
return fd;
|
||||||
}
|
}
|
||||||
catch (File_system::Lookup_failed) {
|
catch (File_system::Lookup_failed) {
|
||||||
PERR("open(%s) lookup failed", pathname); }
|
PERR("open(%s) lookup failed", pathname); }
|
||||||
|
|
|
@ -180,6 +180,13 @@ int main(int argc, char *argv[])
|
||||||
(ret == 0) && (stat_buf.st_size == 10),
|
(ret == 0) && (stat_buf.st_size == 10),
|
||||||
"file_name=%s", file_name4);
|
"file_name=%s", file_name4);
|
||||||
|
|
||||||
|
/* test 'O_TRUNC' flag */
|
||||||
|
CALL_AND_CHECK(fd, open(file_name4, O_WRONLY | O_TRUNC), fd >= 0, "file_name=%s", file_name4);
|
||||||
|
CALL_AND_CHECK(ret, close(fd), ret == 0, "");
|
||||||
|
CALL_AND_CHECK(ret, stat(file_name4, &stat_buf),
|
||||||
|
(ret == 0) && (stat_buf.st_size == 0),
|
||||||
|
"file_name=%s", file_name4);
|
||||||
|
|
||||||
if (i < (iterations - 1))
|
if (i < (iterations - 1))
|
||||||
sleep(2);
|
sleep(2);
|
||||||
}
|
}
|
||||||
|
|
|
@ -642,7 +642,11 @@ namespace {
|
||||||
}
|
}
|
||||||
|
|
||||||
Libc::Plugin_context *context = noux_context(sysio()->open_out.fd);
|
Libc::Plugin_context *context = noux_context(sysio()->open_out.fd);
|
||||||
return Libc::file_descriptor_allocator()->alloc(this, context, sysio()->open_out.fd);
|
Libc::File_descriptor *fd =
|
||||||
|
Libc::file_descriptor_allocator()->alloc(this, context, sysio()->open_out.fd);
|
||||||
|
if ((flags & O_TRUNC) && (ftruncate(fd, 0) == -1))
|
||||||
|
return 0;
|
||||||
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user