Skip to content

Commit

Permalink
s3: client: Add btime_ts to struct finfo.
Browse files Browse the repository at this point in the history
Fill it in when available, else return it as zero.

Based on a patch from Puran Chand <[email protected]>.

Signed-off-by: Jeremy Allison <[email protected]>
Reviewed-by: Andreas Schneider <[email protected]>
Reviewed-by: Alexander Bokovoy <[email protected]>
  • Loading branch information
jrasamba committed May 4, 2018
1 parent 30e6b59 commit abb80ce
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/fuse/clifuse.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ static NTSTATUS parse_finfo_id_both_directory_info(uint8_t *dir_data,
return NT_STATUS_INFO_LENGTH_MISMATCH;
}

finfo->btime_ts = interpret_long_date((const char *)dir_data + 8);
finfo->atime_ts = interpret_long_date((const char *)dir_data + 16);
finfo->mtime_ts = interpret_long_date((const char *)dir_data + 24);
finfo->ctime_ts = interpret_long_date((const char *)dir_data + 32);
Expand Down
1 change: 1 addition & 0 deletions source3/include/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ struct file_info {
uid_t uid;
gid_t gid;
/* these times are normally kept in GMT */
struct timespec btime_ts; /* Birth-time if supported by system */
struct timespec mtime_ts;
struct timespec atime_ts;
struct timespec ctime_ts;
Expand Down
1 change: 1 addition & 0 deletions source3/libsmb/cli_smb2_fnum.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,7 @@ static NTSTATUS parse_finfo_id_both_directory_info(uint8_t *dir_data,
return NT_STATUS_INFO_LENGTH_MISMATCH;
}

finfo->btime_ts = interpret_long_date((const char *)dir_data + 8);
finfo->atime_ts = interpret_long_date((const char *)dir_data + 16);
finfo->mtime_ts = interpret_long_date((const char *)dir_data + 24);
finfo->ctime_ts = interpret_long_date((const char *)dir_data + 32);
Expand Down
19 changes: 19 additions & 0 deletions source3/libsmb/clilist.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ static size_t interpret_long_filename(TALLOC_CTX *ctx,
if (pdata_end - base < 27) {
return pdata_end - base;
}
/*
* What we're returning here as ctime_ts is
* actually the server create time.
*/
finfo->btime_ts = convert_time_t_to_timespec(
make_unix_date2(p+4,
smb1cli_conn_server_time_zone(
cli->conn)));
finfo->ctime_ts = convert_time_t_to_timespec(
make_unix_date2(p+4, smb1cli_conn_server_time_zone(cli->conn)));
finfo->atime_ts = convert_time_t_to_timespec(
Expand Down Expand Up @@ -128,6 +136,14 @@ static size_t interpret_long_filename(TALLOC_CTX *ctx,
if (pdata_end - base < 31) {
return pdata_end - base;
}
/*
* What we're returning here as ctime_ts is
* actually the server create time.
*/
finfo->btime_ts = convert_time_t_to_timespec(
make_unix_date2(p+4,
smb1cli_conn_server_time_zone(
cli->conn)));
finfo->ctime_ts = convert_time_t_to_timespec(
make_unix_date2(p+4, smb1cli_conn_server_time_zone(cli->conn)));
finfo->atime_ts = convert_time_t_to_timespec(
Expand Down Expand Up @@ -250,6 +266,9 @@ static bool interpret_short_filename(TALLOC_CTX *ctx,

finfo->mode = CVAL(p,21);

/* We don't get birth time. */
finfo->btime_ts.tv_sec = 0;
finfo->btime_ts.tv_nsec = 0;
/* this date is converted to GMT by make_unix_date */
finfo->ctime_ts.tv_sec = make_unix_date(p+22, smb1cli_conn_server_time_zone(cli->conn));
finfo->ctime_ts.tv_nsec = 0;
Expand Down

0 comments on commit abb80ce

Please sign in to comment.