lapi/seek.h: fix typo for SEEK_DATA
PATCH 1/2 lapi/seek.h: fix typo for SEEK_DATA
Compilation failed on RHEL6.9GA because SEEK_DATA is not defined.
--- include/lapi/seek.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/lapi/seek.h +2 -2
@@ -20,8 +20,8 @@#include <unistd.h> -#ifndef DATA_HOLE -# define DATA_HOLE 4 +#ifndef SEEK_DATA +# define SEEK_DATA 3#endif #ifndef SEEK_HOLE
Signature · 1 line
1.8.3.1
PATCH 2/2 syscalls/lseek11.c: fix undefined syncfs() && SEEK_DATA
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().
2) We should Add a check if SEEK_DATA was implemented in get_blocksize().
--- testcases/kernel/syscalls/lseek/lseek11.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
testcases/kernel/syscalls/lseek/lseek11.c +12 -5
@@ -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" ); }
@@ -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 ); }
Signature · 1 line
1.8.3.1
PATCH 2/2 syscalls/lseek11.c: fix undefined syncfs() && SEEK_DATA
Hi!
Quoted 3 lines
1) Compilation failed on RHEL6.9GA because
syncfs()was not defined. this function was introduced since linux 2.6.39, so we could usesync()instead ofsyncfs().
Looking at this again, why don't we use fsync(fd) instead?
Quoted 1 line
2) We should Add a check if
SEEK_DATAwas implemented inget_blocksize().
Missed the lseek() in get_blocksize(), sorry.
Quoted 37 lines
Signed-off-by Xiao Yang <[email protected]>--- testcases/kernel/syscalls/lseek/lseek11.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)testcases/kernel/syscalls/lseek/lseek11.c +10
-3@@ -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 ;
testcases/kernel/syscalls/lseek/lseek11.c static void setup(void) · line 191
Quoted 8 lines
testcases/kernel/syscalls/lseek/lseek11.c +1
-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.
Quoted 17 lines
testcases/kernel/syscalls/lseek/lseek11.c +1
-1@@ -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 ); }Signature · 7 lines
1.8.3.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 2/2 syscalls/lseek11.c: fix undefined syncfs() && SEEK_DATA
Hi Cyril
Thanks for your comment.
I will send v2 patch as you said.
Thanks,
Xiao Yang.
Quoted 74 lines · Cyril Hrubis
Hi!
Quoted 3 lines
1) Compilation failed on RHEL6.9GA because
syncfs()was not defined. this function was introduced since linux 2.6.39, so we could usesync()instead ofsyncfs().Looking at this again, why don't we use fsync(fd) instead?
Quoted 1 line
2) We should Add a check if
SEEK_DATAwas implemented inget_blocksize().Missed the
lseek()inget_blocksize(), sorry.Quoted 37 lines
Signed-off-by Xiao Yang<[email protected]>--- testcases/kernel/syscalls/lseek/lseek11.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)testcases/kernel/syscalls/lseek/lseek11.c +10
-3@@ -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 ;testcases/kernel/syscalls/lseek/lseek11.c static void setup(void) · line 191
Quoted 8 lines
testcases/kernel/syscalls/lseek/lseek11.c +1
-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 insetup()since we calltst_brk()in theget_blocksize()thelseek()will never fail here.Quoted 17 lines
testcases/kernel/syscalls/lseek/lseek11.c +1
-1@@ -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 ); }Signature · 7 lines
1.8.3.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
PATCH v2 1/1 syscalls/lseek11.c: fix syncfs() && SEEK_DATA
In reply to Cyril Hrubis1) We add SAFE_FSYNC().
2) Compilation failed on RHEL6.9GA because syncfs() was not defined. this function is introduced since linux 2.6.39, so we could use SAFE_FSYNC() instead of syncfs().
3) We add a check if SEEK_DATA was implemented in get_blocksize(), and remove this check in setup().
--- include/tst_safe_macros.h | 3 +++ lib/safe_macros.c | 14 ++++++++++++++ testcases/kernel/syscalls/lseek/lseek11.c | 23 ++++++++++++----------- 3 files changed, 29 insertions(+), 11 deletions(-)
include/tst_safe_macros.h +3 -0
@@ -427,4 +427,7 @@ int safe_removexattr(const char *file, const int lineno, const char *path,#define SAFE_REMOVEXATTR (path, name) \ safe_removexattr(__FILE__, __LINE__, (path), (name)) +int safe_fsync (const char *file,const int lineno,int fd); +#define SAFE_FSYNC (fd) safe_fsync(__FILE__, __LINE__, (fd)) +#endif /* SAFE_MACROS_H__ */
lib/safe_macros.c +14 -0
@@ -874,3 +874,17 @@ int safe_removexattr(const char *file, const int lineno, const char *path,return rval; } + +int safe_fsync (const char *file,const int lineno,int fd) +{ +int rval; + + rval =fsync (fd); + +if (rval) { +tst_brkm (TBROK |TERRNO ,NULL , +"%s:%d: fsync(%i) failed" , file, lineno, fd); + } + +return rval; +}
testcases/kernel/syscalls/lseek/lseek11.c +12 -11
@@ -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 ); +SAFE_FSYNC (fd); + pos =lseek (fd,0 ,SEEK_DATA ); +if (pos ==-1 ) { +if (errno ==EINVAL ) { +tst_brk (TCONF |TERRNO ,"SEEK_DATA " +"and SEEK_HOLE 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); +SAFE_FSYNC (fd); pos =SAFE_LSEEK (fd,0 ,SEEK_DATA ); offset += pos ? -shift : shift; shift >>=1 ;
@@ -175,13 +182,7 @@ static void setup(void)*/ SAFE_FTRUNCATE (fd,FILE_BLOCKS * block_size); -if (lseek (fd,0 ,SEEK_HOLE ) <0 ) { -if (errno ==EINVAL ) { -tst_brk (TCONF |TERRNO , -"SEEK_DATA and SEEK_HOLE not implemented" ); - } -tst_brk (TBROK |TERRNO ,"SEEK_HOLE failed" ); - } +SAFE_LSEEK (fd,0 ,SEEK_HOLE );for (i =0 ; i <UNIT_COUNT ; i++) { offset =UNIT_BLOCKS * block_size * i;
@@ -192,7 +193,7 @@ static void setup(void)SAFE_LSEEK (fd,-128 ,SEEK_END );write_data (fd, i +1 ); -syncfs (fd); +SAFE_FSYNC (fd);SAFE_LSEEK (fd,0 ,SEEK_SET ); }
Signature · 1 line
1.8.3.1
PATCH v2 1/1 syscalls/lseek11.c: fix syncfs() && SEEK_DATA
Hi!
Pushed, thanks.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/2 lapi/seek.h: fix typo for SEEK_DATA
In reply to Xiao YangHi!
Quoted 1 line
Compilation failed on RHEL6.9GA because
SEEK_DATAis not defined.
Thanks for fixing this, applied.
Signature · 2 lines
Cyril Hrubis [email protected]