Skip to content

Commit

Permalink
Merge branch 'master' of github.com:hpc/mpifileutils
Browse files Browse the repository at this point in the history
  • Loading branch information
Danielle Sikich committed Aug 25, 2018
2 parents ec41129 + 2bf69d8 commit c186e17
Show file tree
Hide file tree
Showing 4 changed files with 280 additions and 97 deletions.
7 changes: 6 additions & 1 deletion doc/rst/dsync.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Parallel MPI application to synchronize two files or two directory trees.

dsync makes DEST match SRC, adding missing entries from DEST, removing
extra entries from DEST, and updating existing entries in DEST as necessary
so that SRC and DEST have identical content and metadata.
so that SRC and DEST have identical content, ownership, timestamps, and permissions.

OPTIONS
-------
Expand All @@ -22,6 +22,11 @@ OPTIONS

Show differences without changing anything.

.. option:: -c, --contents

Compare files byte-by-byte rather than checking size and mtime
to determine whether file contents are different.

.. option:: -N, --no-delete

Do not delete extraneous files from destination.
Expand Down
4 changes: 4 additions & 0 deletions src/common/mfu_flist.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,10 @@ mfu_flist mfu_flist_subset(mfu_flist srclist);
/* copy specified source file into destination list */
void mfu_flist_file_copy(mfu_flist src, uint64_t index, mfu_flist dest);

/* given a source and destination file, update destination metadata
* to match source if needed */
void mfu_flist_file_sync_meta(mfu_flist src_list, uint64_t src_index, mfu_flist dst_list, uint64_t dst_index);

/* get number of bytes to pack a file from the specified list */
size_t mfu_flist_file_pack_size(mfu_flist flist);

Expand Down
46 changes: 46 additions & 0 deletions src/common/mfu_flist_copy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1496,3 +1496,49 @@ void mfu_flist_copy(mfu_flist src_cp_list, int numpaths,

return;
}

void mfu_flist_file_sync_meta(mfu_flist src_list, uint64_t src_index, mfu_flist dst_list, uint64_t dst_index)
{
/* get destination path */
const char* dest_path = mfu_flist_file_get_name(dst_list, dst_index);

/* get owner and group ids */
uid_t src_uid = (uid_t) mfu_flist_file_get_uid(src_list, src_index);
gid_t src_gid = (gid_t) mfu_flist_file_get_gid(src_list, src_index);

uid_t dst_uid = (uid_t) mfu_flist_file_get_uid(dst_list, dst_index);
gid_t dst_gid = (gid_t) mfu_flist_file_get_gid(dst_list, dst_index);

/* update ownership on destination if needed */
if ((src_uid != dst_uid) || (src_gid != dst_gid)) {
mfu_copy_ownership(src_list, src_index, dest_path);
}

/* update permissions on destination if needed */
mode_t src_mode = (mode_t) mfu_flist_file_get_mode(src_list, src_index);
mode_t dst_mode = (mode_t) mfu_flist_file_get_mode(dst_list, dst_index);
if (src_mode != dst_mode) {
mfu_copy_permissions(src_list, src_index, dest_path);
}

/* get atime seconds and nsecs */
uint64_t src_atime = mfu_flist_file_get_atime(src_list, src_index);
uint64_t src_atime_nsec = mfu_flist_file_get_atime_nsec(src_list, src_index);
uint64_t dst_atime = mfu_flist_file_get_atime(dst_list, dst_index);
uint64_t dst_atime_nsec = mfu_flist_file_get_atime_nsec(dst_list, dst_index);

/* get mtime seconds and nsecs */
uint64_t src_mtime = mfu_flist_file_get_mtime(src_list, src_index);
uint64_t src_mtime_nsec = mfu_flist_file_get_mtime_nsec(src_list, src_index);
uint64_t dst_mtime = mfu_flist_file_get_mtime(dst_list, dst_index);
uint64_t dst_mtime_nsec = mfu_flist_file_get_mtime_nsec(dst_list, dst_index);

/* update atime and mtime on destination if needed */
if ((src_atime != dst_atime) || (src_atime_nsec != dst_atime_nsec) ||
(src_mtime != dst_mtime) || (src_mtime_nsec != dst_mtime_nsec))
{
mfu_copy_timestamps(src_list, src_index, dest_path);
}

return;
}

0 comments on commit c186e17

Please sign in to comment.