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
01ae0773
Commit
01ae0773
authored
Mar 04, 2020
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
daa9d2df
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
7 deletions
+36
-7
wcfs/client/client_test.py
wcfs/client/client_test.py
+17
-7
wcfs/internal/mm.pyx
wcfs/internal/mm.pyx
+19
-0
No files found.
wcfs/client/client_test.py
View file @
01ae0773
...
@@ -192,17 +192,17 @@ def test_wcfs_client_down_efault():
...
@@ -192,17 +192,17 @@ def test_wcfs_client_down_efault():
fh
=
wconn
.
open
(
zf
.
_p_oid
)
fh
=
wconn
.
open
(
zf
.
_p_oid
)
defer
(
fh
.
close
)
defer
(
fh
.
close
)
m1
=
fh
.
mmap
(
1
,
4
)
m1
=
fh
.
mmap
(
1
,
4
)
;
defer
(
m1
.
unmap
)
defer
(
m1
.
unmap
)
m2
=
fh
.
mmap
(
3
,
3
);
defer
(
m2
.
unmap
)
tm1
=
tMapping
(
t
,
m1
)
tm1
=
tMapping
(
t
,
m1
)
tm2
=
tMapping
(
t
,
m2
)
tm1
.
assertBlk
(
1
,
''
,
{})
tm1
.
assertBlk
(
1
,
''
,
{})
tm1
.
assertBlk
(
2
,
'c1'
,
{})
tm1
.
assertBlk
(
2
,
'c1'
,
{})
tm1
.
assertBlk
(
3
,
'd1'
,
{})
tm1
.
assertBlk
(
3
,
'd1'
,
{});
tm2
.
assertBlk
(
3
,
'd1'
,
{})
tm1
.
assertBlk
(
4
,
''
,
{})
tm1
.
assertBlk
(
4
,
''
,
{});
tm2
.
assertBlk
(
4
,
''
,
{})
pass
;
tm2
.
assertBlk
(
5
,
''
,
{})
with
panics
(
"not faulted"
):
tm1
.
assertBlkFaults
(
2
)
with
panics
(
"not faulted"
):
tm1
.
assertBlkFaults
(
3
)
# close fileh -> m1 must turn into efaulting memory
# close fileh -> m1 must turn into efaulting memory
fh
.
close
()
fh
.
close
()
...
@@ -210,3 +210,13 @@ def test_wcfs_client_down_efault():
...
@@ -210,3 +210,13 @@ def test_wcfs_client_down_efault():
tm1
.
assertBlkFaults
(
2
)
tm1
.
assertBlkFaults
(
2
)
tm1
.
assertBlkFaults
(
3
)
tm1
.
assertBlkFaults
(
3
)
tm1
.
assertBlkFaults
(
4
)
tm1
.
assertBlkFaults
(
4
)
# verify that read_mustfault works as expected.
def
test_read_mustfault
():
mem
=
mm
.
map_zero_ro
(
mm
.
PAGE_SIZE
)
with
panics
(
"not faulted"
):
read_mustfault
(
mem
[:
1
])
mm
.
protect
(
mem
,
mm
.
PROT_NONE
)
read_mustfault
(
mem
[:
1
])
mm
.
protect
(
mem
,
mm
.
PROT_READ
)
with
panics
(
"not faulted"
):
read_mustfault
(
mem
[:
1
])
wcfs/internal/mm.pyx
View file @
01ae0773
...
@@ -54,6 +54,11 @@ cdef extern from "<sys/user.h>":
...
@@ -54,6 +54,11 @@ cdef extern from "<sys/user.h>":
PAGE_SIZE
PAGE_SIZE
cpdef
enum
:
cpdef
enum
:
PROT_EXEC
=
mman
.
PROT_EXEC
PROT_READ
=
mman
.
PROT_READ
PROT_WRITE
=
mman
.
PROT_WRITE
PROT_NONE
=
mman
.
PROT_NONE
MLOCK_ONFAULT
=
mman
.
MLOCK_ONFAULT
MLOCK_ONFAULT
=
mman
.
MLOCK_ONFAULT
MCL_CURRENT
=
mman
.
MCL_CURRENT
MCL_CURRENT
=
mman
.
MCL_CURRENT
MCL_FUTURE
=
mman
.
MCL_FUTURE
MCL_FUTURE
=
mman
.
MCL_FUTURE
...
@@ -204,6 +209,20 @@ def advise(const unsigned char[::1] mem not None, int advice):
...
@@ -204,6 +209,20 @@ def advise(const unsigned char[::1] mem not None, int advice):
return
return
# protect sets protectionon a region of memory.
#
# see mprotect(2) for details.
def
protect
(
const
unsigned
char
[::
1
]
mem
not
None
,
int
prot
):
cdef
const
void
*
addr
=
&
mem
[
0
]
cdef
size_t
size
=
mem
.
shape
[
0
]
cdef
err
=
mman
.
mprotect
(
<
void
*>
addr
,
size
,
prot
)
if
err
:
PyErr_SetFromErrno
(
OSError
)
return
# sync asks the kernel to synchronize the file with a memory map.
# sync asks the kernel to synchronize the file with a memory map.
#
#
# see msync(2) for details.
# see msync(2) for details.
...
...
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