return 0;
}
+_PUBLIC_ bool timespec_equal(const struct timespec *ts1, const struct timespec *ts2)
+{
+ return ((ts1->tv_sec == ts2->tv_sec) &&
+ (ts1->tv_nsec == ts2->tv_nsec));
+}
+
/****************************************************************************
Round up a timespec if nsec > 500000000, round down if lower,
then zero nsec.
struct timespec timespec_min(const struct timespec *ts1,
const struct timespec *ts2);
int timespec_compare(const struct timespec *ts1, const struct timespec *ts2);
+bool timespec_equal(const struct timespec *ts1, const struct timespec *ts2);
void round_timespec_to_sec(struct timespec *ts);
void round_timespec_to_usec(struct timespec *ts);
void round_timespec_to_nttime(struct timespec *ts);
ft->create_time);
}
- if ((timespec_compare(&ft->atime,
- &fsp->fsp_name->st.st_ex_atime) == 0) &&
- (timespec_compare(&ft->mtime,
- &fsp->fsp_name->st.st_ex_mtime) == 0)) {
+ if (timespec_equal(&ft->atime,
+ &fsp->fsp_name->st.st_ex_atime) &&
+ timespec_equal(&ft->mtime,
+ &fsp->fsp_name->st.st_ex_mtime))
+ {
result = 0;
goto out;
}
}
/* throw away cache and re-read the directory if we've changed */
- if (timespec_compare(¤t_mtime, &data->mtime)) {
+ if (!timespec_equal(¤t_mtime, &data->mtime)) {
SMB_VFS_NEXT_REWINDDIR(handle, data->source_directory);
open_and_sort_dir(handle, data);
}
times[1].tv_nsec = ft->mtime.tv_nsec;
}
- if ((timespec_compare(×[0],
- &fsp->fsp_name->st.st_ex_atime) == 0) &&
- (timespec_compare(×[1],
- &fsp->fsp_name->st.st_ex_mtime) == 0)) {
+ if (timespec_equal(×[0], &fsp->fsp_name->st.st_ex_atime) &&
+ timespec_equal(×[1], &fsp->fsp_name->st.st_ex_mtime))
+ {
END_PROFILE(syscall_fntimes);
return 0;
}
}
if (mod_time.tv_sec > 0 &&
- ((timespec_compare(&mod_time, &f->modtime) != 0) ||
+ (!timespec_equal(&mod_time, &f->modtime) ||
(f->subfname == NULL) ||
(strcmp(n2, f->subfname) != 0)))
{
}
if (iService != -1 &&
- timespec_compare(&ServicePtrs[iService]->usershare_last_mod,
- &lsbuf.st_ex_mtime) == 0) {
+ timespec_equal(&ServicePtrs[iService]->usershare_last_mod,
+ &lsbuf.st_ex_mtime))
+ {
/* Nothing changed - Mark valid and return. */
DEBUG(10,("process_usershare_file: service %s not changed.\n",
canon_name ));
struct files_struct *fsp)
{
SMB_STRUCT_STAT *fsp_st = &fsp->fsp_name->st;
- int ret;
+ bool equal;
if (cookie_st->st_ex_mode != fsp_st->st_ex_mode) {
DEBUG(1, ("vfs_default_durable_reconnect (%s): "
return false;
}
- ret = timespec_compare(&cookie_st->st_ex_atime,
- &fsp_st->st_ex_atime);
- if (ret != 0) {
+ equal = timespec_equal(&cookie_st->st_ex_atime, &fsp_st->st_ex_atime);
+ if (!equal) {
struct timeval tc, ts;
tc = convert_timespec_to_timeval(cookie_st->st_ex_atime);
ts = convert_timespec_to_timeval(fsp_st->st_ex_atime);
return false;
}
- ret = timespec_compare(&cookie_st->st_ex_mtime,
- &fsp_st->st_ex_mtime);
- if (ret != 0) {
+ equal = timespec_equal(&cookie_st->st_ex_mtime, &fsp_st->st_ex_mtime);
+ if (!equal) {
struct timeval tc, ts;
tc = convert_timespec_to_timeval(cookie_st->st_ex_mtime);
ts = convert_timespec_to_timeval(fsp_st->st_ex_mtime);
return false;
}
- ret = timespec_compare(&cookie_st->st_ex_ctime,
- &fsp_st->st_ex_ctime);
- if (ret != 0) {
+ equal = timespec_equal(&cookie_st->st_ex_ctime, &fsp_st->st_ex_ctime);
+ if (!equal) {
struct timeval tc, ts;
tc = convert_timespec_to_timeval(cookie_st->st_ex_ctime);
ts = convert_timespec_to_timeval(fsp_st->st_ex_ctime);
return false;
}
- ret = timespec_compare(&cookie_st->st_ex_btime,
- &fsp_st->st_ex_btime);
- if (ret != 0) {
+ equal = timespec_equal(&cookie_st->st_ex_btime, &fsp_st->st_ex_btime);
+ if (!equal) {
struct timeval tc, ts;
tc = convert_timespec_to_timeval(cookie_st->st_ex_btime);
ts = convert_timespec_to_timeval(fsp_st->st_ex_btime);
nt_errstr(status));
return false;
}
- equal = (timespec_compare(&test_crtime, &crtime_tomatch) == 0);
+ equal = timespec_equal(&test_crtime, &crtime_tomatch);
if (!equal) {
struct timeval_buf test_buf;
struct timeval_buf tomatch_buf;
* This checks we're actually correctly reading crtimes
* from the filesystem.
*/
- equal = (timespec_compare(&test_crtime, &root_crtime) == 0);
+ equal = timespec_equal(&test_crtime, &root_crtime);
if (equal) {
printf("%s:%d Error. crtime of %s must differ from "
"root_crtime\n",
nt_errstr(status));
goto err;
}
- equal = (timespec_compare(&testfile_crtime, &open_crtime) == 0);
+ equal = timespec_equal(&testfile_crtime, &open_crtime);
if (!equal) {
printf("%s:%d crtime mismatch of test file %s\n",
__FILE__,
goto out;
}
- if (timespec_compare(&create_time1, &create_time)) {
+ if (!timespec_equal(&create_time1, &create_time)) {
printf("run_dir_createtime: create time was updated (error)\n");
} else {
printf("run_dir_createtime: create time was not updated (correct)\n");