diff options
author | Jeremy Allison <jra@samba.org> | 2006-08-24 16:44:00 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 11:38:48 -0500 |
commit | 425280a1d23f97ef0b0be77462386d619f47b21d (patch) | |
tree | 7ef113d951f9940ce153c553a0097c92443b5816 /source/client/clitar.c | |
parent | 3c547202856378cb1b6895b8c5dd0c9e43c66a1f (diff) | |
download | samba-425280a1d23f97ef0b0be77462386d619f47b21d.tar.gz samba-425280a1d23f97ef0b0be77462386d619f47b21d.tar.xz samba-425280a1d23f97ef0b0be77462386d619f47b21d.zip |
r17800: Start using struct timespec internally for file times
on the wire. This allows us to go to nsec resolution
for systems that support it. It should also now be
easy to add a correct "create time" (birth time)
for systems that support it (*BSD). I'll be watching
the build farm closely after this one for breakage :-).
Jeremy.
Diffstat (limited to 'source/client/clitar.c')
-rw-r--r-- | source/client/clitar.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/source/client/clitar.c b/source/client/clitar.c index f0d0ac595c2..87ca3245c11 100644 --- a/source/client/clitar.c +++ b/source/client/clitar.c @@ -49,9 +49,9 @@ struct file_info_struct { uid_t uid; gid_t gid; /* These times are normally kept in GMT */ - time_t mtime; - time_t atime; - time_t ctime; + struct timespec mtime_ts; + struct timespec atime_ts; + struct timespec ctime_ts; char *name; /* This is dynamically allocate */ file_info2 *next, *prev; /* Used in the stack ... */ @@ -312,8 +312,9 @@ of link other than a GNUtar Longlink - ignoring\n")); * We only get the modification time of the file; set the creation time * from the mod. time, and the access time to current time */ - finfo->mtime = finfo->ctime = strtol(hb->dbuf.mtime, NULL, 8); - finfo->atime = time(NULL); + finfo->mtime_ts = finfo->ctime_ts = + convert_time_t_to_timespec((time_t)strtol(hb->dbuf.mtime, NULL, 8)); + finfo->atime_ts = convert_time_t_to_timespec(time(NULL)); finfo->size = unoct(hb->dbuf.size, sizeof(hb->dbuf.size)); return True; @@ -625,18 +626,18 @@ static void do_atar(char *rname,char *lname,file_info *finfo1) finfo.mode = finfo1 -> mode; finfo.uid = finfo1 -> uid; finfo.gid = finfo1 -> gid; - finfo.mtime = finfo1 -> mtime; - finfo.atime = finfo1 -> atime; - finfo.ctime = finfo1 -> ctime; + finfo.mtime_ts = finfo1 -> mtime_ts; + finfo.atime_ts = finfo1 -> atime_ts; + finfo.ctime_ts = finfo1 -> ctime_ts; finfo.name = finfo1 -> name; } else { finfo.size = def_finfo.size; finfo.mode = def_finfo.mode; finfo.uid = def_finfo.uid; finfo.gid = def_finfo.gid; - finfo.mtime = def_finfo.mtime; - finfo.atime = def_finfo.atime; - finfo.ctime = def_finfo.ctime; + finfo.mtime_ts = def_finfo.mtime_ts; + finfo.atime_ts = def_finfo.atime_ts; + finfo.ctime_ts = def_finfo.ctime_ts; finfo.name = def_finfo.name; } @@ -667,11 +668,14 @@ static void do_atar(char *rname,char *lname,file_info *finfo1) safe_strcpy(finfo.name,rname, strlen(rname)); if (!finfo1) { - if (!cli_getattrE(cli, fnum, &finfo.mode, &finfo.size, NULL, &finfo.atime, &finfo.mtime)) { + time_t atime, mtime; + if (!cli_getattrE(cli, fnum, &finfo.mode, &finfo.size, NULL, &atime, &mtime)) { DEBUG(0, ("getattrE: %s\n", cli_errstr(cli))); return; } - finfo.ctime = finfo.mtime; + finfo.atime_ts = convert_time_t_to_timespec(atime); + finfo.mtime_ts = convert_time_t_to_timespec(mtime); + finfo.ctime_ts = finfo.mtime_ts; } DEBUG(3,("file %s attrib 0x%X\n",finfo.name,finfo.mode)); @@ -707,7 +711,8 @@ static void do_atar(char *rname,char *lname,file_info *finfo1) /* Only if the first read succeeds, write out the tar header. */ if (!wrote_tar_header) { /* write a tar header, don't bother with mode - just set to 100644 */ - writetarheader(tarhandle, rname, finfo.size, finfo.mtime, "100644 \0", ftype); + writetarheader(tarhandle, rname, finfo.size, + finfo.mtime_ts.tv_sec, "100644 \0", ftype); wrote_tar_header = True; } @@ -836,7 +841,7 @@ strlen(finfo->name)=%d\nname=%s,cur_dir=%s\n", /* write a tar directory, don't bother with mode - just set it to * 40755 */ - writetarheader(tarhandle, cur_dir, 0, finfo->mtime, "040755 \0", '5'); + writetarheader(tarhandle, cur_dir, 0, finfo->mtime_ts.tv_sec, "040755 \0", '5'); if (tar_noisy) { DEBUG(0,(" directory %s\n", cur_dir)); } @@ -1034,7 +1039,7 @@ static int get_file(file_info2 finfo) /* Now we update the creation date ... */ DEBUG(5, ("Updating creation date on %s\n", finfo.name)); - if (!cli_setatr(cli, finfo.name, finfo.mode, finfo.mtime)) { + if (!cli_setatr(cli, finfo.name, finfo.mode, finfo.mtime_ts.tv_sec)) { if (tar_real_noisy) { DEBUG(0, ("Could not set time on file: %s\n", finfo.name)); /*return(False); */ /* Ignore, as Win95 does not allow changes */ |