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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Joshua
wendelin.core
Commits
d27af7e8
Commit
d27af7e8
authored
Oct 23, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
6249dcd1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
22 deletions
+42
-22
wcfs/internal/wcfs_misc.cpp
wcfs/internal/wcfs_misc.cpp
+32
-3
wcfs/internal/wcfs_misc.h
wcfs/internal/wcfs_misc.h
+7
-0
wcfs/internal/wcfs_virtmem.cpp
wcfs/internal/wcfs_virtmem.cpp
+3
-19
No files found.
wcfs/internal/wcfs_misc.cpp
View file @
d27af7e8
...
...
@@ -27,6 +27,9 @@
#include <memory>
static
error
_pathError
(
const
char
*
op
,
const
string
&
path
,
int
syserr
);
// os::
namespace
os
{
...
...
@@ -63,13 +66,39 @@ error File::stat(struct stat *st) {
// _errno returns error corresponding to file->op and errno.
error
File
::
_errno
(
const
char
*
op
)
{
File
*
f
=
this
;
char
ebuf
[
128
];
char
*
estr
=
strerror_r
(
errno
,
ebuf
,
sizeof
(
ebuf
));
return
fmt
::
errorf
(
"%s %s: %s"
,
op
,
f
->
_path
,
estr
);
return
_pathError
(
op
,
f
->
_path
,
errno
);
}
}
// os::
// _pathError returns os.PathError-like for op/path and system error
// indicated by syserr.
static
error
_pathError
(
const
char
*
op
,
const
string
&
path
,
int
syserr
)
{
char
ebuf
[
128
];
char
*
estr
=
strerror_r
(
syserr
,
ebuf
,
sizeof
(
ebuf
));
return
fmt
::
errorf
(
"%s %s: %s"
,
op
,
path
.
c_str
(),
estr
);
}
// mm::
namespace
mm
{
// map_into memory-maps f.fd[offset +size) as into [addr +size).
// prot is PROT_* from mmap(2).
// flags is MAP_* from mmap(2); MAP_FIXED is added to flags.
//
// XXX split from File?
error
map_into
(
void
*
addr
,
size_t
size
,
int
prot
,
int
flags
,
const
File
&
f
,
off_t
offset
)
{
void
*
addr2
;
addr2
=
mmap
(
addr
,
size
,
PROT_READ
,
MAP_FIXED
|
MAP_SHARED
,
f
->
fd
(),
offset
);
if
(
addr2
==
MAP_FAILED
)
return
_pathError
(
"mmap"
,
f
.
name
(),
errno
);
if
(
addr2
!=
addr
)
panic
(
"mmap(addr, MAP_FIXED): returned !addr"
);
return
nil
;
}
}
// mm::
// fmt::
namespace
fmt
{
...
...
wcfs/internal/wcfs_misc.h
View file @
d27af7e8
...
...
@@ -80,6 +80,13 @@ tuple<File, error> open(const string &path, int flags = O_RDONLY,
}
// os::
// mm::
namespace
mm
{
error
map_into
(
void
*
addr
,
size_t
,
int
prot
,
int
flags
,
const
os
::
File
&
f
,
off_t
offset
);
// XXX unmap
}
// mm::
// fmt::
namespace
fmt
{
...
...
wcfs/internal/wcfs_virtmem.cpp
View file @
d27af7e8
...
...
@@ -38,6 +38,7 @@ using namespace golang;
#include <vector>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdint.h>
...
...
@@ -278,14 +279,8 @@ error _Mapping::_remmapblk(int64_t blk, Tid at) {
}
// block is inside file - mmap file data
else
{
mm
.
map_into_ro
(
blkmem
,
fsfile
.
fd
(),
blk
*
f
->
blksize
);
// XXX err
err
=
mmap_into_ro
(
blkmem
,
f
->
blksize
,
fsfile
,
blk
*
f
->
blksize
);
err
=
fsfile
.
mmapfix
(
blkmem
,
f
->
blksize
,
PROT_READ
,
MAP_SHARED
,
blk
*
f
->
blksize
);
mmap
(
blkmem
,
f
->
blksize
,
PROT_READ
,
MAP_FIXED
|
MAP_SHARED
,
fsfile
.
fd
(),
blk
*
f
->
blksize
);
err
=
mm
::
map_into
(
blkmem
,
f
->
blksize
,
PROT_READ
,
MAP_SHARED
,
fsfile
,
blk
*
f
->
blksize
);
// XXX err handle
}
return
nil
;
...
...
@@ -314,14 +309,3 @@ tuple<os::File, error> WCFS::_open(const string &path, int flags) {
string
h
(
uint64_t
v
)
{
return
fmt
::
sprintf
(
"%016x"
,
v
);
}
// map_into_ro memory-maps f.fd[offset +size) as read-only into [addr +size).
// The mapping is created with MAP_SHARED.
error
mmap_into_ro
(
void
*
addr
,
size_t
size
,
const
File
&
f
.
off_t
offset
)
{
void
*
addr2
;
addr2
=
mmap
(
blkmem
,
size
,
PROT_READ
,
MAP_FIXED
|
MAP_SHARED
,
f
.
fd
(),
offset
);
// XXX -> err
// XXX assert addr2 == addr
}
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