All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 2/2] syscalls/lseek11.c: fix undefined syncfs() && SEEK_DATA
Date: Wed, 12 Apr 2017 13:42:25 +0200	[thread overview]
Message-ID: <20170412114225.GA25790@rei> (raw)
In-Reply-To: <1491968042-5173-2-git-send-email-yangx.jy@cn.fujitsu.com>

Hi!
> 1) Compilation failed on RHEL6.9GA because syncfs() was not defined.
>    this function was introduced since linux 2.6.39, so we could use
>    sync() instead of syncfs().

Looking at this again, why don't we use fsync(fd) instead?

> 2) We should Add a check if SEEK_DATA was implemented in get_blocksize().

Missed the lseek() in get_blocksize(), sorry.

> Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
> ---
>  testcases/kernel/syscalls/lseek/lseek11.c | 17 ++++++++++++-----
>  1 file changed, 12 insertions(+), 5 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/lseek/lseek11.c b/testcases/kernel/syscalls/lseek/lseek11.c
> index fe226b5..01b9fa4 100644
> --- a/testcases/kernel/syscalls/lseek/lseek11.c
> +++ b/testcases/kernel/syscalls/lseek/lseek11.c
> @@ -116,8 +116,15 @@ static void get_blocksize(void)
>  		offset <<= 1;
>  		SAFE_FTRUNCATE(fd, 0);
>  		SAFE_PWRITE(1, fd, "a", 1, offset);
> -		syncfs(fd);
> -		pos = SAFE_LSEEK(fd, 0, SEEK_DATA);
> +		sync();
> +		pos = lseek(fd, 0, SEEK_DATA);
> +		if (pos == -1) {
> +			if (errno == EINVAL) {
> +				tst_brk(TCONF | TERRNO,
> +				"SEEK_DATA not implemented");
> +			}
> +			tst_brk(TBROK | TERRNO, "SEEK_DATA failed");
> +		}
>  	}
>  
>  	/* bisect for double check */
> @@ -125,7 +132,7 @@ static void get_blocksize(void)
>  	while (shift && offset < (st.st_blksize * 2)) {
>  		SAFE_FTRUNCATE(fd, 0);
>  		SAFE_PWRITE(1, fd, "a", 1, offset);
> -		syncfs(fd);
> +		sync();
>  		pos = SAFE_LSEEK(fd, 0, SEEK_DATA);
>  		offset += pos ? -shift : shift;
>  		shift >>= 1;
> @@ -178,7 +185,7 @@ static void setup(void)
>  	if (lseek(fd, 0, SEEK_HOLE) < 0) {
>  		if (errno == EINVAL) {
>  			tst_brk(TCONF | TERRNO,
> -				"SEEK_DATA and SEEK_HOLE not implemented");
> +				"SEEK_HOLE not implemented");
>  		}
>  		tst_brk(TBROK | TERRNO, "SEEK_HOLE failed");
>  	}

We should get rid of this whole lseek() test in setup() since we call
tst_brk() in the get_blocksize() the lseek() will never fail here.

> @@ -192,7 +199,7 @@ static void setup(void)
>  	SAFE_LSEEK(fd, -128, SEEK_END);
>  	write_data(fd, i + 1);
>  
> -	syncfs(fd);
> +	sync();
>  	SAFE_LSEEK(fd, 0, SEEK_SET);
>  }
>  
> -- 
> 1.8.3.1
> 
> 
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2017-04-12 11:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-12  3:34 [LTP] [PATCH 1/2] lapi/seek.h: fix typo for SEEK_DATA Xiao Yang
2017-04-12  3:34 ` [LTP] [PATCH 2/2] syscalls/lseek11.c: fix undefined syncfs() && SEEK_DATA Xiao Yang
2017-04-12 11:42   ` Cyril Hrubis [this message]
2017-04-13  1:29     ` Xiao Yang
2017-04-13  2:31     ` [LTP] [PATCH v2] syscalls/lseek11.c: fix " Xiao Yang
2017-04-13 10:04       ` Cyril Hrubis
2017-04-12  6:55 ` [LTP] [PATCH 1/2] lapi/seek.h: fix typo for SEEK_DATA Cyril Hrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170412114225.GA25790@rei \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.