summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/cliconnect.c4
-rw-r--r--source3/libsmb/clifile.c7
-rw-r--r--source3/libsmb/clifsinfo.c4
-rw-r--r--source3/libsmb/clilist.c24
-rw-r--r--source3/libsmb/clirap.c14
-rw-r--r--source3/libsmb/libsmbclient.c84
6 files changed, 77 insertions, 60 deletions
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 3e4b6f0545..0e179416dc 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -1149,6 +1149,7 @@ BOOL cli_negprot(struct cli_state *cli)
}
if (cli->protocol >= PROTOCOL_NT1) {
+ struct timespec ts;
/* NT protocol */
cli->sec_mode = CVAL(cli->inbuf,smb_vwv1);
cli->max_mux = SVAL(cli->inbuf, smb_vwv1+1);
@@ -1157,7 +1158,8 @@ BOOL cli_negprot(struct cli_state *cli)
cli->serverzone = SVALS(cli->inbuf,smb_vwv15+1);
cli->serverzone *= 60;
/* this time arrives in real GMT */
- cli->servertime = interpret_long_date(cli->inbuf+smb_vwv11+1);
+ ts = interpret_long_date(cli->inbuf+smb_vwv11+1);
+ cli->servertime = ts.tv_sec;
cli->secblob = data_blob(smb_buf(cli->inbuf),smb_buflen(cli->inbuf));
cli->capabilities = IVAL(cli->inbuf,smb_vwv9+1);
if (cli->capabilities & CAP_RAW_MODE) {
diff --git a/source3/libsmb/clifile.c b/source3/libsmb/clifile.c
index 9beafc55fb..fb07dae427 100644
--- a/source3/libsmb/clifile.c
+++ b/source3/libsmb/clifile.c
@@ -266,9 +266,10 @@ BOOL cli_unix_stat(struct cli_state *cli, const char *name, SMB_STRUCT_STAT *sbu
/* assume 512 byte blocks */
sbuf->st_blocks /= 512;
#endif
- sbuf->st_ctime = interpret_long_date(rdata + 16); /* time of last change */
- sbuf->st_atime = interpret_long_date(rdata + 24); /* time of last access */
- sbuf->st_mtime = interpret_long_date(rdata + 32); /* time of last modification */
+ set_ctimespec(sbuf, interpret_long_date(rdata + 16)); /* time of last change */
+ set_atimespec(sbuf, interpret_long_date(rdata + 24)); /* time of last access */
+ set_mtimespec(sbuf, interpret_long_date(rdata + 32)); /* time of last modification */
+
sbuf->st_uid = (uid_t) IVAL(rdata,40); /* user ID of owner */
sbuf->st_gid = (gid_t) IVAL(rdata,48); /* group ID of owner */
sbuf->st_mode |= unix_filetype_from_wire(IVAL(rdata, 56));
diff --git a/source3/libsmb/clifsinfo.c b/source3/libsmb/clifsinfo.c
index c6aa6a70a0..9c3b6e3aed 100644
--- a/source3/libsmb/clifsinfo.c
+++ b/source3/libsmb/clifsinfo.c
@@ -282,7 +282,9 @@ BOOL cli_get_fs_volume_info(struct cli_state *cli, fstring volume_name, uint32 *
}
if (pdate) {
- *pdate = interpret_long_date(rdata);
+ struct timespec ts;
+ ts = interpret_long_date(rdata);
+ *pdate = ts.tv_sec;
}
if (pserial_number) {
*pserial_number = IVAL(rdata,8);
diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c
index b022a107d0..18c058f9df 100644
--- a/source3/libsmb/clilist.c
+++ b/source3/libsmb/clilist.c
@@ -49,9 +49,9 @@ static size_t interpret_long_filename(struct cli_state *cli, int level,char *p,f
case 1: /* OS/2 understands this */
/* these dates are converted to GMT by
make_unix_date */
- finfo->ctime = cli_make_unix_date2(cli, p+4);
- finfo->atime = cli_make_unix_date2(cli, p+8);
- finfo->mtime = cli_make_unix_date2(cli, p+12);
+ finfo->ctime_ts = convert_time_t_to_timespec(cli_make_unix_date2(cli, p+4));
+ finfo->atime_ts = convert_time_t_to_timespec(cli_make_unix_date2(cli, p+8));
+ finfo->mtime_ts = convert_time_t_to_timespec(cli_make_unix_date2(cli, p+12));
finfo->size = IVAL(p,16);
finfo->mode = CVAL(p,24);
len = CVAL(p, 26);
@@ -70,9 +70,9 @@ static size_t interpret_long_filename(struct cli_state *cli, int level,char *p,f
case 2: /* this is what OS/2 uses mostly */
/* these dates are converted to GMT by
make_unix_date */
- finfo->ctime = cli_make_unix_date2(cli, p+4);
- finfo->atime = cli_make_unix_date2(cli, p+8);
- finfo->mtime = cli_make_unix_date2(cli, p+12);
+ finfo->ctime_ts = convert_time_t_to_timespec(cli_make_unix_date2(cli, p+4));
+ finfo->atime_ts = convert_time_t_to_timespec(cli_make_unix_date2(cli, p+8));
+ finfo->mtime_ts = convert_time_t_to_timespec(cli_make_unix_date2(cli, p+12));
finfo->size = IVAL(p,16);
finfo->mode = CVAL(p,24);
len = CVAL(p, 30);
@@ -96,11 +96,11 @@ static size_t interpret_long_filename(struct cli_state *cli, int level,char *p,f
/* Offset zero is "create time", not "change time". */
p += 8;
- finfo->atime = interpret_long_date(p);
+ finfo->atime_ts = interpret_long_date(p);
p += 8;
- finfo->mtime = interpret_long_date(p);
+ finfo->mtime_ts = interpret_long_date(p);
p += 8;
- finfo->ctime = interpret_long_date(p);
+ finfo->ctime_ts = interpret_long_date(p);
p += 8;
finfo->size = IVAL2_TO_SMB_BIG_UINT(p,0);
p += 8;
@@ -373,8 +373,10 @@ static int interpret_short_filename(struct cli_state *cli, char *p,file_info *fi
finfo->mode = CVAL(p,21);
/* this date is converted to GMT by make_unix_date */
- finfo->ctime = cli_make_unix_date(cli, p+22);
- finfo->mtime = finfo->atime = finfo->ctime;
+ finfo->ctime_ts.tv_sec = cli_make_unix_date(cli, p+22);
+ finfo->ctime_ts.tv_nsec = 0;
+ finfo->mtime_ts.tv_sec = finfo->atime_ts.tv_sec = finfo->ctime_ts.tv_sec;
+ finfo->mtime_ts.tv_nsec = finfo->atime_ts.tv_nsec = 0;
finfo->size = IVAL(p,26);
clistr_pull(cli, finfo->name, p+30, sizeof(finfo->name), 12, STR_ASCII);
if (strcmp(finfo->name, "..") && strcmp(finfo->name, ".")) {
diff --git a/source3/libsmb/clirap.c b/source3/libsmb/clirap.c
index 1227b26b2f..677c8f1fc3 100644
--- a/source3/libsmb/clirap.c
+++ b/source3/libsmb/clirap.c
@@ -555,8 +555,8 @@ send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level
****************************************************************************/
BOOL cli_qpathinfo2(struct cli_state *cli, const char *fname,
- time_t *create_time, time_t *access_time, time_t *write_time,
- time_t *change_time, SMB_OFF_T *size, uint16 *mode,
+ struct timespec *create_time, struct timespec *access_time, struct timespec *write_time,
+ struct timespec *change_time, SMB_OFF_T *size, uint16 *mode,
SMB_INO_T *ino)
{
unsigned int data_len = 0;
@@ -670,8 +670,8 @@ send a qfileinfo call
****************************************************************************/
BOOL cli_qfileinfo(struct cli_state *cli, int fnum,
uint16 *mode, SMB_OFF_T *size,
- time_t *create_time, time_t *access_time, time_t *write_time,
- time_t *change_time, SMB_INO_T *ino)
+ struct timespec *create_time, struct timespec *access_time, struct timespec *write_time,
+ struct timespec *change_time, SMB_INO_T *ino)
{
unsigned int data_len = 0;
unsigned int param_len = 0;
@@ -794,9 +794,9 @@ BOOL cli_qpathinfo_basic( struct cli_state *cli, const char *name,
return False;
}
- sbuf->st_atime = interpret_long_date( rdata+8 ); /* Access time. */
- sbuf->st_mtime = interpret_long_date( rdata+16 ); /* Write time. */
- sbuf->st_ctime = interpret_long_date( rdata+24 ); /* Change time. */
+ set_atimespec(sbuf, interpret_long_date( rdata+8 )); /* Access time. */
+ set_mtimespec(sbuf, interpret_long_date( rdata+16 )); /* Write time. */
+ set_ctimespec(sbuf, interpret_long_date( rdata+24 )); /* Change time. */
*attributes = IVAL( rdata, 32 );
diff --git a/source3/libsmb/libsmbclient.c b/source3/libsmb/libsmbclient.c
index abeb66b373..2656bd0f04 100644
--- a/source3/libsmb/libsmbclient.c
+++ b/source3/libsmb/libsmbclient.c
@@ -1470,14 +1470,15 @@ smbc_getatr(SMBCCTX * context,
char *path,
uint16 *mode,
SMB_OFF_T *size,
- time_t *c_time,
- time_t *a_time,
- time_t *m_time,
+ struct timespec *c_time_ts,
+ struct timespec *a_time_ts,
+ struct timespec *m_time_ts,
SMB_INO_T *ino)
{
pstring fixedpath;
pstring targetpath;
struct cli_state *targetcli;
+ time_t m_time;
if (!context || !context->internal ||
!context->internal->_initialized) {
@@ -1514,7 +1515,7 @@ smbc_getatr(SMBCCTX * context,
if (!srv->no_pathinfo2 &&
cli_qpathinfo2(targetcli, targetpath,
- NULL, a_time, m_time, c_time, size, mode, ino)) {
+ NULL, a_time_ts, m_time_ts, c_time_ts, size, mode, ino)) {
return True;
}
@@ -1524,10 +1525,11 @@ smbc_getatr(SMBCCTX * context,
return False;
}
- if (cli_getatr(targetcli, targetpath, mode, size, m_time)) {
- if (m_time != NULL) {
- if (a_time != NULL) *a_time = *m_time;
- if (c_time != NULL) *c_time = *m_time;
+ if (cli_getatr(targetcli, targetpath, mode, size, &m_time)) {
+ if (m_time_ts != NULL) {
+ *m_time_ts = convert_time_t_to_timespec(m_time);
+ if (a_time_ts != NULL) *a_time_ts = *m_time_ts;
+ if (c_time_ts != NULL) *c_time_ts = *m_time_ts;
}
srv->no_pathinfo2 = True;
return True;
@@ -1709,11 +1711,11 @@ smbc_unlink_ctx(SMBCCTX *context,
int saverr = errno;
SMB_OFF_T size = 0;
uint16 mode = 0;
- time_t m_time = 0, a_time = 0, c_time = 0;
+ struct timespec m_time_ts, a_time_ts, c_time_ts;
SMB_INO_T ino = 0;
if (!smbc_getatr(context, srv, path, &mode, &size,
- &c_time, &a_time, &m_time, &ino)) {
+ &c_time_ts, &a_time_ts, &m_time_ts, &ino)) {
/* Hmmm, bad error ... What? */
@@ -2049,9 +2051,9 @@ smbc_stat_ctx(SMBCCTX *context,
fstring password;
fstring workgroup;
pstring path;
- time_t m_time = 0;
- time_t a_time = 0;
- time_t c_time = 0;
+ struct timespec m_time_ts;
+ struct timespec a_time_ts;
+ struct timespec c_time_ts;
SMB_OFF_T size = 0;
uint16 mode = 0;
SMB_INO_T ino = 0;
@@ -2095,7 +2097,7 @@ smbc_stat_ctx(SMBCCTX *context,
}
if (!smbc_getatr(context, srv, path, &mode, &size,
- &c_time, &a_time, &m_time, &ino)) {
+ &c_time_ts, &a_time_ts, &m_time_ts, &ino)) {
errno = smbc_errno(context, srv->cli);
return -1;
@@ -2106,9 +2108,9 @@ smbc_stat_ctx(SMBCCTX *context,
smbc_setup_stat(context, st, path, size, mode);
- st->st_atime = a_time;
- st->st_ctime = c_time;
- st->st_mtime = m_time;
+ set_atimespec(st, a_time_ts);
+ set_ctimespec(st, c_time_ts);
+ set_mtimespec(st, m_time_ts);
st->st_dev = srv->dev;
return 0;
@@ -2124,9 +2126,9 @@ smbc_fstat_ctx(SMBCCTX *context,
SMBCFILE *file,
struct stat *st)
{
- time_t c_time;
- time_t a_time;
- time_t m_time;
+ struct timespec c_time_ts;
+ struct timespec a_time_ts;
+ struct timespec m_time_ts;
SMB_OFF_T size;
uint16 mode;
fstring server;
@@ -2182,22 +2184,26 @@ smbc_fstat_ctx(SMBCCTX *context,
/*d_printf(">>>fstat: resolved path as %s\n", targetpath);*/
if (!cli_qfileinfo(targetcli, file->cli_fd, &mode, &size,
- NULL, &a_time, &m_time, &c_time, &ino)) {
- if (!cli_getattrE(targetcli, file->cli_fd, &mode, &size,
- &c_time, &a_time, &m_time)) {
+ NULL, &a_time_ts, &m_time_ts, &c_time_ts, &ino)) {
+ time_t c_time, a_time, m_time;
+ if (!cli_getattrE(targetcli, file->cli_fd, &mode, &size,
+ &c_time, &a_time, &m_time)) {
- errno = EINVAL;
- return -1;
- }
+ errno = EINVAL;
+ return -1;
+ }
+ c_time_ts = convert_time_t_to_timespec(c_time);
+ a_time_ts = convert_time_t_to_timespec(a_time);
+ m_time_ts = convert_time_t_to_timespec(m_time);
}
st->st_ino = ino;
smbc_setup_stat(context, st, file->fname, size, mode);
- st->st_atime = a_time;
- st->st_ctime = c_time;
- st->st_mtime = m_time;
+ set_atimespec(st, a_time_ts);
+ set_ctimespec(st, c_time_ts);
+ set_mtimespec(st, m_time_ts);
st->st_dev = file->srv->dev;
return 0;
@@ -4079,7 +4085,7 @@ dos_attr_query(SMBCCTX *context,
const char *filename,
SMBCSRV *srv)
{
- time_t m_time = 0, a_time = 0, c_time = 0;
+ struct timespec m_time_ts, a_time_ts, c_time_ts;
SMB_OFF_T size = 0;
uint16 mode = 0;
SMB_INO_T inode = 0;
@@ -4094,7 +4100,7 @@ dos_attr_query(SMBCCTX *context,
/* Obtain the DOS attributes */
if (!smbc_getatr(context, srv, CONST_DISCARD(char *, filename),
&mode, &size,
- &c_time, &a_time, &m_time, &inode)) {
+ &c_time_ts, &a_time_ts, &m_time_ts, &inode)) {
errno = smbc_errno(context, srv->cli);
DEBUG(5, ("dos_attr_query Failed to query old attributes\n"));
@@ -4104,9 +4110,9 @@ dos_attr_query(SMBCCTX *context,
ret->mode = mode;
ret->size = size;
- ret->a_time = a_time;
- ret->c_time = c_time;
- ret->m_time = m_time;
+ ret->a_time = convert_timespec_to_time_t(a_time_ts);
+ ret->c_time = convert_timespec_to_time_t(c_time_ts);
+ ret->m_time = convert_timespec_to_time_t(m_time_ts);
ret->inode = inode;
return ret;
@@ -4200,7 +4206,8 @@ cacl_get(SMBCCTX *context,
char *name;
char *pExclude;
char *p;
- time_t m_time = 0, a_time = 0, c_time = 0;
+ struct timespec m_time_ts, a_time_ts, c_time_ts;
+ time_t m_time = (time_t)0, a_time = (time_t)0, c_time = (time_t)0;
SMB_OFF_T size = 0;
uint16 mode = 0;
SMB_INO_T ino = 0;
@@ -4547,13 +4554,16 @@ cacl_get(SMBCCTX *context,
/* Obtain the DOS attributes */
if (!smbc_getatr(context, srv, filename, &mode, &size,
- &c_time, &a_time, &m_time, &ino)) {
+ &c_time_ts, &a_time_ts, &m_time_ts, &ino)) {
errno = smbc_errno(context, srv->cli);
return -1;
}
-
+ c_time = convert_timespec_to_time_t(c_time_ts);
+ a_time = convert_timespec_to_time_t(a_time_ts);
+ m_time = convert_timespec_to_time_t(m_time_ts);
+
if (! exclude_dos_mode) {
if (all || all_dos) {
if (determine_size) {