Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
ccan
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mirror
ccan
Commits
6c02fd59
Commit
6c02fd59
authored
Feb 15, 2011
by
Rusty Russell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
failtest: capture pread/pwrite
parent
f070b47b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
6 deletions
+36
-6
ccan/failtest/failtest.c
ccan/failtest/failtest.c
+22
-6
ccan/failtest/failtest.h
ccan/failtest/failtest.h
+2
-0
ccan/failtest/failtest_override.h
ccan/failtest/failtest_override.h
+8
-0
ccan/failtest/failtest_proto.h
ccan/failtest/failtest_proto.h
+4
-0
No files found.
ccan/failtest/failtest.c
View file @
6c02fd59
...
...
@@ -466,7 +466,7 @@ int failtest_pipe(int pipefd[2], const char *file, unsigned line)
return
p
->
u
.
pipe
.
ret
;
}
ssize_t
failtest_
read
(
int
fd
,
void
*
buf
,
size_t
count
,
ssize_t
failtest_
pread
(
int
fd
,
void
*
buf
,
size_t
count
,
off_t
off
,
const
char
*
file
,
unsigned
line
)
{
struct
failtest_call
*
p
;
...
...
@@ -474,6 +474,7 @@ ssize_t failtest_read(int fd, void *buf, size_t count,
call
.
fd
=
fd
;
call
.
buf
=
buf
;
call
.
count
=
count
;
call
.
off
=
off
;
p
=
add_history
(
FAILTEST_READ
,
file
,
line
,
&
call
);
/* This is going to change seek offset, so save it. */
...
...
@@ -485,7 +486,7 @@ ssize_t failtest_read(int fd, void *buf, size_t count,
p
->
u
.
read
.
ret
=
-
1
;
p
->
error
=
EIO
;
}
else
{
p
->
u
.
read
.
ret
=
read
(
fd
,
buf
,
count
);
p
->
u
.
read
.
ret
=
pread
(
fd
,
buf
,
count
,
off
);
}
errno
=
p
->
error
;
return
p
->
u
.
read
.
ret
;
...
...
@@ -497,7 +498,7 @@ static struct write_info *new_write(void)
return
&
writes
[
writes_num
++
];
}
ssize_t
failtest_
write
(
int
fd
,
const
void
*
buf
,
size_t
count
,
ssize_t
failtest_
pwrite
(
int
fd
,
const
void
*
buf
,
size_t
count
,
off_t
off
,
const
char
*
file
,
unsigned
line
)
{
struct
failtest_call
*
p
;
...
...
@@ -507,6 +508,7 @@ ssize_t failtest_write(int fd, const void *buf, size_t count,
call
.
fd
=
fd
;
call
.
buf
=
buf
;
call
.
count
=
count
;
call
.
off
=
off
;
p
=
add_history
(
FAILTEST_WRITE
,
file
,
line
,
&
call
);
offset
=
lseek
(
fd
,
0
,
SEEK_CUR
);
...
...
@@ -570,12 +572,26 @@ ssize_t failtest_write(int fd, const void *buf, size_t count,
return
p
->
u
.
write
.
ret
;
}
}
p
->
u
.
write
.
ret
=
write
(
fd
,
buf
,
count
);
p
->
u
.
write
.
ret
=
pwrite
(
fd
,
buf
,
count
,
off
);
}
errno
=
p
->
error
;
return
p
->
u
.
write
.
ret
;
}
ssize_t
failtest_read
(
int
fd
,
void
*
buf
,
size_t
count
,
const
char
*
file
,
unsigned
line
)
{
return
failtest_pread
(
fd
,
buf
,
count
,
lseek
(
fd
,
0
,
SEEK_CUR
),
file
,
line
);
}
ssize_t
failtest_write
(
int
fd
,
const
void
*
buf
,
size_t
count
,
const
char
*
file
,
unsigned
line
)
{
return
failtest_pwrite
(
fd
,
buf
,
count
,
lseek
(
fd
,
0
,
SEEK_CUR
),
file
,
line
);
}
static
struct
lock_info
*
WARN_UNUSED_RESULT
add_lock
(
struct
lock_info
*
locks
,
int
fd
,
off_t
start
,
off_t
end
,
int
type
)
{
...
...
ccan/failtest/failtest.h
View file @
6c02fd59
...
...
@@ -76,6 +76,7 @@ struct read_call {
int
fd
;
void
*
buf
;
size_t
count
;
off_t
off
;
};
struct
write_call
{
...
...
@@ -83,6 +84,7 @@ struct write_call {
int
fd
;
const
void
*
buf
;
size_t
count
;
off_t
off
;
};
struct
fcntl_call
{
...
...
ccan/failtest/failtest_override.h
View file @
6c02fd59
...
...
@@ -39,6 +39,14 @@
#define write(fd, buf, count) \
failtest_write((fd), (buf), (count), __FILE__, __LINE__)
#undef pread
#define pread(fd, buf, count, off) \
failtest_pread((fd), (buf), (count), (off), __FILE__, __LINE__)
#undef pwrite
#define pwrite(fd, buf, count, off) \
failtest_pwrite((fd), (buf), (count), (off), __FILE__, __LINE__)
#undef close
#define close(fd) failtest_close(fd)
...
...
ccan/failtest/failtest_proto.h
View file @
6c02fd59
...
...
@@ -15,6 +15,10 @@ ssize_t failtest_read(int fd, void *buf, size_t count,
const
char
*
file
,
unsigned
line
);
ssize_t
failtest_write
(
int
fd
,
const
void
*
buf
,
size_t
count
,
const
char
*
file
,
unsigned
line
);
ssize_t
failtest_pread
(
int
fd
,
void
*
buf
,
size_t
count
,
off_t
offset
,
const
char
*
file
,
unsigned
line
);
ssize_t
failtest_pwrite
(
int
fd
,
const
void
*
buf
,
size_t
count
,
off_t
offset
,
const
char
*
file
,
unsigned
line
);
int
failtest_close
(
int
fd
);
int
failtest_fcntl
(
int
fd
,
const
char
*
file
,
unsigned
line
,
int
cmd
,
...);
#endif
/* CCAN_FAILTEST_PROTO_H */
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