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
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
wendelin.core
Commits
493ac6ce
Commit
493ac6ce
authored
Jan 24, 2022
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wcfs: client: Adjust naming for os::File to match upcoming pygolang
See
pygolang!17
parent
38dde766
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
44 deletions
+44
-44
wcfs/client/wcfs.cpp
wcfs/client/wcfs.cpp
+12
-12
wcfs/client/wcfs_misc.cpp
wcfs/client/wcfs_misc.cpp
+15
-15
wcfs/client/wcfs_misc.h
wcfs/client/wcfs_misc.h
+10
-10
wcfs/client/wcfs_watchlink.cpp
wcfs/client/wcfs_watchlink.cpp
+7
-7
No files found.
wcfs/client/wcfs.cpp
View file @
493ac6ce
// Copyright (C) 2018-202
1
Nexedi SA and Contributors.
// Copyright (C) 2018-202
2
Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
...
...
@@ -755,7 +755,7 @@ error _Conn::resync(zodb::Tid at) {
// update f._headfsize and remmap to head/f zero regions that are now covered by head/f
struct
stat
st
;
err
=
f
->
_headf
->
s
tat
(
&
st
);
err
=
f
->
_headf
->
S
tat
(
&
st
);
if
(
err
!=
nil
)
return
E
(
err
);
...
...
@@ -956,18 +956,18 @@ error _FileH::_open() {
bool
retok
=
false
;
defer
([
&
]()
{
if
(
!
retok
)
f
.
_headf
->
c
lose
();
f
.
_headf
->
C
lose
();
});
struct
stat
st
;
err
=
f
.
_headf
->
s
tat
(
&
st
);
err
=
f
.
_headf
->
S
tat
(
&
st
);
if
(
err
!=
nil
)
return
err
;
f
.
blksize
=
st
.
st_blksize
;
f
.
_headfsize
=
st
.
st_size
;
if
(
!
(
f
.
_headfsize
%
f
.
blksize
==
0
))
return
fmt
::
errorf
(
"wcfs bug: %s size (%d) %% blksize (%d) != 0"
,
v
(
f
.
_headf
->
n
ame
()),
f
.
_headfsize
,
f
.
blksize
);
v
(
f
.
_headf
->
N
ame
()),
f
.
_headfsize
,
f
.
blksize
);
// start watching f
// NOTE we are _not_ holding wconn.filehMu nor f.mmapMu - only wconn.atMu to rely on wconn.at being stable.
...
...
@@ -1066,7 +1066,7 @@ error _FileH::_closeLocked(bool force) {
panic
(
"BUG: fileh.close: wconn.filehTab[fileh.foid] != fileh"
);
wconn
->
_filehTab
.
erase
(
fileh
.
foid
);
reterr1
(
fileh
.
_headf
->
c
lose
());
reterr1
(
fileh
.
_headf
->
C
lose
());
// change all fileh.mmaps to cause EFAULT on any access after fileh.close
fileh
.
_mmapMu
.
lock
();
...
...
@@ -1110,7 +1110,7 @@ void _FileH::_afterFork() {
panic
(
"BUG: fileh.closeAfterFork: wconn.filehTab[fileh.foid] != fileh"
);
wconn
->
_filehTab
.
erase
(
fileh
.
foid
);
fileh
.
_headf
->
c
lose
();
// ignore err
fileh
.
_headf
->
C
lose
();
// ignore err
// change all fileh.mmaps to cause EFAULT on access
for
(
auto
mmap
:
fileh
.
_mmaps
)
{
...
...
@@ -1343,11 +1343,11 @@ error _Mapping::_remmapblk(int64_t blk, zodb::Tid at) {
}
defer
([
&
]()
{
if
(
fclose
)
fsfile
->
c
lose
();
fsfile
->
C
lose
();
});
struct
stat
st
;
err
=
fsfile
->
s
tat
(
&
st
);
err
=
fsfile
->
S
tat
(
&
st
);
if
(
err
!=
nil
)
return
E
(
err
);
if
((
size_t
)
st
.
st_blksize
!=
f
->
blksize
)
...
...
@@ -1426,7 +1426,7 @@ string WCFS::_path(const string &obj) {
tuple
<
os
::
File
,
error
>
WCFS
::
_open
(
const
string
&
path
,
int
flags
)
{
WCFS
&
wc
=
*
this
;
string
path_
=
wc
.
_path
(
path
);
return
os
::
o
pen
(
path_
,
flags
);
return
os
::
O
pen
(
path_
,
flags
);
}
...
...
@@ -1441,11 +1441,11 @@ static error mmap_zero_into(void *addr, size_t size, int prot) {
// this way the mapping will be able to be read, but no memory will be allocated to keep it.
os
::
File
z
;
error
err
;
tie
(
z
,
err
)
=
os
::
o
pen
(
"/dev/zero"
);
tie
(
z
,
err
)
=
os
::
O
pen
(
"/dev/zero"
);
if
(
err
!=
nil
)
return
E
(
err
);
defer
([
&
]()
{
z
->
c
lose
();
z
->
C
lose
();
});
err
=
mm
::
map_into
(
addr
,
size
,
prot
,
MAP_SHARED
|
MAP_NORESERVE
,
z
,
0
);
if
(
err
!=
nil
)
...
...
wcfs/client/wcfs_misc.cpp
View file @
493ac6ce
// Copyright (C) 2019-202
1
Nexedi SA and Contributors.
// Copyright (C) 2019-202
2
Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
...
...
@@ -49,8 +49,8 @@ global<error> ErrClosed = errors::New("file already closed");
static
error
_pathError
(
const
char
*
op
,
const
string
&
path
,
int
syserr
);
static
string
_sysErrString
(
int
syserr
);
int
_File
::
fd
()
const
{
return
_fd
;
}
string
_File
::
name
()
const
{
return
_path
;
}
int
_File
::
_sysfd
()
const
{
return
_fd
;
}
string
_File
::
Name
()
const
{
return
_path
;
}
_File
::
_File
()
{}
_File
::~
_File
()
{}
...
...
@@ -60,7 +60,7 @@ void _File::decref() {
}
tuple
<
File
,
error
>
o
pen
(
const
string
&
path
,
int
flags
,
mode_t
mode
)
{
tuple
<
File
,
error
>
O
pen
(
const
string
&
path
,
int
flags
,
mode_t
mode
)
{
int
fd
=
::
open
(
path
.
c_str
(),
flags
,
mode
);
if
(
fd
==
-
1
)
return
make_tuple
(
nil
,
_pathError
(
"open"
,
path
,
errno
));
...
...
@@ -71,7 +71,7 @@ tuple<File, error> open(const string &path, int flags, mode_t mode) {
return
make_tuple
(
f
,
nil
);
}
error
_File
::
c
lose
()
{
error
_File
::
C
lose
()
{
_File
&
f
=
*
this
;
int
err
=
::
close
(
f
.
_fd
);
...
...
@@ -81,7 +81,7 @@ error _File::close() {
return
nil
;
}
tuple
<
int
,
error
>
_File
::
r
ead
(
void
*
buf
,
size_t
count
)
{
tuple
<
int
,
error
>
_File
::
R
ead
(
void
*
buf
,
size_t
count
)
{
_File
&
f
=
*
this
;
int
n
;
...
...
@@ -94,7 +94,7 @@ tuple<int, error> _File::read(void *buf, size_t count) {
return
make_tuple
(
n
,
nil
);
}
tuple
<
int
,
error
>
_File
::
w
rite
(
const
void
*
buf
,
size_t
count
)
{
tuple
<
int
,
error
>
_File
::
W
rite
(
const
void
*
buf
,
size_t
count
)
{
_File
&
f
=
*
this
;
int
n
,
wrote
=
0
;
...
...
@@ -112,7 +112,7 @@ tuple <int, error> _File::write(const void *buf, size_t count) {
return
make_tuple
(
wrote
,
nil
);
}
error
_File
::
s
tat
(
struct
stat
*
st
)
{
error
_File
::
S
tat
(
struct
stat
*
st
)
{
_File
&
f
=
*
this
;
int
err
=
fstat
(
f
.
_fd
,
st
);
...
...
@@ -211,9 +211,9 @@ tuple<uint8_t*, error> map(int prot, int flags, os::File f, off_t offset, size_t
if
(
flags
&
MAP_FIXED
)
panic
(
"MAP_FIXED not allowed for map - use map_into"
);
addr
=
::
mmap
(
nil
,
size
,
prot
,
flags
,
f
->
fd
(),
offset
);
addr
=
::
mmap
(
nil
,
size
,
prot
,
flags
,
f
->
_sys
fd
(),
offset
);
if
(
addr
==
MAP_FAILED
)
return
make_tuple
(
nil
,
os
::
_pathError
(
"mmap"
,
f
->
n
ame
(),
errno
));
return
make_tuple
(
nil
,
os
::
_pathError
(
"mmap"
,
f
->
N
ame
(),
errno
));
return
make_tuple
((
uint8_t
*
)
addr
,
nil
);
}
...
...
@@ -224,9 +224,9 @@ tuple<uint8_t*, error> map(int prot, int flags, os::File f, off_t offset, size_t
error
map_into
(
void
*
addr
,
size_t
size
,
int
prot
,
int
flags
,
os
::
File
f
,
off_t
offset
)
{
void
*
addr2
;
addr2
=
::
mmap
(
addr
,
size
,
prot
,
MAP_FIXED
|
flags
,
f
->
fd
(),
offset
);
addr2
=
::
mmap
(
addr
,
size
,
prot
,
MAP_FIXED
|
flags
,
f
->
_sys
fd
(),
offset
);
if
(
addr2
==
MAP_FAILED
)
return
os
::
_pathError
(
"mmap"
,
f
->
n
ame
(),
errno
);
return
os
::
_pathError
(
"mmap"
,
f
->
N
ame
(),
errno
);
if
(
addr2
!=
addr
)
panic
(
"mmap(addr, MAP_FIXED): returned !addr"
);
return
nil
;
...
...
@@ -252,7 +252,7 @@ tuple<string, error> ReadFile(const string& path) {
os
::
File
f
;
error
err
;
tie
(
f
,
err
)
=
os
::
o
pen
(
path
);
tie
(
f
,
err
)
=
os
::
O
pen
(
path
);
if
(
err
!=
nil
)
return
make_tuple
(
""
,
err
);
...
...
@@ -261,7 +261,7 @@ tuple<string, error> ReadFile(const string& path) {
while
(
1
)
{
int
n
;
tie
(
n
,
err
)
=
f
->
r
ead
(
&
buf
[
0
],
buf
.
size
());
tie
(
n
,
err
)
=
f
->
R
ead
(
&
buf
[
0
],
buf
.
size
());
data
.
append
(
&
buf
[
0
],
n
);
if
(
err
!=
nil
)
{
if
(
err
==
io
::
EOF_
)
...
...
@@ -270,7 +270,7 @@ tuple<string, error> ReadFile(const string& path) {
}
}
error
err2
=
f
->
c
lose
();
error
err2
=
f
->
C
lose
();
if
(
err
==
nil
)
err
=
err2
;
if
(
err
!=
nil
)
...
...
wcfs/client/wcfs_misc.h
View file @
493ac6ce
// Copyright (C) 2019-202
1
Nexedi SA and Contributors.
// Copyright (C) 2019-202
2
Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
...
...
@@ -75,34 +75,34 @@ class _File : public object {
private:
_File
();
~
_File
();
friend
tuple
<
File
,
error
>
o
pen
(
const
string
&
path
,
int
flags
,
mode_t
mode
);
friend
tuple
<
File
,
error
>
O
pen
(
const
string
&
path
,
int
flags
,
mode_t
mode
);
public:
void
decref
();
public:
int
fd
()
const
;
string
name
()
const
;
error
c
lose
();
int
_sysfd
()
const
;
string
Name
()
const
;
error
C
lose
();
// read implements io.Reader from Go: it reads into buf up-to count bytes.
// XXX buf -> slice<byte> ?
tuple
<
int
,
error
>
r
ead
(
void
*
buf
,
size_t
count
);
tuple
<
int
,
error
>
R
ead
(
void
*
buf
,
size_t
count
);
// write implements io.Writer from Go: it writes all data from buf.
//
// NOTE write behaves like io.Writer in Go - it tries to write as much
// bytes as requested, and if it could write only less - it returns error.
// XXX buf -> slice<byte> ?
tuple
<
int
,
error
>
w
rite
(
const
void
*
buf
,
size_t
count
);
tuple
<
int
,
error
>
W
rite
(
const
void
*
buf
,
size_t
count
);
error
s
tat
(
struct
stat
*
st
);
error
S
tat
(
struct
stat
*
st
);
private:
error
_errno
(
const
char
*
op
);
};
//
o
pen opens file @path.
tuple
<
File
,
error
>
o
pen
(
const
string
&
path
,
int
flags
=
O_RDONLY
,
//
O
pen opens file @path.
tuple
<
File
,
error
>
O
pen
(
const
string
&
path
,
int
flags
=
O_RDONLY
,
mode_t
mode
=
S_IRUSR
|
S_IWUSR
|
S_IXUSR
|
S_IRGRP
|
S_IWGRP
|
S_IXGRP
|
S_IROTH
|
S_IWOTH
|
S_IXOTH
);
...
...
wcfs/client/wcfs_watchlink.cpp
View file @
493ac6ce
// Copyright (C) 2018-202
1
Nexedi SA and Contributors.
// Copyright (C) 2018-202
2
Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
...
...
@@ -94,7 +94,7 @@ error _WatchLink::close() {
errors
::
Is
(
err2
,
ErrLinkDown
))
// link shutdown due to logic error; details logged
err2
=
nil
;
error
err3
=
wlink
.
_f
->
c
lose
();
error
err3
=
wlink
.
_f
->
C
lose
();
if
(
err
==
nil
)
err
=
err2
;
if
(
err
==
nil
)
...
...
@@ -115,7 +115,7 @@ void _WatchLink::afterFork() {
// _serveRX is not running. Just release the file handle, that fork
// duplicated, to make sure that child cannot send anything to wcfs and
// interfere into parent-wcfs exchange.
wlink
.
_f
->
c
lose
();
// ignore err
wlink
.
_f
->
C
lose
();
// ignore err
}
// closeWrite closes send half of the link.
...
...
@@ -386,7 +386,7 @@ error _WatchLink::_write(const string &pkt) {
int
n
;
error
err
;
tie
(
n
,
err
)
=
wlink
.
_f
->
w
rite
(
pkt
.
c_str
(),
pkt
.
size
());
tie
(
n
,
err
)
=
wlink
.
_f
->
W
rite
(
pkt
.
c_str
(),
pkt
.
size
());
return
err
;
}
...
...
@@ -454,7 +454,7 @@ tuple<string, error> _WatchLink::_readline() {
int
n
;
error
err
;
tie
(
n
,
err
)
=
wlink
.
_f
->
r
ead
(
buf
,
sizeof
(
buf
));
tie
(
n
,
err
)
=
wlink
.
_f
->
R
ead
(
buf
,
sizeof
(
buf
));
if
(
n
>
0
)
{
wlink
.
_rxbuf
+=
string
(
buf
,
n
);
continue
;
...
...
@@ -515,12 +515,12 @@ void _WatchLink::decref() {
string
_WatchLink
::
String
()
const
{
const
_WatchLink
&
wlink
=
*
this
;
// XXX don't include wcfs as prefix here? (see Conn.String for details)
return
fmt
::
sprintf
(
"%s: wlink%d"
,
v
(
wlink
.
_wc
),
wlink
.
_f
->
fd
());
return
fmt
::
sprintf
(
"%s: wlink%d"
,
v
(
wlink
.
_wc
),
wlink
.
_f
->
_sys
fd
());
}
int
_WatchLink
::
fd
()
const
{
const
_WatchLink
&
wlink
=
*
this
;
return
wlink
.
_f
->
fd
();
return
wlink
.
_f
->
_sys
fd
();
}
// _nextReqID returns stream ID for next client-originating request to be made.
...
...
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