add generic/795
Subsystems (2)
ChenXiaoSong
reviewerv2 cover add generic/795
From: ChenXiaoSong <[email protected]>
v1->v2:
- Add patch#01 patch#02.
- Patch#03: some cleanups.
v1: https://lore.kernel.org/linux-cifs/[email protected]/
ChenXiaoSong (3):
src: factor out common stat code
generic/002: clean up the test
generic/795: check nlink returned by fstat()
src/Makefile | 13 ++- src/fstat.c | 42 ++++++++++ src/lstat64.c | 166 +------------------------------------ src/stat_common.c | 185 ++++++++++++++++++++++++++++++++++++++++++ src/stat_common.h | 16 ++++ tests/generic/002 | 16 ++-- tests/generic/002.out | 2 +- tests/generic/795 | 60 ++++++++++++++ tests/generic/795.out | 2 + 9 files changed, 324 insertions(+), 178 deletions(-) create mode 100644 src/fstat.c create mode 100644 src/stat_common.c create mode 100644 src/stat_common.h create mode 100755 tests/generic/795 create mode 100644 tests/generic/795.out
Signature · 1 line
2.43.0
ChenXiaoSong
reviewerPATCH RESEND v2 1/3 src: factor out common stat code
From: ChenXiaoSong <[email protected]>
To see only the differences in the code copied from lstat64.c to stat_common.c, run:
git show --find-copies --diff-filter=C <commit-id>
Move command-line parsing and stat output formatting from lstat64 into stat_common so the implementation can be shared by other stat helpers.
No functional change.
--- src/Makefile | 11 ++- src/lstat64.c | 166 +---------------------------------------- src/stat_common.c | 185 ++++++++++++++++++++++++++++++++++++++++++++++ src/stat_common.h | 16 ++++ 4 files changed, 212 insertions(+), 166 deletions(-) create mode 100644 src/stat_common.c create mode 100644 src/stat_common.h
src/Makefile +9 -2
@@ -115,7 +115,8 @@ ifeq ($(NEED_INTERNAL_XFS_IOC_EXCHANGE_RANGE),yes) LCFLAGS += -DNEED_INTERNAL_XFS_IOC_EXCHANGE_RANGE endif -CFILES = $(TARGETS:=.c) +CFILES = $(TARGETS:=.c) stat_common.c +HFILES = stat_common.h LDIRT = $(TARGETS) fssum
@@ -129,7 +130,13 @@ fssum: fssum.c md5.c @echo " [CC] $@" $(Q)$(LTLINK) fssum.c md5.c -o $@ $(CFLAGS) $(LDFLAGS) $(LDLIBS) -$(TARGETS): $(LIBTEST) +STAT_TARGETS = lstat64 + +$(STAT_TARGETS): %: %.c stat_common.c stat_common.h $(LIBTEST) + @echo " [CC] $@" + $(Q)$(LTLINK) [email protected] stat_common.c -o $@ $(CFLAGS) $(LDFLAGS) $(LDLIBS) $(LIBTEST) + +$(filter-out $(STAT_TARGETS),$(TARGETS)): $(LIBTEST) @echo " [CC] $@" $(Q)$(LTLINK) [email protected] -o $@ $(CFLAGS) $(LDFLAGS) $(LDLIBS) $(LIBTEST)
src/lstat64.c +2 -164
174 lines not on this page · raw message
src/stat_common.c new file +185 -0
185 lines not on this page · raw message
src/stat_common.h new file +16 -0
@@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (c) 2000-2002 Silicon Graphics, Inc. +* All Rights Reserved. +*/ + +#ifndef STAT_COMMON_H +#define STAT_COMMON_H + +#include <sys/stat.h> + +typedef int (*get_stat_fn )(const char *path,struct stat64 *sbuf); + +int handle_stat (int argc,char **argv,const char *program,get_stat_fn get_stat); + +#endif /* STAT_COMMON_H */
Signature · 1 line
2.43.0
ChenXiaoSong
reviewerPATCH RESEND v2 2/3 generic/002: clean up the test
In reply to ChenXiaoSongFrom: ChenXiaoSong <[email protected]>
Add the hardlink group and use shorter loops. Use _exit() and change the success text to "Silence is golden".
--- tests/generic/002 | 16 ++++++---------- tests/generic/002.out | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-)
tests/generic/002 +6 -10
@@ -2,12 +2,12 @@ # SPDX-License-Identifier: GPL-2.0 # Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. # -# FS QA Test No. 002 +# FS QA Test 002 # # simple inode link count test for a regular file # . ./common/preamble -_begin_fstest metadata udf auto quick +_begin_fstest metadata udf auto quick hardlink # Import common functions. . ./common/filter
@@ -17,14 +17,11 @@ status=0 # success is the default! _require_test _require_hardlinks -echo "Silence is goodness ..." - # ensure target directory exists mkdir `dirname $TEST_DIR/tmp` 2>/dev/null touch $TEST_DIR/tmp.1 -for l in 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 -do +for ((l = 2; l <= 20; l++)); do ln $TEST_DIR/tmp.1 $TEST_DIR/tmp.$l x=`$here/src/lstat64 $TEST_DIR/tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'` if [ "$l" -ne $x ]
@@ -35,8 +32,7 @@ do fi done -for l in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 -do +for ((l = 20; l >= 1; l--)); do x=`$here/src/lstat64 $TEST_DIR/tmp.1 | sed -n -e '/ Links: /s/.*Links: *//p'` if [ "$l" -ne $x ] then
@@ -47,5 +43,5 @@ do rm -f $TEST_DIR/tmp.$l done -# success, all done -exit +echo "Silence is golden" +exit $status
tests/generic/002.out +1 -1
@@ -1,2 +1,2 @@ QA output created by 002 -Silence is goodness ... +Silence is golden
Signature · 1 line
2.43.0
ChenXiaoSong
reviewerPATCH RESEND v2 3/3 generic/795: check nlink returned by fstat()
In reply to ChenXiaoSongFrom: ChenXiaoSong <[email protected]>
Add a test to verify that fstat(2) returns the expected st_nlink value as hardlinks are created and removed.
--- src/Makefile | 4 +-- src/fstat.c | 42 ++++++++++++++++++++++++++++++ tests/generic/795 | 60 +++++++++++++++++++++++++++++++++++++++++++ tests/generic/795.out | 2 ++ 4 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 src/fstat.c create mode 100755 tests/generic/795 create mode 100644 tests/generic/795.out
src/Makefile +2 -2
@@ -6,7 +6,7 @@ TOPDIR = .. include $(TOPDIR)/include/builddefs -TARGETS = dirstress fill fill2 getpagesize holes lstat64 \ +TARGETS = dirstress fill fill2 getpagesize holes lstat64 fstat \ nametest permname randholes runas truncfile usemem \ mmapcat append_reader append_writer dirperf metaperf \ devzero feature alloc fault fstest t_access_root \
@@ -130,7 +130,7 @@ fssum: fssum.c md5.c @echo " [CC] $@" $(Q)$(LTLINK) fssum.c md5.c -o $@ $(CFLAGS) $(LDFLAGS) $(LDLIBS) -STAT_TARGETS = lstat64 +STAT_TARGETS = lstat64 fstat $(STAT_TARGETS): %: %.c stat_common.c stat_common.h $(LIBTEST) @echo " [CC] $@"
src/fstat.c new file +42 -0
42 lines not on this page · raw message
tests/generic/795 new file +60 -0
60 lines not on this page · raw message
tests/generic/795.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 795 +Silence is golden
Signature · 1 line
2.43.0
Looks good:
ChenXiaoSong
reviewerHi Christoph,
Thanks for your review. There is new version:
https://lore.kernel.org/linux-cifs/[email protected]/
Quoted 4 lines · Christoph Hellwig
Looks good:
Reviewed-by Christoph Hellwig <[email protected]>
Signature · 3 lines
ChenXiaoSong <[email protected]> Chinese Homepage: https://chenxiaosong.com English Homepage: https://chenxiaosong.com/en