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
b6685340
Commit
b6685340
authored
Oct 21, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
cd3f3f04
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
5 deletions
+57
-5
wcfs/internal/wcfs_virtmem.cpp
wcfs/internal/wcfs_virtmem.cpp
+57
-5
No files found.
wcfs/internal/wcfs_virtmem.cpp
View file @
b6685340
...
...
@@ -224,12 +224,14 @@ void Conn::_pin1(SrvReq *req) {
// at=None means unpin to head/ . XXX -> C
// NOTE this does not check wrt virtmem already mapped blk as RW.
void
_Mapping
::
_remmapblk
(
int64_t
blk
,
Tid
at
)
{
// XXX err context?
_Mapping
*
mmap
=
this
;
ASSERT
(
mmap
->
blk_start
<=
blk
&&
blk
<
mmap
->
blk_stop
());
_File
*
f
=
mmap
->
file
;
uint8_t
*
blkmem
=
mmap
->
mem_start
+
(
blk
-
mmap
->
blk_start
)
*
f
->
blksize
;
osfile
fsfile
;
if
(
at
==
TidHead
)
{
fsfile
=
f
->
headf
;
}
...
...
@@ -239,15 +241,65 @@ void _Mapping::_remmapblk(int64_t blk, Tid at) {
defer
(
fsfile
.
close
)
}
_
=
os
.
fstat
(
fsfile
.
fileno
());
ASSERT
(
_
.
st_blksize
==
f
->
blksize
);
// FIXME assert
struct
stat
st
;
err
=
fsfile
.
stat
(
&
st
);
if
(
err
!=
nil
)
return
err
;
ASSERT
(
st
.
st_blksize
==
f
->
blksize
);
// FIXME assert
// block is beyond file size - mmap with zeros (assumes head/f size ↑=)
if
((
blk
+
1
)
*
f
->
blksize
>
_
.
st_size
)
{
mm
.
map_zero_into_ro
(
blkmem
)
if
((
blk
+
1
)
*
f
->
blksize
>
st
.
st_size
)
{
mm
.
map_zero_into_ro
(
blkmem
)
;
}
// block is inside file - mmap file data
else
{
mm
.
map_into_ro
(
blkmem
,
fsfile
.
fileno
(),
blk
*
f
->
blksize
)
mm
.
map_into_ro
(
blkmem
,
fsfile
.
fileno
(),
blk
*
f
->
blksize
)
;
}
}
struct
error
{
err
string
;
error
()
{}
error
(
nullptr_t
)
{}
// = nil
bool
operator
==
(
nullptr_t
)
{
// == nil
return
err
.
is_empty
();
}
bool
operator
!=
(
nullptr_t
)
{
// != nil
return
!
(
this
==
nil
);
}
};
struct
osfile
{
int
fd
;
string
path
;
error
close
();
error
stat
(
struct
stat
*
st
);
};
error
osfile
::
close
()
{
osfile
*
f
=
this
;
int
err
=
close
(
f
->
fd
);
if
(
err
!=
0
)
return
f
->
_errno
(
"close"
);
}
error
osfile
::
stat
(
struct
stat
*
st
)
{
osfile
*
f
=
this
;
int
err
=
fstat
(
f
->
fd
,
st
);
if
(
err
!=
0
)
return
f
->
_errno
(
"stat"
);
return
nil
;
}
// _errno returns error corresponding to op and errno.
error
osfile
::
_err
(
const
char
*
op
)
{
return
errorf
(
"%s %s: %s"
,
op
,
f
->
path
,
strerror_r
(
errno
));
}
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