diff --git a/gftool/gfprep/gfarm_pfunc.c b/gftool/gfprep/gfarm_pfunc.c index b0fe293b9..f2e2a9374 100644 --- a/gftool/gfprep/gfarm_pfunc.c +++ b/gftool/gfprep/gfarm_pfunc.c @@ -652,6 +652,8 @@ pfunc_copy_by_gfcp(gfarm_pfunc_t *handle, const char *src_url, char *src_host, gfarm_off_t src_size, const char *dst_url, char *dst_host) { + gfarm_error_t e; + struct pfunc_stat src_st; int result = PFUNC_RESULT_OK, retv; char *src_url_uc = (char *)src_url; /* UNCONST */ char *dst_url_uc = (char *)dst_url; /* UNCONST */ @@ -706,7 +708,23 @@ pfunc_copy_by_gfcp(gfarm_pfunc_t *handle, fprintf(stderr, "ERROR: copy failed: gfcp(%s, %s)\n", src_url, dst_url); result = PFUNC_RESULT_NG; + goto end; + } + e = pfunc_lstat(src_url, &src_st); + if (e != GFARM_ERR_NO_ERROR) { + fprintf(stderr, "ERROR: copy failed: lstat(%s): %s\n", + src_url, gfarm_error_string(e)); + result = PFUNC_RESULT_NG; + goto end; + } + e = pfunc_lutimens(dst_url, &src_st); + if (e != GFARM_ERR_NO_ERROR) { + fprintf(stderr, "ERROR: copy failed: utime(%s): %s\n", + dst_url, gfarm_error_string(e)); + result = PFUNC_RESULT_NG; + goto end; } +end: return (result); } diff --git a/regress/gftool/gfprep/gfpcopy_dir.sh b/regress/gftool/gfprep/gfpcopy_dir.sh index c4db2e6ca..7295a2211 100755 --- a/regress/gftool/gfprep/gfpcopy_dir.sh +++ b/regress/gftool/gfprep/gfpcopy_dir.sh @@ -57,6 +57,7 @@ else exit $exit_fail fi check_local_entries $local_dir1 +compare_mtime gfarm:$gf_dir1/dir/1byte file:$local_dir1/dir/1byte if $GFPCOPY $OPT file:$local_dir1 gfarm:$gf_dir2; then : @@ -74,6 +75,7 @@ else exit $exit_fail fi check_local_entries $local_dir2 +compare_mtime gfarm:$gf_dir2/dir/1byte file:$local_dir2/dir/1byte if $GFPCOPY $OPT gfarm:$gf_dir2 file:$local_dir2; then : @@ -84,6 +86,7 @@ else fi BASENAME=`basename $gf_dir2` check_local_entries $local_dir2/$BASENAME +compare_mtime gfarm:$gf_dir2/dir/1byte file:$local_dir2/$BASENAME/dir/1byte clean_test exit $exit_pass diff --git a/regress/gftool/gfprep/gfpcopy_file.sh b/regress/gftool/gfprep/gfpcopy_file.sh index a02e7ed3e..00af8baa1 100755 --- a/regress/gftool/gfprep/gfpcopy_file.sh +++ b/regress/gftool/gfprep/gfpcopy_file.sh @@ -21,10 +21,11 @@ fi test_copy() { SIZE=$1 filename=COPYFILE - OPT="-b 65536 -f -d ${ADD_OPT}" + OPT="-b 65536 -f ${ADD_OPT}" lfile=$local_dir1/$filename gfile=$gf_dir1/$filename - if dd if=/dev/urandom of=$lfile bs=$SIZE count=1 > /dev/null; then + lfile2=$local_dir2/$filename + if dd if=/dev/urandom of=$lfile bs=$SIZE count=1 2> /dev/null; then : else echo dd failed @@ -38,6 +39,8 @@ test_copy() { clean_test exit $exit_fail fi + compare_mtime file:$lfile gfarm:$gfile + if $GFPCOPY $OPT gfarm:$gfile file:$local_dir2; then : else @@ -45,7 +48,8 @@ test_copy() { clean_test exit $exit_fail fi - if cmp $lfile $local_dir2/$filename; then + compare_mtime gfarm:$gfile file:$lfile2 + if cmp $lfile $lfile2; then : else echo copied data is different diff --git a/regress/gftool/gfprep/setup_gfprep.sh b/regress/gftool/gfprep/setup_gfprep.sh index 9411a6343..4791e6d4c 100644 --- a/regress/gftool/gfprep/setup_gfprep.sh +++ b/regress/gftool/gfprep/setup_gfprep.sh @@ -62,3 +62,25 @@ check_N() { exit $exit_fail fi } + +get_mtime() { + file="$1" + case $file in + gfarm:*) + gfstat "$file" | grep ^Modify | cut -d' ' -f 2,3 + ;; + file:*) + f=${file#file:} + stat "$f" | grep ^Modify | cut -d' ' -f 2,3 + ;; + esac +} + +compare_mtime() { + m1=`get_mtime $1` + m2=`get_mtime $2` + if [ "$m1" != "$m2" ]; then + echo "compare_mtime: $m1 != $m2 ($1, $2)" + exit $exit_fail + fi +}