summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorAndroid (Google) Code Review <android-gerrit@google.com>2009-05-23 14:07:35 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-05-23 14:07:35 -0700
commit6a3a2b9d20212d8496744ebdc47a52bd6c670cbb (patch)
tree2d805bc94c4f4d9c06bee497e81ee0130afeb526 /libs
parentfa02f9216267330c0df39cf361ef7441264f0a44 (diff)
parent04561a55df693e7bd8d3047ccc4fbef504ac07cf (diff)
downloadframeworks_base-6a3a2b9d20212d8496744ebdc47a52bd6c670cbb.zip
frameworks_base-6a3a2b9d20212d8496744ebdc47a52bd6c670cbb.tar.gz
frameworks_base-6a3a2b9d20212d8496744ebdc47a52bd6c670cbb.tar.bz2
am 04561a55: Merge change 2359 into donut
Merge commit '04561a55df693e7bd8d3047ccc4fbef504ac07cf' * commit '04561a55df693e7bd8d3047ccc4fbef504ac07cf': Fix for the simultor build breakage.
Diffstat (limited to 'libs')
-rw-r--r--libs/utils/backup_helper_file.cpp37
1 files changed, 26 insertions, 11 deletions
diff --git a/libs/utils/backup_helper_file.cpp b/libs/utils/backup_helper_file.cpp
index 8efb3eb..7ec2ce8 100644
--- a/libs/utils/backup_helper_file.cpp
+++ b/libs/utils/backup_helper_file.cpp
@@ -26,6 +26,7 @@
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/stat.h>
+#include <sys/time.h> // for utimes
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -607,14 +608,14 @@ backup_helper_test_four()
0x11, 0x00, 0x00, 0x00, 0x62, 0x79, 0x74, 0x65,
0x73, 0x5f, 0x6f, 0x66, 0x5f, 0x70, 0x61, 0x64,
0x64, 0x69, 0x6e, 0x67, 0x33, 0xab, 0xab, 0xab,
-
+
// bytes of padding2
0x44, 0x11, 0x22, 0x33, 0xef, 0xbe, 0xad, 0xde,
0x44, 0x33, 0x22, 0x11, 0x34, 0x23, 0x12, 0x01,
0x12, 0x00, 0x00, 0x00, 0x62, 0x79, 0x74, 0x65,
0x73, 0x5f, 0x6f, 0x66, 0x5f, 0x70, 0x61, 0x64,
0x64, 0x69, 0x6e, 0x67, 0x5f, 0x32, 0xab, 0xab,
-
+
// bytes of padding3
0x44, 0x11, 0x22, 0x33, 0xef, 0xbe, 0xad, 0xde,
0x44, 0x33, 0x22, 0x11, 0x34, 0x23, 0x12, 0x01,
@@ -627,7 +628,7 @@ backup_helper_test_four()
if (err != 0) {
return err;
}
-
+
// read
fd = open(filename, O_RDONLY);
if (fd == -1) {
@@ -665,7 +666,7 @@ backup_helper_test_four()
matched = false;
}
}
-
+
return matched ? 0 : 1;
}
@@ -746,7 +747,7 @@ backup_helper_test_data_writer()
system("rm -r " SCRATCH_DIR);
mkdir(SCRATCH_DIR, 0777);
mkdir(SCRATCH_DIR "data", 0777);
-
+
fd = creat(filename, 0666);
if (fd == -1) {
fprintf(stderr, "error creating: %s\n", strerror(errno));
@@ -863,7 +864,7 @@ backup_helper_test_data_reader()
system("rm -r " SCRATCH_DIR);
mkdir(SCRATCH_DIR, 0777);
mkdir(SCRATCH_DIR "data", 0777);
-
+
fd = creat(filename, 0666);
if (fd == -1) {
fprintf(stderr, "error creating: %s\n", strerror(errno));
@@ -940,9 +941,23 @@ get_mod_time(const char* filename, struct timeval times[2])
return errno;
}
times[0].tv_sec = st.st_atime;
- times[0].tv_usec = st.st_atime_nsec / 1000;
times[1].tv_sec = st.st_mtime;
+
+ // If st_atime is a macro then struct stat64 uses struct timespec
+ // to store the access and modif time values and typically
+ // st_*time_nsec is not defined. In glibc, this is controlled by
+ // __USE_MISC.
+#ifdef __USE_MISC
+#if !defined(st_atime) || defined(st_atime_nsec)
+#error "Check if this __USE_MISC conditional is still needed."
+#endif
+ times[0].tv_usec = st.st_atim.tv_nsec / 1000;
+ times[1].tv_usec = st.st_mtim.tv_nsec / 1000;
+#else
+ times[0].tv_usec = st.st_atime_nsec / 1000;
times[1].tv_usec = st.st_mtime_nsec / 1000;
+#endif
+
return 0;
}
@@ -987,7 +1002,7 @@ backup_helper_test_files()
{
BackupDataWriter dataStream(dataStreamFD);
-
+
err = back_up_files(-1, &dataStream, newSnapshotFD, SCRATCH_DIR, files_before, 5);
if (err != 0) {
return err;
@@ -1017,7 +1032,7 @@ backup_helper_test_files()
utimes(SCRATCH_DIR "data/e", e_times);
write_text_file(SCRATCH_DIR "data/g", "g\ngg\n");
unlink(SCRATCH_DIR "data/f");
-
+
char const* files_after[] = {
"data/a", // added
"data/b", // same
@@ -1047,7 +1062,7 @@ backup_helper_test_files()
{
BackupDataWriter dataStream(dataStreamFD);
-
+
err = back_up_files(oldSnapshotFD, &dataStream, newSnapshotFD, SCRATCH_DIR,
files_after, 6);
if (err != 0) {
@@ -1058,7 +1073,7 @@ backup_helper_test_files()
close(oldSnapshotFD);
close(dataStreamFD);
close(newSnapshotFD);
-
+
return 0;
}