[Ocfs2-test-devel] [PATCH 1/1] Ocfs2-test: Deal with compiling error on opensuse for splice_test
Sunil Mushran
sunil.mushran at oracle.com
Mon Apr 13 11:10:36 PDT 2009
The prototype in splice_test.h is just a placeholder. We should use the
one in bit/fcntl.h when available. And if the two prototypes differ, make
the private the same as the public.
To see how this can be done, do a "grep -rl inc_nlink" in the ocfs2-1.4
src tree. The basic idea is to move the header to an api-compat directory
and include it only if the prototype is not found in bit/fcntl.h.
We have a macro or two (OCFS2_CHECK_KERNEL) which you may need to port
over to ocfs2-test.
Let me know if you have any qs.
Sunil
Tristan Ye wrote:
> On openSuSE 11 the splice in bits/fcntl.h is:
> /* Splice two files together. */
> extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout,
> __off64_t *__offout, size_t __len,
> unsigned int __flags);
>
> In our ocfs2-test/program/splice_test/splice_test.h, the splice_test is:
> int splice(int fdin, loff_t *off_in, int fdout,
> loff_t *off_out, size_t len, unsigned int flags)
>
> Such different return value of two splice() cause a type conflicting error.
>
> Here we explicitly use the splice() call from definition in splice_test.h by
> force by changing its name as my_splice() from the one in fcntl.h, which also
> prevent a compiling error from happening.
>
> Signed-off-by: Tristan Ye <tristan.ye at oracle.com>
> ---
> programs/splice/splice_read.c | 6 +++---
> programs/splice/splice_test.h | 2 +-
> programs/splice/splice_write.c | 6 +++---
> 3 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/programs/splice/splice_read.c b/programs/splice/splice_read.c
> index c25522e..7d7aa95 100644
> --- a/programs/splice/splice_read.c
> +++ b/programs/splice/splice_read.c
> @@ -4,7 +4,7 @@
> int main(int argc, char *argv[])
> {
> int fd;
> - int slen;
> + ssize_t slen;
>
> if (argc < 2) {
> printf("Usage: ./splice_read out | cat\n");
> @@ -16,11 +16,11 @@ int main(int argc, char *argv[])
> printf("open file failed.\n");
> exit(-1);
> }
> - slen = splice(fd, NULL, STDOUT_FILENO, NULL, 10000000, 0);
> + slen = my_splice(fd, NULL, STDOUT_FILENO, NULL, 10000000, 0);
> if (slen < 0)
> fprintf(stderr, "splice failed.\n");
> else
> - fprintf(stderr, "spliced length = %d\n",slen);
> + fprintf(stderr, "spliced length = %ld\n",slen);
> close(fd);
> if (slen <0)
> exit(-1);
> diff --git a/programs/splice/splice_test.h b/programs/splice/splice_test.h
> index 5113bbb..899d388 100644
> --- a/programs/splice/splice_test.h
> +++ b/programs/splice/splice_test.h
> @@ -31,7 +31,7 @@
> #error unsupported arch
> #endif
>
> -int splice(int fdin, loff_t *off_in, int fdout,
> +ssize_t my_splice(int fdin, loff_t *off_in, int fdout,
> loff_t *off_out, size_t len, unsigned int flags)
> {
> return syscall(__NR_splice, fdin, off_in, fdout, off_out, len, flags);
> diff --git a/programs/splice/splice_write.c b/programs/splice/splice_write.c
> index a4d8c1a..ee9a281 100644
> --- a/programs/splice/splice_write.c
> +++ b/programs/splice/splice_write.c
> @@ -4,7 +4,7 @@
> int main(int argc, char *argv[])
> {
> int fd;
> - int slen;
> + ssize_t slen;
>
> if (argc < 2) {
> printf("Usage: ls | ./splice_write out\n");
> @@ -15,11 +15,11 @@ int main(int argc, char *argv[])
> printf("open file failed.\n");
> exit(-1);
> }
> - slen = splice(STDIN_FILENO, NULL, fd, NULL, 10000000, 0);
> + slen = my_splice(STDIN_FILENO, NULL, fd, NULL, 10000000, 0);
> if (slen < 0)
> fprintf(stderr, "splice failed.\n");
> else
> - fprintf(stderr, "spliced length = %d\n",slen);
> + fprintf(stderr, "spliced length = %ld\n",slen);
> close(fd);
> if (slen < 0)
> exit(-1);
>
More information about the Ocfs2-test-devel
mailing list