diff options
author | Volker Lendecke <vl@samba.org> | 2010-11-29 18:09:49 +0100 |
---|---|---|
committer | Volker Lendecke <vlendec@samba.org> | 2010-11-30 12:23:50 +0100 |
commit | e0e4dc1c2282253cfaac5bae39b75361d13c843e (patch) | |
tree | dd8e36cadf4c8de99940ef6bbccdc86b7304930b | |
parent | 3f6705e8e3055133cc155797e66233d8a5919795 (diff) | |
download | samba-e0e4dc1c2282253cfaac5bae39b75361d13c843e.tar.gz samba-e0e4dc1c2282253cfaac5bae39b75361d13c843e.tar.bz2 samba-e0e4dc1c2282253cfaac5bae39b75361d13c843e.zip |
s3: Add shadow copy info to smbclient allinfo
Autobuild-User: Volker Lendecke <vlendec@samba.org>
Autobuild-Date: Tue Nov 30 12:23:50 CET 2010 on sn-devel-104
-rw-r--r-- | source3/client/client.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/source3/client/client.c b/source3/client/client.c index 062809d1b6..b3bbcf5cd7 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -1633,8 +1633,11 @@ static int do_allinfo(const char *name) uint16_t mode; SMB_INO_T ino; NTTIME tmp; + uint16_t fnum; unsigned int num_streams; struct stream_struct *streams; + int num_snapshots; + char **snapshots; unsigned int i; NTSTATUS status; @@ -1681,6 +1684,49 @@ static int do_allinfo(const char *name) (unsigned long long)streams[i].size); } + status = cli_open(cli, name, O_RDONLY, DENY_NONE, &fnum); + if (!NT_STATUS_IS_OK(status)) { + /* + * Ignore failure, it does not hurt if we can't list + * snapshots + */ + return 0; + } + status = cli_shadow_copy_data(talloc_tos(), cli, fnum, + true, &snapshots, &num_snapshots); + if (!NT_STATUS_IS_OK(status)) { + cli_close(cli, fnum); + return 0; + } + + for (i=0; i<num_snapshots; i++) { + char *snap_name; + + d_printf("%s\n", snapshots[i]); + snap_name = talloc_asprintf(talloc_tos(), "%s%s", + snapshots[i], name); + status = cli_qpathinfo2(cli, snap_name, &b_time, &a_time, + &m_time, &c_time, &size, + NULL, NULL); + if (!NT_STATUS_IS_OK(status)) { + d_fprintf(stderr, "pathinfo(%s) failed: %s\n", + snap_name, nt_errstr(status)); + TALLOC_FREE(snap_name); + continue; + } + unix_timespec_to_nt_time(&tmp, b_time); + d_printf("create_time: %s\n", nt_time_string(talloc_tos(), tmp)); + unix_timespec_to_nt_time(&tmp, a_time); + d_printf("access_time: %s\n", nt_time_string(talloc_tos(), tmp)); + unix_timespec_to_nt_time(&tmp, m_time); + d_printf("write_time: %s\n", nt_time_string(talloc_tos(), tmp)); + unix_timespec_to_nt_time(&tmp, c_time); + d_printf("change_time: %s\n", nt_time_string(talloc_tos(), tmp)); + d_printf("size: %d\n", (int)size); + } + + TALLOC_FREE(snapshots); + return 0; } |