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
149e69a8
Commit
149e69a8
authored
Oct 21, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
b6685340
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
104 additions
and
48 deletions
+104
-48
setup.py
setup.py
+4
-1
wcfs/internal/wcfs_misc.cpp
wcfs/internal/wcfs_misc.cpp
+44
-0
wcfs/internal/wcfs_misc.h
wcfs/internal/wcfs_misc.h
+52
-0
wcfs/internal/wcfs_virtmem.cpp
wcfs/internal/wcfs_virtmem.cpp
+4
-47
No files found.
setup.py
View file @
149e69a8
...
@@ -233,7 +233,10 @@ setup(
...
@@ -233,7 +233,10 @@ setup(
_bigfile
,
_bigfile
,
PyGoExt
(
'wcfs.internal._wcfs'
,
PyGoExt
(
'wcfs.internal._wcfs'
,
[
'wcfs/internal/_wcfs.pyx'
,
'wcfs/internal/wcfs_virtmem.cpp'
],
[
'wcfs/internal/_wcfs.pyx'
,
'wcfs/internal/wcfs_virtmem.cpp'
,
'wcfs/internal/wcfs_misc.cpp'
,
],
include_dirs
=
[
# XXX -> common place
include_dirs
=
[
# XXX -> common place
'./include'
,
'./include'
,
'./3rdparty/ccan'
,
'./3rdparty/ccan'
,
...
...
wcfs/internal/wcfs_misc.cpp
0 → 100644
View file @
149e69a8
// Copyright (C) 2019 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Free Software licenses or any of the Open Source
// Initiative approved licenses and Convey the resulting work. Corresponding
// source of such a combination shall include the source code for all other
// software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
#include "wcfs_misc.h"
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
));
}
wcfs/internal/wcfs_misc.h
0 → 100644
View file @
149e69a8
// cOPYRIGHT (c) 2019 nEXEDI sa AND cONTRIBUTORS.
// kIRILL sMELKOV <KIRR@NEXEDI.COM>
//
// tHIS PROGRAM IS FREE SOFTWARE: YOU CAN uSE, sTUDY, mODIFY AND rEDISTRIBUTE
// IT UNDER THE TERMS OF THE gnu gENERAL pUBLIC lICENSE VERSION 3, OR (AT YOUR
// OPTION) ANY LATER VERSION, AS PUBLISHED BY THE fREE sOFTWARE fOUNDATION.
//
// yOU CAN ALSO lINK AND cOMBINE THIS PROGRAM WITH OTHER SOFTWARE COVERED BY
// THE TERMS OF ANY OF THE fREE sOFTWARE LICENSES OR ANY OF THE oPEN sOURCE
// iNITIATIVE APPROVED LICENSES AND cONVEY THE RESULTING WORK. cORRESPONDING
// SOURCE OF SUCH A COMBINATION SHALL INCLUDE THE SOURCE CODE FOR ALL OTHER
// SOFTWARE USED.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// wcfs_misc.{h,cpp} provide miscelanneous utilities for other wcfs_* files.
#ifndef _NXD_WCFS_MISC_H_
#define _NXD_WCFS_MISC_H_
#include <string>
using
std
::
string
;
// error mimics error from Go.
struct
error
{
string
err
;
error
()
{}
error
(
nullptr_t
)
{}
// = nil
bool
operator
==
(
nullptr_t
)
{
// == nil
return
err
.
empty
();
}
bool
operator
!=
(
nullptr_t
)
{
// != nil
return
!
(
this
==
NULL
);
}
};
// osfile mimics os.File from Go.
// its operations return error with full file context.
struct
osfile
{
int
fd
;
string
path
;
error
close
();
error
stat
(
struct
stat
*
st
);
};
#endif
wcfs/internal/wcfs_virtmem.cpp
View file @
149e69a8
...
@@ -38,6 +38,10 @@ using namespace golang;
...
@@ -38,6 +38,10 @@ using namespace golang;
#include <vector>
#include <vector>
#include <stdint.h>
#include <stdint.h>
#include "wcfs_misc.h"
template
<
typename
Key
,
typename
Value
>
template
<
typename
Key
,
typename
Value
>
using
dict
=
std
::
unordered_map
<
Key
,
Value
>
;
using
dict
=
std
::
unordered_map
<
Key
,
Value
>
;
...
@@ -256,50 +260,3 @@ void _Mapping::_remmapblk(int64_t blk, Tid at) {
...
@@ -256,50 +260,3 @@ void _Mapping::_remmapblk(int64_t blk, Tid at) {
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