Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
b09b8abf
Commit
b09b8abf
authored
Oct 25, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
7a731b3c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
7 deletions
+33
-7
wcfs/internal/wcfs_misc.cpp
wcfs/internal/wcfs_misc.cpp
+20
-3
wcfs/internal/wcfs_misc.h
wcfs/internal/wcfs_misc.h
+7
-0
wcfs/internal/wcfs_virtmem.cpp
wcfs/internal/wcfs_virtmem.cpp
+6
-4
No files found.
wcfs/internal/wcfs_misc.cpp
View file @
b09b8abf
...
...
@@ -138,19 +138,27 @@ error map_into(void *addr, size_t size, int prot, int flags, const os::File &f,
namespace
fmt
{
static
string
_vsprintf
(
const
string
&
format
,
va_list
argp
)
{
string
_vsprintf
(
const
char
*
format
,
va_list
argp
)
{
// based on https://stackoverflow.com/a/26221725/9456786
va_list
argp2
;
va_copy
(
argp2
,
argp
);
size_t
size
=
vsnprintf
(
NULL
,
0
,
format
.
c_str
()
,
argp2
);
size_t
size
=
vsnprintf
(
NULL
,
0
,
format
,
argp2
);
va_end
(
argp2
);
std
::
unique_ptr
<
char
[]
>
buf
(
new
char
[
size
]
);
vsnprintf
(
buf
.
get
(),
size
,
format
.
c_str
()
,
argp
);
vsnprintf
(
buf
.
get
(),
size
,
format
,
argp
);
return
string
(
buf
.
get
(),
buf
.
get
()
+
size
-
1
);
// without trailing '\0'
}
string
sprintf
(
const
string
&
format
,
...)
{
va_list
argp
;
va_start
(
argp
,
format
);
string
str
=
fmt
::
_vsprintf
(
format
.
c_str
(),
argp
);
va_end
(
argp
);
return
str
;
}
string
sprintf
(
const
char
*
format
,
...)
{
va_list
argp
;
va_start
(
argp
,
format
);
string
str
=
fmt
::
_vsprintf
(
format
,
argp
);
...
...
@@ -159,6 +167,15 @@ string sprintf(const string &format, ...) {
}
error
errorf
(
const
string
&
format
,
...)
{
error
err
;
va_list
argp
;
va_start
(
argp
,
format
);
err
.
err
=
fmt
::
sprintf
(
format
.
c_str
(),
argp
);
va_end
(
argp
);
return
err
;
}
error
errorf
(
const
char
*
format
,
...)
{
error
err
;
va_list
argp
;
va_start
(
argp
,
format
);
...
...
wcfs/internal/wcfs_misc.h
View file @
b09b8abf
...
...
@@ -107,6 +107,13 @@ namespace fmt {
string
sprintf
(
const
string
&
format
,
...);
error
errorf
(
const
string
&
format
,
...);
// `const char *` overload just to catch format mistakes as
// __attribute__(format) does not work with std::string.
string
sprintf
(
const
char
*
format
,
...)
__attribute__
((
format
(
printf
,
1
,
2
)));
error
errorf
(
const
char
*
format
,
...)
__attribute__
((
format
(
printf
,
1
,
2
)));
}
// fmt::
#endif
wcfs/internal/wcfs_virtmem.cpp
View file @
b09b8abf
...
...
@@ -355,11 +355,13 @@ error _Mapping::_remmapblk(int64_t blk, Tid at) {
err
=
fsfile
.
stat
(
&
st
);
if
(
err
!=
nil
)
return
err
;
ASSERT
(
st
.
st_blksize
==
f
->
blksize
);
// FIXME assert -> return err ?
if
((
size_t
)
st
.
st_blksize
!=
f
->
blksize
)
return
fmt
::
errorf
(
"wcfs bug: blksize changed: expected %lu; got %ld"
,
f
->
blksize
,
st
.
st_blksize
);
// block is beyond file size - mmap with zeros - else access to memory
// after file.size will raise SIGBUS. (assumes head/f size ↑=)
if
((
blk
+
1
)
*
f
->
blksize
>
st
.
st_size
)
{
if
((
blk
+
1
)
*
f
->
blksize
>
(
size_t
)
st
.
st_size
)
{
err
=
mmap_zero_into_ro
(
blkmem
,
1
*
f
->
blksize
);
if
(
err
!=
nil
)
return
err
;
...
...
@@ -422,7 +424,7 @@ error WatchLink::_send(StreamID stream, const string &msg) {
pkt.rawdata = // XXX copy msg XXX + "%d <stream> ...\n" ?
return wlink->_write(&pkt)
#endif
string
pkt
=
fmt
::
sprintf
(
"%
ul
%s
\n
"
,
stream
,
msg
.
c_str
());
string
pkt
=
fmt
::
sprintf
(
"%
lu
%s
\n
"
,
stream
,
msg
.
c_str
());
return
wlink
->
_write
(
pkt
);
}
...
...
@@ -522,7 +524,7 @@ tuple<os::File, error> WCFS::_open(const string &path, int flags) {
// ---- misc ----
static
string
h
(
uint64_t
v
)
{
return
fmt
::
sprintf
(
"%016x"
,
v
);
return
fmt
::
sprintf
(
"%016
l
x"
,
v
);
}
// map_zero_ro mmaps read-only zeros into [addr +size) so that region as all zeros.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment