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
b7d7b8d4
Commit
b7d7b8d4
authored
Oct 22, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
786cab49
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
4 deletions
+38
-4
wcfs/internal/wcfs_misc.cpp
wcfs/internal/wcfs_misc.cpp
+22
-1
wcfs/internal/wcfs_misc.h
wcfs/internal/wcfs_misc.h
+10
-0
wcfs/internal/wcfs_virtmem.cpp
wcfs/internal/wcfs_virtmem.cpp
+6
-3
No files found.
wcfs/internal/wcfs_misc.cpp
View file @
b7d7b8d4
...
...
@@ -19,6 +19,7 @@
#include "wcfs_misc.h"
// os::
namespace
os
{
tuple
<
File
,
error
>
open
(
const
string
&
path
)
{
...
...
@@ -51,5 +52,25 @@ error File::_err(const char *op) {
return
errorf
(
"%s %s: %s"
,
op
,
f
->
path
,
strerror_r
(
errno
));
}
}
// os::
// fmt::
namespace
fmt
{
string
sprintf
(
const
string
&
format
,
...)
{
// https://stackoverflow.com/a/26221725/9456786
va_list
ap
;
va_start
(
ap
,
format
);
size_t
size
=
vsnprintf
(
NULL
,
0
,
format
.
c_str
(),
ap
);
va_end
(
ap
);
std
::
unique_ptr
<
char
[]
>
buf
(
new
char
[
size
]
);
va_start
(
ap
,
format
);
vsnprintf
(
buf
.
get
(),
size
,
format
.
c_str
(),
ap
);
va_end
(
ap
);
return
string
(
buf
.
get
(),
buf
.
get
()
+
size
-
1
);
// without trailing '\0'
}
}
// fmt::
wcfs/internal/wcfs_misc.h
View file @
b7d7b8d4
...
...
@@ -27,6 +27,7 @@ using std::string;
#include <tuple>
using
std
::
tuple
;
using
std
::
tie
;
// nil is synonim for nullptr and NULL.
const
nullptr_t
nil
=
nullptr
;
...
...
@@ -45,6 +46,7 @@ struct error {
}
};
// os::
namespace
os
{
// os::File mimics os.File from Go.
...
...
@@ -63,4 +65,12 @@ tuple<File, error> open(const string &path);
}
// os::
// fmt::
namespace
fmt
{
string
sprintf
(
const
string
&
format
,
...);
}
// fmt::
#endif
wcfs/internal/wcfs_virtmem.cpp
View file @
b7d7b8d4
...
...
@@ -240,6 +240,7 @@ error _Mapping::_remmapblk(int64_t blk, Tid at) {
ASSERT
(
mmap
->
blk_start
<=
blk
&&
blk
<
mmap
->
blk_stop
());
_File
*
f
=
mmap
->
file
;
error
err
;
uint8_t
*
blkmem
=
mmap
->
mem_start
+
(
blk
-
mmap
->
blk_start
)
*
f
->
blksize
;
os
::
File
fsfile
;
...
...
@@ -248,13 +249,15 @@ error _Mapping::_remmapblk(int64_t blk, Tid at) {
}
else
{
// TODO share @rev fd until wconn is resynced?
fsfile
=
f
->
wconn
->
_wc
->
_open
(
"@%s/bigfile/%s"
%
(
h
(
at
),
h
(
f
->
foid
)),
"rb"
);
// XXX err
tie
(
fsfile
,
err
)
=
f
->
wconn
->
_wc
->
_open
(
fmt
::
sprintf
(
"@%s/bigfile/%s"
,
h
(
at
),
h
(
f
->
foid
),
"rb"
);
if
(
err
!=
nil
)
return
err
;
defer
(
fsfile
.
close
);
}
struct
stat
st
;
auto
err
=
fsfile
.
stat
(
&
st
);
err
=
fsfile
.
stat
(
&
st
);
if
(
err
!=
nil
)
return
err
;
ASSERT
(
st
.
st_blksize
==
f
->
blksize
);
// FIXME assert
...
...
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