Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tarantool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
tarantool
Commits
e5cf6894
Commit
e5cf6894
authored
10 years ago
by
Konstantin Osipov
Browse files
Options
Downloads
Patches
Plain Diff
'fio' (cooperative file I/O) package: style fixes
Add comments, renames.
parent
a91a418c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
src/coeio_file.cc
+30
-24
30 additions, 24 deletions
src/coeio_file.cc
src/coeio_file.h
+11
-3
11 additions, 3 deletions
src/coeio_file.h
src/lua/fio.cc
+133
-140
133 additions, 140 deletions
src/lua/fio.cc
src/lua/fio.h
+1
-1
1 addition, 1 deletion
src/lua/fio.h
src/lua/init.cc
+1
-1
1 addition, 1 deletion
src/lua/init.cc
with
176 additions
and
169 deletions
src/coeio_file.cc
+
30
−
24
View file @
e5cf6894
...
...
@@ -27,14 +27,18 @@
* SUCH DAMAGE.
*/
#include
<
coeio_file.h
>
#include
<
coeio.h
>
#include
<
fiber.h
>
#include
<
say.h
>
#include
"
coeio_file.h
"
#include
"
coeio.h
"
#include
"
fiber.h
"
#include
"
say.h
"
#include
<stdio.h>
#include
<stdlib.h>
/**
* A context of libeio request for any
* coeio_file task.
*/
struct
coeio_file_task
{
ssize_t
result
;
int
errorno
;
...
...
@@ -91,10 +95,10 @@ struct coeio_file_task {
#define INIT_COEIO_FILE(name) \
struct coeio_file_task name; \
memset(&name, 0, sizeof(name)); \
name.fiber = fiber(); \
memset(&name, 0, sizeof(name)); \
name.fiber = fiber(); \
/** A callback invoked by eio when a task is complete. */
static
int
coeio_file_complete
(
eio_req
*
req
)
{
...
...
@@ -108,6 +112,10 @@ coeio_file_complete(eio_req *req)
return
0
;
}
/**
* Synchronously (from cooperative multitasking point of view)
* wait for task completion.
*/
static
ssize_t
coeio_file_wait_done
(
eio_req
*
req
,
struct
coeio_file_task
*
eio
)
{
...
...
@@ -127,8 +135,8 @@ int
coeio_file_open
(
const
char
*
path
,
int
flags
,
mode_t
mode
)
{
INIT_COEIO_FILE
(
eio
);
eio_req
*
req
=
eio_open
(
path
,
flags
,
mode
,
0
,
coeio_file_complete
,
&
eio
);
eio_req
*
req
=
eio_open
(
path
,
flags
,
mode
,
0
,
coeio_file_complete
,
&
eio
);
return
coeio_file_wait_done
(
req
,
&
eio
);
}
...
...
@@ -144,8 +152,8 @@ ssize_t
coeio_file_pwrite
(
int
fd
,
const
void
*
buf
,
size_t
count
,
off_t
offset
)
{
INIT_COEIO_FILE
(
eio
);
eio_req
*
req
=
eio_write
(
fd
,
(
void
*
)
buf
,
count
,
offset
,
0
,
coeio_file_complete
,
&
eio
);
eio_req
*
req
=
eio_write
(
fd
,
(
void
*
)
buf
,
count
,
offset
,
0
,
coeio_file_complete
,
&
eio
);
return
coeio_file_wait_done
(
req
,
&
eio
);
}
...
...
@@ -154,7 +162,7 @@ coeio_file_pread(int fd, void *buf, size_t count, off_t offset)
{
INIT_COEIO_FILE
(
eio
);
eio_req
*
req
=
eio_read
(
fd
,
buf
,
count
,
offset
,
0
,
coeio_file_complete
,
&
eio
);
offset
,
0
,
coeio_file_complete
,
&
eio
);
return
coeio_file_wait_done
(
req
,
&
eio
);
}
...
...
@@ -174,7 +182,7 @@ coeio_file_write(int fd, const void *buf, size_t count)
eio
.
write
.
count
=
count
;
eio
.
write
.
fd
=
fd
;
eio_req
*
req
=
eio_custom
(
coeio_file_do_write
,
0
,
coeio_file_complete
,
&
eio
);
coeio_file_complete
,
&
eio
);
return
coeio_file_wait_done
(
req
,
&
eio
);
}
...
...
@@ -194,7 +202,7 @@ coeio_file_read(int fd, void *buf, size_t count)
eio
.
read
.
count
=
count
;
eio
.
read
.
fd
=
fd
;
eio_req
*
req
=
eio_custom
(
coeio_file_do_read
,
0
,
coeio_file_complete
,
&
eio
);
coeio_file_complete
,
&
eio
);
return
coeio_file_wait_done
(
req
,
&
eio
);
}
...
...
@@ -218,7 +226,7 @@ coeio_file_lseek(int fd, off_t offset, int whence)
eio
.
lseek
.
fd
=
fd
;
eio_req
*
req
=
eio_custom
(
coeio_file_do_lseek
,
0
,
coeio_file_complete
,
&
eio
);
coeio_file_complete
,
&
eio
);
return
coeio_file_wait_done
(
req
,
&
eio
);
}
...
...
@@ -230,7 +238,6 @@ coeio_file_do_lstat(eio_req *req)
req
->
errorno
=
errno
;
}
int
coeio_file_lstat
(
const
char
*
pathname
,
struct
stat
*
buf
)
{
...
...
@@ -238,7 +245,7 @@ coeio_file_lstat(const char *pathname, struct stat *buf)
eio
.
lstat
.
pathname
=
pathname
;
eio
.
lstat
.
buf
=
buf
;
eio_req
*
req
=
eio_custom
(
coeio_file_do_lstat
,
0
,
coeio_file_complete
,
&
eio
);
coeio_file_complete
,
&
eio
);
return
coeio_file_wait_done
(
req
,
&
eio
);
}
...
...
@@ -257,7 +264,7 @@ coeio_file_stat(const char *pathname, struct stat *buf)
eio
.
lstat
.
pathname
=
pathname
;
eio
.
lstat
.
buf
=
buf
;
eio_req
*
req
=
eio_custom
(
coeio_file_do_stat
,
0
,
coeio_file_complete
,
&
eio
);
coeio_file_complete
,
&
eio
);
return
coeio_file_wait_done
(
req
,
&
eio
);
}
...
...
@@ -277,7 +284,7 @@ coeio_file_fstat(int fd, struct stat *stat)
eio
.
fstat
.
buf
=
stat
;
eio_req
*
req
=
eio_custom
(
coeio_file_do_fstat
,
0
,
coeio_file_complete
,
&
eio
);
coeio_file_complete
,
&
eio
);
return
coeio_file_wait_done
(
req
,
&
eio
);
}
...
...
@@ -286,7 +293,7 @@ coeio_file_rename(const char *oldpath, const char *newpath)
{
INIT_COEIO_FILE
(
eio
);
eio_req
*
req
=
eio_rename
(
oldpath
,
newpath
,
0
,
coeio_file_complete
,
&
eio
);
coeio_file_complete
,
&
eio
);
return
coeio_file_wait_done
(
req
,
&
eio
);
}
...
...
@@ -320,7 +327,7 @@ coeio_file_do_glob(eio_req *req)
{
struct
coeio_file_task
*
eio
=
(
struct
coeio_file_task
*
)
req
->
data
;
req
->
result
=
glob
(
eio
->
glob
.
pattern
,
eio
->
glob
.
flags
,
eio
->
glob
.
errfunc
,
eio
->
glob
.
pglob
);
eio
->
glob
.
flags
,
eio
->
glob
.
errfunc
,
eio
->
glob
.
pglob
);
req
->
errorno
=
errno
;
}
...
...
@@ -394,7 +401,7 @@ coeio_file_do_readlink(eio_req *req)
{
struct
coeio_file_task
*
eio
=
(
struct
coeio_file_task
*
)
req
->
data
;
req
->
result
=
readlink
(
eio
->
readlink
.
pathname
,
eio
->
readlink
.
buf
,
eio
->
readlink
.
bufsize
);
eio
->
readlink
.
buf
,
eio
->
readlink
.
bufsize
);
req
->
errorno
=
errno
;
}
...
...
@@ -406,7 +413,7 @@ coeio_file_readlink(const char *pathname, char *buf, size_t bufsize)
eio
.
readlink
.
buf
=
buf
;
eio
.
readlink
.
bufsize
=
bufsize
;
eio_req
*
req
=
eio_custom
(
coeio_file_do_readlink
,
0
,
coeio_file_complete
,
&
eio
);
coeio_file_complete
,
&
eio
);
return
coeio_file_wait_done
(
req
,
&
eio
);
}
...
...
@@ -423,7 +430,6 @@ coeio_file_do_tempdir(eio_req *req)
}
}
int
coeio_file_tempdir
(
char
*
path
,
size_t
path_len
)
{
...
...
This diff is collapsed.
Click to expand it.
src/coeio_file.h
+
11
−
3
View file @
e5cf6894
...
...
@@ -32,6 +32,15 @@
#include
<sys/types.h>
#include
<glob.h>
/**
* Cooperative file I/O.
* Unlike the rest of coeio API, this implementation
* doesn't support timeouts or cancellation.
*
* It follows the error reporting convention of the respective
* system calls, i.e. it doesn't throw exceptions either.
*/
int
coeio_file_open
(
const
char
*
path
,
int
flags
,
mode_t
mode
);
int
coeio_file_close
(
int
fd
);
...
...
@@ -51,8 +60,8 @@ int coeio_file_rmdir(const char *pathname);
int
coeio_file_ftruncate
(
int
fd
,
off_t
length
);
int
coeio_file_truncate
(
const
char
*
path
,
off_t
length
);
int
coeio_file_glob
(
const
char
*
pattern
,
int
flags
,
int
(
*
errfunc
)
(
const
char
*
epath
,
int
eerrno
),
glob_t
*
pglob
);
int
(
*
errfunc
)
(
const
char
*
epath
,
int
eerrno
),
glob_t
*
pglob
);
int
coeio_file_chown
(
const
char
*
path
,
uid_t
owner
,
gid_t
group
);
int
coeio_file_chmod
(
const
char
*
path
,
mode_t
mode
);
...
...
@@ -64,7 +73,6 @@ int coeio_file_sync();
int
coeio_file_fsync
(
int
fd
);
int
coeio_file_fdatasync
(
int
fd
);
int
coeio_file_tempdir
(
char
*
path
,
size_t
path_len
);
#endif
/* INCLUDES_TARANTOOL_COEIO_FILE_H */
This diff is collapsed.
Click to expand it.
src/lua/fio.cc
+
133
−
140
View file @
e5cf6894
...
...
@@ -26,6 +26,7 @@
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include
"lua/fio.h"
#include
<sys/types.h>
#include
<sys/stat.h>
#include
<pwd.h>
...
...
@@ -34,9 +35,8 @@
#include
<unistd.h>
#include
<glob.h>
#include
<time.h>
#include
"lua/fio.h"
#include
<coeio.h>
#include
<fiber.h>
#include
"coeio.h"
#include
"fiber.h"
extern
"C"
{
#include
<lua.h>
...
...
@@ -44,11 +44,10 @@ extern "C" {
#include
<lualib.h>
}
#include
"lua/utils.h"
#include
<coeio_file.h>
#include
"coeio_file.h"
static
int
fio_lua
_open
(
struct
lua_State
*
L
)
lbox_fio
_open
(
struct
lua_State
*
L
)
{
const
char
*
path
=
lua_tostring
(
L
,
1
);
int
flags
=
lua_tointeger
(
L
,
2
);
...
...
@@ -59,9 +58,8 @@ fio_lua_open(struct lua_State *L)
return
1
;
}
static
int
fio_lua
_pwrite
(
struct
lua_State
*
L
)
lbox_fio
_pwrite
(
struct
lua_State
*
L
)
{
int
fh
=
lua_tointeger
(
L
,
1
);
const
char
*
buf
=
lua_tostring
(
L
,
2
);
...
...
@@ -73,9 +71,8 @@ fio_lua_pwrite(struct lua_State *L)
return
1
;
}
static
int
fio_lua
_pread
(
struct
lua_State
*
L
)
lbox_fio
_pread
(
struct
lua_State
*
L
)
{
int
fh
=
lua_tointeger
(
L
,
1
);
size_t
len
=
lua_tonumber
(
L
,
2
);
...
...
@@ -109,12 +106,12 @@ fio_lua_pread(struct lua_State *L)
}
static
int
fio_lua
_rename
(
struct
lua_State
*
L
)
lbox_fio
_rename
(
struct
lua_State
*
L
)
{
const
char
*
oldpath
,
*
newpath
;
int
top
=
lua_gettop
(
L
);
if
(
top
<
2
||
!
(
oldpath
=
lua_tostring
(
L
,
1
))
||
!
(
newpath
=
lua_tostring
(
L
,
2
)))
{
!
(
newpath
=
lua_tostring
(
L
,
2
)))
{
luaL_error
(
L
,
"Usage: fio.rename(oldpath, newpath)"
);
return
0
;
}
...
...
@@ -124,7 +121,7 @@ fio_lua_rename(struct lua_State *L)
}
static
int
fio_lua
_unlink
(
struct
lua_State
*
L
)
lbox_fio
_unlink
(
struct
lua_State
*
L
)
{
if
(
lua_gettop
(
L
)
<
1
)
luaL_error
(
L
,
"Usage: fio.unlink(pathname)"
);
...
...
@@ -140,7 +137,7 @@ fio_lua_unlink(struct lua_State *L)
}
static
int
fio_lua
_ftruncate
(
struct
lua_State
*
L
)
lbox_fio
_ftruncate
(
struct
lua_State
*
L
)
{
int
fd
=
lua_tointeger
(
L
,
1
);
off_t
length
=
lua_tonumber
(
L
,
2
);
...
...
@@ -150,7 +147,7 @@ fio_lua_ftruncate(struct lua_State *L)
}
static
int
fio_lua
_truncate
(
struct
lua_State
*
L
)
lbox_fio
_truncate
(
struct
lua_State
*
L
)
{
int
top
=
lua_gettop
(
L
);
if
(
top
<
1
)
...
...
@@ -168,7 +165,7 @@ fio_lua_truncate(struct lua_State *L)
}
static
int
fio_lua
_write
(
struct
lua_State
*
L
)
lbox_fio
_write
(
struct
lua_State
*
L
)
{
int
fh
=
lua_tointeger
(
L
,
1
);
const
char
*
buf
=
lua_tostring
(
L
,
2
);
...
...
@@ -179,7 +176,7 @@ fio_lua_write(struct lua_State *L)
}
static
int
fio_lua
_chown
(
struct
lua_State
*
L
)
lbox_fio
_chown
(
struct
lua_State
*
L
)
{
if
(
lua_gettop
(
L
)
<
3
)
luaL_error
(
L
,
"Usage: fio.chown(pathname, owner, group)"
);
...
...
@@ -217,7 +214,7 @@ fio_lua_chown(struct lua_State *L)
}
static
int
fio_lua
_chmod
(
struct
lua_State
*
L
)
lbox_fio
_chmod
(
struct
lua_State
*
L
)
{
if
(
lua_gettop
(
L
)
<
2
)
luaL_error
(
L
,
"Usage: fio.chmod(pathname, mode)"
);
...
...
@@ -228,7 +225,7 @@ fio_lua_chmod(struct lua_State *L)
}
static
int
fio_lua
_read
(
struct
lua_State
*
L
)
lbox_fio
_read
(
struct
lua_State
*
L
)
{
int
fh
=
lua_tointeger
(
L
,
1
);
size_t
len
=
lua_tonumber
(
L
,
2
);
...
...
@@ -260,7 +257,7 @@ fio_lua_read(struct lua_State *L)
}
static
int
fio_lua
_lseek
(
struct
lua_State
*
L
)
lbox_fio
_lseek
(
struct
lua_State
*
L
)
{
int
fh
=
lua_tointeger
(
L
,
1
);
off_t
offset
=
lua_tonumber
(
L
,
2
);
...
...
@@ -271,7 +268,7 @@ fio_lua_lseek(struct lua_State *L)
}
static
int
fio_lua
_pushtimespec
(
struct
lua_State
*
L
,
const
struct
timespec
*
ts
)
lbox_fio
_pushtimespec
(
struct
lua_State
*
L
,
const
struct
timespec
*
ts
)
{
double
nsec
=
ts
->
tv_nsec
;
nsec
/=
1000000000
;
...
...
@@ -286,7 +283,7 @@ fio_lua_pushtimespec(struct lua_State *L, const struct timespec *ts)
}
static
int
fio_lua
_pushstat
(
struct
lua_State
*
L
,
const
struct
stat
*
stat
)
lbox_fio
_pushstat
(
struct
lua_State
*
L
,
const
struct
stat
*
stat
)
{
lua_newtable
(
L
);
...
...
@@ -300,15 +297,14 @@ fio_lua_pushstat(struct lua_State *L, const struct stat *stat)
PUSHTABLE
(
"size"
,
lua_pushinteger
,
stat
->
st_size
);
PUSHTABLE
(
"blksize"
,
lua_pushinteger
,
stat
->
st_blksize
);
PUSHTABLE
(
"blocks"
,
lua_pushinteger
,
stat
->
st_blocks
);
PUSHTABLE
(
"ctime"
,
fio_lua
_pushtimespec
,
&
stat
->
st_ctim
);
PUSHTABLE
(
"mtime"
,
fio_lua
_pushtimespec
,
&
stat
->
st_mtim
);
PUSHTABLE
(
"atime"
,
fio_lua
_pushtimespec
,
&
stat
->
st_atim
);
PUSHTABLE
(
"ctime"
,
lbox_fio
_pushtimespec
,
&
stat
->
st_ctim
);
PUSHTABLE
(
"mtime"
,
lbox_fio
_pushtimespec
,
&
stat
->
st_mtim
);
PUSHTABLE
(
"atime"
,
lbox_fio
_pushtimespec
,
&
stat
->
st_atim
);
return
1
;
}
static
int
fio_lua
_lstat
(
struct
lua_State
*
L
)
lbox_fio
_lstat
(
struct
lua_State
*
L
)
{
if
(
lua_gettop
(
L
)
<
1
)
luaL_error
(
L
,
"pathname is absent"
);
...
...
@@ -320,11 +316,11 @@ fio_lua_lstat(struct lua_State *L)
lua_pushnil
(
L
);
return
1
;
}
return
fio_lua
_pushstat
(
L
,
&
stat
);
return
lbox_fio
_pushstat
(
L
,
&
stat
);
}
static
int
fio_lua
_stat
(
struct
lua_State
*
L
)
lbox_fio
_stat
(
struct
lua_State
*
L
)
{
if
(
lua_gettop
(
L
)
<
1
)
luaL_error
(
L
,
"pathname is absent"
);
...
...
@@ -336,11 +332,11 @@ fio_lua_stat(struct lua_State *L)
lua_pushnil
(
L
);
return
1
;
}
return
fio_lua
_pushstat
(
L
,
&
stat
);
return
lbox_fio
_pushstat
(
L
,
&
stat
);
}
static
int
fio_lua
_fstat
(
struct
lua_State
*
L
)
lbox_fio
_fstat
(
struct
lua_State
*
L
)
{
int
fd
=
lua_tointeger
(
L
,
1
);
struct
stat
stat
;
...
...
@@ -349,12 +345,12 @@ fio_lua_fstat(struct lua_State *L)
lua_pushnil
(
L
);
return
1
;
}
return
fio_lua
_pushstat
(
L
,
&
stat
);
return
lbox_fio
_pushstat
(
L
,
&
stat
);
}
static
int
fio_lua
_mkdir
(
struct
lua_State
*
L
)
lbox_fio
_mkdir
(
struct
lua_State
*
L
)
{
const
char
*
pathname
;
int
top
=
lua_gettop
(
L
);
...
...
@@ -375,7 +371,7 @@ fio_lua_mkdir(struct lua_State *L)
}
static
int
fio_lua
_rmdir
(
struct
lua_State
*
L
)
lbox_fio
_rmdir
(
struct
lua_State
*
L
)
{
const
char
*
pathname
;
if
(
lua_gettop
(
L
)
<
1
||
!
(
pathname
=
lua_tostring
(
L
,
1
)))
{
...
...
@@ -388,7 +384,7 @@ fio_lua_rmdir(struct lua_State *L)
}
static
int
fio_lua
_glob
(
struct
lua_State
*
L
)
lbox_fio
_glob
(
struct
lua_State
*
L
)
{
if
(
lua_gettop
(
L
)
<
1
)
luaL_error
(
L
,
"Usage: fio.glob(pattern)"
);
...
...
@@ -397,17 +393,17 @@ fio_lua_glob(struct lua_State *L)
glob_t
globbuf
;
switch
(
glob
(
pattern
,
GLOB_NOESCAPE
,
NULL
,
&
globbuf
))
{
case
0
:
break
;
case
GLOB_NOMATCH
:
lua_newtable
(
L
);
return
1
;
case
0
:
break
;
case
GLOB_NOMATCH
:
lua_newtable
(
L
);
return
1
;
default:
case
GLOB_NOSPACE
:
errno
=
ENOMEM
;
lua_pushnil
(
L
);
return
1
;
default:
case
GLOB_NOSPACE
:
errno
=
ENOMEM
;
lua_pushnil
(
L
);
return
1
;
}
lua_newtable
(
L
);
...
...
@@ -423,7 +419,7 @@ fio_lua_glob(struct lua_State *L)
}
static
int
fio_lua
_link
(
struct
lua_State
*
L
)
lbox_fio
_link
(
struct
lua_State
*
L
)
{
if
(
lua_gettop
(
L
)
<
2
)
luaL_error
(
L
,
"Usage: fio.link(target, linkpath)"
);
...
...
@@ -434,7 +430,7 @@ fio_lua_link(struct lua_State *L)
}
static
int
fio_lua
_symlink
(
struct
lua_State
*
L
)
lbox_fio
_symlink
(
struct
lua_State
*
L
)
{
if
(
lua_gettop
(
L
)
<
2
)
luaL_error
(
L
,
"Usage: fio.symlink(target, linkpath)"
);
...
...
@@ -445,7 +441,7 @@ fio_lua_symlink(struct lua_State *L)
}
static
int
fio_lua
_readlink
(
struct
lua_State
*
L
)
lbox_fio
_readlink
(
struct
lua_State
*
L
)
{
if
(
lua_gettop
(
L
)
<
1
)
luaL_error
(
L
,
"Usage: fio.readlink(pathname)"
);
...
...
@@ -463,7 +459,7 @@ fio_lua_readlink(struct lua_State *L)
}
static
int
fio_lua
_tempdir
(
struct
lua_State
*
L
)
lbox_fio
_tempdir
(
struct
lua_State
*
L
)
{
char
*
buf
=
(
char
*
)
lua_newuserdata
(
L
,
PATH_MAX
);
if
(
!
buf
)
{
...
...
@@ -483,7 +479,7 @@ fio_lua_tempdir(struct lua_State *L)
}
static
int
fio_lua
_fsync
(
struct
lua_State
*
L
)
lbox_fio
_fsync
(
struct
lua_State
*
L
)
{
int
fd
=
lua_tointeger
(
L
,
1
);
lua_pushboolean
(
L
,
coeio_file_fsync
(
fd
)
==
0
);
...
...
@@ -491,7 +487,7 @@ fio_lua_fsync(struct lua_State *L)
}
static
int
fio_lua
_fdatasync
(
struct
lua_State
*
L
)
lbox_fio
_fdatasync
(
struct
lua_State
*
L
)
{
int
fd
=
lua_tointeger
(
L
,
1
);
lua_pushboolean
(
L
,
coeio_file_fdatasync
(
fd
)
==
0
);
...
...
@@ -499,14 +495,14 @@ fio_lua_fdatasync(struct lua_State *L)
}
static
int
fio_lua
_sync
(
struct
lua_State
*
L
)
lbox_fio
_sync
(
struct
lua_State
*
L
)
{
lua_pushboolean
(
L
,
coeio_file_sync
()
==
0
);
return
1
;
}
static
int
fio_lua
_close
(
struct
lua_State
*
L
)
lbox_fio
_close
(
struct
lua_State
*
L
)
{
int
fd
=
lua_tointeger
(
L
,
1
);
lua_pushboolean
(
L
,
coeio_file_close
(
fd
)
==
0
);
...
...
@@ -514,25 +510,24 @@ fio_lua_close(struct lua_State *L)
}
void
fio_lua
_init
(
struct
lua_State
*
L
)
tarantool_lua_fio
_init
(
struct
lua_State
*
L
)
{
static
const
struct
luaL_Reg
fio_methods
[]
=
{
{
"lstat"
,
fio_lua_lstat
},
{
"stat"
,
fio_lua_stat
},
{
"mkdir"
,
fio_lua_mkdir
},
{
"rmdir"
,
fio_lua_rmdir
},
{
"glob"
,
fio_lua_glob
},
{
"link"
,
fio_lua_link
},
{
"symlink"
,
fio_lua_symlink
},
{
"readlink"
,
fio_lua_readlink
},
{
"unlink"
,
fio_lua_unlink
},
{
"rename"
,
fio_lua_rename
},
{
"chown"
,
fio_lua_chown
},
{
"chmod"
,
fio_lua_chmod
},
{
"truncate"
,
fio_lua_truncate
},
{
"tempdir"
,
fio_lua_tempdir
},
{
"sync"
,
fio_lua_sync
},
{
"lstat"
,
lbox_fio_lstat
},
{
"stat"
,
lbox_fio_stat
},
{
"mkdir"
,
lbox_fio_mkdir
},
{
"rmdir"
,
lbox_fio_rmdir
},
{
"glob"
,
lbox_fio_glob
},
{
"link"
,
lbox_fio_link
},
{
"symlink"
,
lbox_fio_symlink
},
{
"readlink"
,
lbox_fio_readlink
},
{
"unlink"
,
lbox_fio_unlink
},
{
"rename"
,
lbox_fio_rename
},
{
"chown"
,
lbox_fio_chown
},
{
"chmod"
,
lbox_fio_chmod
},
{
"truncate"
,
lbox_fio_truncate
},
{
"tempdir"
,
lbox_fio_tempdir
},
{
"sync"
,
lbox_fio_sync
},
{
NULL
,
NULL
}
};
...
...
@@ -544,19 +539,17 @@ fio_lua_init(struct lua_State *L)
lua_pushliteral
(
L
,
"internal"
);
lua_newtable
(
L
);
static
const
struct
luaL_Reg
internal_methods
[]
=
{
{
"open"
,
fio_lua_open
},
{
"close"
,
fio_lua_close
},
{
"pwrite"
,
fio_lua_pwrite
},
{
"pread"
,
fio_lua_pread
},
{
"read"
,
fio_lua_read
},
{
"write"
,
fio_lua_write
},
{
"lseek"
,
fio_lua_lseek
},
{
"ftruncate"
,
fio_lua_ftruncate
},
{
"fsync"
,
fio_lua_fsync
},
{
"fdatasync"
,
fio_lua_fdatasync
},
{
"fstat"
,
fio_lua_fstat
},
{
"open"
,
lbox_fio_open
},
{
"close"
,
lbox_fio_close
},
{
"pwrite"
,
lbox_fio_pwrite
},
{
"pread"
,
lbox_fio_pread
},
{
"read"
,
lbox_fio_read
},
{
"write"
,
lbox_fio_write
},
{
"lseek"
,
lbox_fio_lseek
},
{
"ftruncate"
,
lbox_fio_ftruncate
},
{
"fsync"
,
lbox_fio_fsync
},
{
"fdatasync"
,
lbox_fio_fdatasync
},
{
"fstat"
,
lbox_fio_fstat
},
{
NULL
,
NULL
}
};
luaL_register
(
L
,
NULL
,
internal_methods
);
...
...
@@ -569,57 +562,57 @@ fio_lua_init(struct lua_State *L)
lua_pushliteral
(
L
,
"flag"
);
lua_newtable
(
L
);
#ifdef O_APPEND
PUSHTABLE
(
"O_APPEND"
,
lua_pushinteger
,
O_APPEND
);
#endif
#ifdef O_ASYNC
PUSHTABLE
(
"O_ASYNC"
,
lua_pushinteger
,
O_ASYNC
);
#endif
#ifdef O_CLOEXEC
PUSHTABLE
(
"O_CLOEXEC"
,
lua_pushinteger
,
O_CLOEXEC
);
#endif
#ifdef O_CREAT
PUSHTABLE
(
"O_CREAT"
,
lua_pushinteger
,
O_CREAT
);
#endif
#ifdef O_DIRECT
PUSHTABLE
(
"O_DIRECT"
,
lua_pushinteger
,
O_DIRECT
);
#endif
#ifdef O_DIRECTORY
PUSHTABLE
(
"O_DIRECTORY"
,
lua_pushinteger
,
O_DIRECTORY
);
#endif
#ifdef O_EXCL
PUSHTABLE
(
"O_EXCL"
,
lua_pushinteger
,
O_EXCL
);
#endif
#ifdef O_LARGEFILE
PUSHTABLE
(
"O_LARGEFILE"
,
lua_pushinteger
,
O_LARGEFILE
);
#endif
#ifdef O_NOATIME
PUSHTABLE
(
"O_NOATIME"
,
lua_pushinteger
,
O_NOATIME
);
#endif
#ifdef O_NOCTTY
PUSHTABLE
(
"O_NOCTTY"
,
lua_pushinteger
,
O_NOCTTY
);
#endif
#ifdef O_NOFOLLOW
PUSHTABLE
(
"O_NOFOLLOW"
,
lua_pushinteger
,
O_NOFOLLOW
);
#endif
#ifdef O_NONBLOCK
PUSHTABLE
(
"O_NONBLOCK"
,
lua_pushinteger
,
O_NONBLOCK
);
#endif
#ifdef O_NDELAY
PUSHTABLE
(
"O_NDELAY"
,
lua_pushinteger
,
O_NDELAY
);
#endif
#ifdef O_PATH
PUSHTABLE
(
"O_PATH"
,
lua_pushinteger
,
O_PATH
);
#endif
#ifdef O_SYNC
PUSHTABLE
(
"O_SYNC"
,
lua_pushinteger
,
O_SYNC
);
#endif
#ifdef O_TMPFILE
PUSHTABLE
(
"O_TMPFILE"
,
lua_pushinteger
,
O_TMPFILE
);
#endif
#ifdef O_TRUNC
PUSHTABLE
(
"O_TRUNC"
,
lua_pushinteger
,
O_TRUNC
);
#endif
#ifdef O_APPEND
PUSHTABLE
(
"O_APPEND"
,
lua_pushinteger
,
O_APPEND
);
#endif
#ifdef O_ASYNC
PUSHTABLE
(
"O_ASYNC"
,
lua_pushinteger
,
O_ASYNC
);
#endif
#ifdef O_CLOEXEC
PUSHTABLE
(
"O_CLOEXEC"
,
lua_pushinteger
,
O_CLOEXEC
);
#endif
#ifdef O_CREAT
PUSHTABLE
(
"O_CREAT"
,
lua_pushinteger
,
O_CREAT
);
#endif
#ifdef O_DIRECT
PUSHTABLE
(
"O_DIRECT"
,
lua_pushinteger
,
O_DIRECT
);
#endif
#ifdef O_DIRECTORY
PUSHTABLE
(
"O_DIRECTORY"
,
lua_pushinteger
,
O_DIRECTORY
);
#endif
#ifdef O_EXCL
PUSHTABLE
(
"O_EXCL"
,
lua_pushinteger
,
O_EXCL
);
#endif
#ifdef O_LARGEFILE
PUSHTABLE
(
"O_LARGEFILE"
,
lua_pushinteger
,
O_LARGEFILE
);
#endif
#ifdef O_NOATIME
PUSHTABLE
(
"O_NOATIME"
,
lua_pushinteger
,
O_NOATIME
);
#endif
#ifdef O_NOCTTY
PUSHTABLE
(
"O_NOCTTY"
,
lua_pushinteger
,
O_NOCTTY
);
#endif
#ifdef O_NOFOLLOW
PUSHTABLE
(
"O_NOFOLLOW"
,
lua_pushinteger
,
O_NOFOLLOW
);
#endif
#ifdef O_NONBLOCK
PUSHTABLE
(
"O_NONBLOCK"
,
lua_pushinteger
,
O_NONBLOCK
);
#endif
#ifdef O_NDELAY
PUSHTABLE
(
"O_NDELAY"
,
lua_pushinteger
,
O_NDELAY
);
#endif
#ifdef O_PATH
PUSHTABLE
(
"O_PATH"
,
lua_pushinteger
,
O_PATH
);
#endif
#ifdef O_SYNC
PUSHTABLE
(
"O_SYNC"
,
lua_pushinteger
,
O_SYNC
);
#endif
#ifdef O_TMPFILE
PUSHTABLE
(
"O_TMPFILE"
,
lua_pushinteger
,
O_TMPFILE
);
#endif
#ifdef O_TRUNC
PUSHTABLE
(
"O_TRUNC"
,
lua_pushinteger
,
O_TRUNC
);
#endif
PUSHTABLE
(
"O_RDONLY"
,
lua_pushinteger
,
O_RDONLY
);
PUSHTABLE
(
"O_WRONLY"
,
lua_pushinteger
,
O_WRONLY
);
PUSHTABLE
(
"O_RDWR"
,
lua_pushinteger
,
O_RDWR
);
...
...
@@ -647,12 +640,12 @@ fio_lua_init(struct lua_State *L)
PUSHTABLE
(
"SEEK_SET"
,
lua_pushinteger
,
SEEK_SET
);
PUSHTABLE
(
"SEEK_CUR"
,
lua_pushinteger
,
SEEK_CUR
);
PUSHTABLE
(
"SEEK_END"
,
lua_pushinteger
,
SEEK_END
);
#ifdef SEEK_DATA
PUSHTABLE
(
"SEEK_DATA"
,
lua_pushinteger
,
SEEK_DATA
);
#endif
#ifdef SEEK_HOLE
PUSHTABLE
(
"SEEK_HOLE"
,
lua_pushinteger
,
SEEK_HOLE
);
#endif
#ifdef SEEK_DATA
PUSHTABLE
(
"SEEK_DATA"
,
lua_pushinteger
,
SEEK_DATA
);
#endif
#ifdef SEEK_HOLE
PUSHTABLE
(
"SEEK_HOLE"
,
lua_pushinteger
,
SEEK_HOLE
);
#endif
lua_settable
(
L
,
-
3
);
...
...
This diff is collapsed.
Click to expand it.
src/lua/fio.h
+
1
−
1
View file @
e5cf6894
...
...
@@ -30,6 +30,6 @@
*/
struct
lua_State
;
void
fio_lua
_init
(
struct
lua_State
*
L
);
void
tarantool_lua_fio
_init
(
struct
lua_State
*
L
);
#endif
/* INCLUDES_TARANTOOL_LUA_FIO_H */
This diff is collapsed.
Click to expand it.
src/lua/init.cc
+
1
−
1
View file @
e5cf6894
...
...
@@ -282,6 +282,7 @@ tarantool_lua_init(const char *tarantool_bin, int argc, char **argv)
tarantool_lua_socket_init
(
L
);
tarantool_lua_bsdsocket_init
(
L
);
tarantool_lua_pickle_init
(
L
);
tarantool_lua_fio_init
(
L
);
luaopen_msgpack
(
L
);
lua_pop
(
L
,
1
);
...
...
@@ -316,7 +317,6 @@ tarantool_lua_init(const char *tarantool_bin, int argc, char **argv)
}
box_lua_init
(
L
);
fio_lua_init
(
L
);
lua_newtable
(
L
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment