2 Unix SMB/CIFS implementation.
4 Copyright (C) James J Myers 2003 <myersjj@samba.org>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 /****************************************************************************
25 ****************************************************************************/
26 BOOL
cli_qpathinfo(struct cli_state
*cli
, const char *fname
,
27 time_t *c_time
, time_t *a_time
, time_t *m_time
,
28 size_t *size
, uint16
*mode
)
30 union smb_fileinfo parms
;
34 mem_ctx
= talloc_init("cli_qpathinfo");
35 if (!mem_ctx
) return False
;
37 parms
.standard
.level
= RAW_FILEINFO_STANDARD
;
38 parms
.standard
.in
.fname
= fname
;
40 status
= smb_raw_pathinfo(cli
->tree
, mem_ctx
, &parms
);
41 talloc_destroy(mem_ctx
);
42 if (!NT_STATUS_IS_OK(status
)) {
47 *c_time
= parms
.standard
.out
.create_time
;
50 *a_time
= parms
.standard
.out
.access_time
;
53 *m_time
= parms
.standard
.out
.write_time
;
56 *size
= parms
.standard
.out
.size
;
59 *mode
= parms
.standard
.out
.attrib
;
65 /****************************************************************************
66 send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level
67 ****************************************************************************/
68 BOOL
cli_qpathinfo2(struct cli_state
*cli
, const char *fname
,
69 time_t *c_time
, time_t *a_time
, time_t *m_time
,
70 time_t *w_time
, size_t *size
, uint16
*mode
,
73 union smb_fileinfo parms
;
77 mem_ctx
= talloc_init("cli_qfilename");
78 if (!mem_ctx
) return False
;
80 parms
.all_info
.level
= RAW_FILEINFO_ALL_INFO
;
81 parms
.all_info
.in
.fname
= fname
;
83 status
= smb_raw_pathinfo(cli
->tree
, mem_ctx
, &parms
);
84 talloc_destroy(mem_ctx
);
85 if (!NT_STATUS_IS_OK(status
)) {
90 *c_time
= nt_time_to_unix(&parms
.all_info
.out
.create_time
);
93 *a_time
= nt_time_to_unix(&parms
.all_info
.out
.access_time
);
96 *m_time
= nt_time_to_unix(&parms
.all_info
.out
.change_time
);
99 *w_time
= nt_time_to_unix(&parms
.all_info
.out
.write_time
);
102 *size
= parms
.all_info
.out
.size
;
105 *mode
= parms
.all_info
.out
.attrib
;
112 /****************************************************************************
113 send a qfileinfo QUERY_FILE_NAME_INFO call
114 ****************************************************************************/
115 BOOL
cli_qfilename(struct cli_state
*cli
, int fnum
,
118 union smb_fileinfo parms
;
122 mem_ctx
= talloc_init("cli_qfilename");
123 if (!mem_ctx
) return False
;
125 parms
.name_info
.level
= RAW_FILEINFO_NAME_INFO
;
126 parms
.name_info
.in
.fnum
= fnum
;
128 status
= smb_raw_fileinfo(cli
->tree
, mem_ctx
, &parms
);
129 if (!NT_STATUS_IS_OK(status
)) {
130 talloc_destroy(mem_ctx
);
135 *name
= strdup(parms
.name_info
.out
.fname
.s
);
137 talloc_destroy(mem_ctx
);
143 /****************************************************************************
144 send a qfileinfo call
145 ****************************************************************************/
146 BOOL
cli_qfileinfo(struct cli_state
*cli
, int fnum
,
147 uint16
*mode
, size_t *size
,
148 time_t *c_time
, time_t *a_time
, time_t *m_time
,
149 time_t *w_time
, SMB_INO_T
*ino
)
151 union smb_fileinfo parms
;
155 mem_ctx
= talloc_init("cli_qfileinfo");
156 if (!mem_ctx
) return False
;
158 parms
.all_info
.level
= RAW_FILEINFO_ALL_INFO
;
159 parms
.all_info
.in
.fnum
= fnum
;
161 status
= smb_raw_fileinfo(cli
->tree
, mem_ctx
, &parms
);
162 talloc_destroy(mem_ctx
);
163 if (!NT_STATUS_IS_OK(status
)) {
168 *c_time
= nt_time_to_unix(&parms
.all_info
.out
.create_time
);
171 *a_time
= nt_time_to_unix(&parms
.all_info
.out
.access_time
);
174 *m_time
= nt_time_to_unix(&parms
.all_info
.out
.change_time
);
177 *w_time
= nt_time_to_unix(&parms
.all_info
.out
.write_time
);
180 *mode
= parms
.all_info
.out
.attrib
;
183 *size
= (size_t)parms
.all_info
.out
.size
;
193 /****************************************************************************
194 send a qpathinfo SMB_QUERY_FILE_ALT_NAME_INFO call
195 ****************************************************************************/
196 NTSTATUS
cli_qpathinfo_alt_name(struct cli_state
*cli
, const char *fname
,
197 const char **alt_name
)
199 union smb_fileinfo parms
;
203 parms
.alt_name_info
.level
= RAW_FILEINFO_ALT_NAME_INFO
;
204 parms
.alt_name_info
.in
.fname
= fname
;
206 mem_ctx
= talloc_init("cli_qpathinfo_alt_name");
207 if (!mem_ctx
) return NT_STATUS_NO_MEMORY
;
209 status
= smb_raw_pathinfo(cli
->tree
, mem_ctx
, &parms
);
210 if (!NT_STATUS_IS_OK(status
)) {
211 talloc_destroy(mem_ctx
);
213 return cli_nt_error(cli
);
216 if (!parms
.alt_name_info
.out
.fname
.s
) {
217 *alt_name
= strdup("");
219 *alt_name
= strdup(parms
.alt_name_info
.out
.fname
.s
);
222 talloc_destroy(mem_ctx
);