mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-21 02:01:38 +00:00
base-linux: build fix for BOARD=pc
This is a follow-up commit to "base: remove internal use of format strings". Issue #2064
This commit is contained in:
parent
47fa54992f
commit
65d3b3a32f
@ -34,17 +34,15 @@ using namespace Core;
|
||||
Linux_dataspace::Filename Dataspace_component::_file_name(const char *args)
|
||||
{
|
||||
Session_label const label = label_from_args(args);
|
||||
Linux_dataspace::Filename fname;
|
||||
|
||||
if (label.last_element().length() > sizeof(fname.buf)) {
|
||||
Genode::error("file name too long: ", label.last_element());
|
||||
if (label.last_element().length() > Linux_dataspace::Filename::capacity()) {
|
||||
error("file name too long: ", label.last_element());
|
||||
throw Service_denied();
|
||||
}
|
||||
|
||||
copy_cstring(fname.buf, label.last_element().string(), sizeof(fname.buf));
|
||||
Linux_dataspace::Filename const fname = label.last_element();
|
||||
|
||||
/* only files inside the current working directory are allowed */
|
||||
for (const char *c = fname.buf; *c; ++c)
|
||||
for (const char *c = fname.string(); *c; ++c)
|
||||
if (*c == '/') throw Service_denied();
|
||||
|
||||
return fname;
|
||||
@ -54,10 +52,10 @@ Linux_dataspace::Filename Dataspace_component::_file_name(const char *args)
|
||||
size_t Dataspace_component::_file_size()
|
||||
{
|
||||
Genode::uint64_t size = 0;
|
||||
if (lx_stat_size(_fname.buf, size) < 0)
|
||||
if (lx_stat_size(_fname.string(), size) < 0)
|
||||
throw Service_denied();
|
||||
|
||||
return size;
|
||||
return align_addr((size_t)size, 12);
|
||||
}
|
||||
|
||||
|
||||
@ -66,7 +64,7 @@ Dataspace_component::Dataspace_component(const char *args)
|
||||
_fname(_file_name(args)),
|
||||
_size(_file_size()),
|
||||
_addr(0),
|
||||
_cap(_fd_to_cap(lx_open(_fname.buf, O_RDONLY | LX_O_CLOEXEC, S_IRUSR | S_IXUSR))),
|
||||
_cap(_fd_to_cap(lx_open(_fname.string(), O_RDONLY | LX_O_CLOEXEC, S_IRUSR | S_IXUSR))),
|
||||
_writeable(false),
|
||||
_owner(0)
|
||||
{ }
|
||||
@ -76,6 +74,4 @@ Dataspace_component::Dataspace_component(size_t size, addr_t, addr_t phys_addr,
|
||||
Cache, bool writeable, Dataspace_owner *_owner)
|
||||
:
|
||||
_size(size), _addr(phys_addr), _cap(), _writeable(writeable), _owner(_owner)
|
||||
{
|
||||
_fname.buf[0] = 0;
|
||||
}
|
||||
{ }
|
||||
|
Loading…
x
Reference in New Issue
Block a user