2003-08-13 05:53:07 +04:00
/*
Unix SMB / CIFS implementation .
client trans2 calls
Copyright ( C ) James J Myers 2003 < myersjj @ samba . org >
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
2007-07-10 06:07:03 +04:00
the Free Software Foundation ; either version 3 of the License , or
2003-08-13 05:53:07 +04:00
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
2007-07-10 06:07:03 +04:00
along with this program . If not , see < http : //www.gnu.org/licenses/>.
2003-08-13 05:53:07 +04:00
*/
# include "includes.h"
2005-12-28 18:38:36 +03:00
# include "libcli/raw/libcliraw.h"
2007-09-08 17:27:14 +04:00
# include "libcli/libcli.h"
2003-08-13 05:53:07 +04:00
/****************************************************************************
send a qpathinfo call
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2004-08-04 17:23:35 +04:00
NTSTATUS smbcli_qpathinfo ( struct smbcli_tree * tree , const char * fname ,
2004-02-10 14:33:35 +03:00
time_t * c_time , time_t * a_time , time_t * m_time ,
2004-05-25 21:24:24 +04:00
size_t * size , uint16_t * mode )
2003-08-13 05:53:07 +04:00
{
union smb_fileinfo parms ;
TALLOC_CTX * mem_ctx ;
NTSTATUS status ;
2004-08-04 17:23:35 +04:00
mem_ctx = talloc_init ( " smbcli_qpathinfo " ) ;
2004-02-10 14:33:35 +03:00
if ( ! mem_ctx ) return NT_STATUS_NO_MEMORY ;
2003-08-13 05:53:07 +04:00
parms . standard . level = RAW_FILEINFO_STANDARD ;
2006-03-13 01:48:25 +03:00
parms . standard . in . file . path = fname ;
2003-08-13 05:53:07 +04:00
2004-02-08 03:51:07 +03:00
status = smb_raw_pathinfo ( tree , mem_ctx , & parms ) ;
2005-01-27 10:08:20 +03:00
talloc_free ( mem_ctx ) ;
2004-02-10 14:33:35 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
return status ;
2003-08-13 05:53:07 +04:00
if ( c_time ) {
* c_time = parms . standard . out . create_time ;
}
if ( a_time ) {
* a_time = parms . standard . out . access_time ;
}
if ( m_time ) {
* m_time = parms . standard . out . write_time ;
}
if ( size ) {
* size = parms . standard . out . size ;
}
if ( mode ) {
* mode = parms . standard . out . attrib ;
}
2004-02-10 14:33:35 +03:00
return status ;
2003-08-13 05:53:07 +04:00
}
/****************************************************************************
send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2004-08-04 17:23:35 +04:00
NTSTATUS smbcli_qpathinfo2 ( struct smbcli_tree * tree , const char * fname ,
2004-02-10 14:33:35 +03:00
time_t * c_time , time_t * a_time , time_t * m_time ,
2004-05-25 21:24:24 +04:00
time_t * w_time , size_t * size , uint16_t * mode ,
2004-11-01 23:21:54 +03:00
ino_t * ino )
2003-08-13 05:53:07 +04:00
{
union smb_fileinfo parms ;
TALLOC_CTX * mem_ctx ;
NTSTATUS status ;
2004-08-04 17:23:35 +04:00
mem_ctx = talloc_init ( " smbcli_qfilename " ) ;
2004-02-10 14:33:35 +03:00
if ( ! mem_ctx ) return NT_STATUS_NO_MEMORY ;
2003-08-13 05:53:07 +04:00
parms . all_info . level = RAW_FILEINFO_ALL_INFO ;
2006-03-13 01:48:25 +03:00
parms . all_info . in . file . path = fname ;
2003-08-13 05:53:07 +04:00
2004-02-08 03:51:07 +03:00
status = smb_raw_pathinfo ( tree , mem_ctx , & parms ) ;
2005-01-27 10:08:20 +03:00
talloc_free ( mem_ctx ) ;
2004-02-10 14:33:35 +03:00
if ( ! NT_STATUS_IS_OK ( status ) )
return status ;
2003-08-13 05:53:07 +04:00
if ( c_time ) {
2004-05-25 17:57:39 +04:00
* c_time = nt_time_to_unix ( parms . all_info . out . create_time ) ;
2003-08-13 05:53:07 +04:00
}
if ( a_time ) {
2004-05-25 17:57:39 +04:00
* a_time = nt_time_to_unix ( parms . all_info . out . access_time ) ;
2003-08-13 05:53:07 +04:00
}
if ( m_time ) {
2004-05-25 17:57:39 +04:00
* m_time = nt_time_to_unix ( parms . all_info . out . change_time ) ;
2003-08-13 05:53:07 +04:00
}
if ( w_time ) {
2004-05-25 17:57:39 +04:00
* w_time = nt_time_to_unix ( parms . all_info . out . write_time ) ;
2003-08-13 05:53:07 +04:00
}
if ( size ) {
* size = parms . all_info . out . size ;
}
if ( mode ) {
* mode = parms . all_info . out . attrib ;
}
2004-02-10 14:33:35 +03:00
return status ;
2003-08-13 05:53:07 +04:00
}
/****************************************************************************
send a qfileinfo QUERY_FILE_NAME_INFO call
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2004-08-04 17:23:35 +04:00
NTSTATUS smbcli_qfilename ( struct smbcli_tree * tree , int fnum , const char * * name )
2003-08-13 05:53:07 +04:00
{
union smb_fileinfo parms ;
TALLOC_CTX * mem_ctx ;
NTSTATUS status ;
2004-08-04 17:23:35 +04:00
mem_ctx = talloc_init ( " smbcli_qfilename " ) ;
2004-02-10 14:33:35 +03:00
if ( ! mem_ctx ) return NT_STATUS_NO_MEMORY ;
2003-08-13 05:53:07 +04:00
parms . name_info . level = RAW_FILEINFO_NAME_INFO ;
2006-03-13 01:48:25 +03:00
parms . name_info . in . file . fnum = fnum ;
2003-08-13 05:53:07 +04:00
2004-02-08 03:51:07 +03:00
status = smb_raw_fileinfo ( tree , mem_ctx , & parms ) ;
2003-08-13 05:53:07 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2005-01-27 10:08:20 +03:00
talloc_free ( mem_ctx ) ;
2003-08-13 05:53:07 +04:00
* name = NULL ;
2004-02-10 14:33:35 +03:00
return status ;
2003-08-13 05:53:07 +04:00
}
* name = strdup ( parms . name_info . out . fname . s ) ;
2005-01-27 10:08:20 +03:00
talloc_free ( mem_ctx ) ;
2003-08-13 05:53:07 +04:00
2004-02-10 14:33:35 +03:00
return status ;
2003-08-13 05:53:07 +04:00
}
/****************************************************************************
send a qfileinfo call
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2004-08-04 17:23:35 +04:00
NTSTATUS smbcli_qfileinfo ( struct smbcli_tree * tree , int fnum ,
2004-05-25 21:24:24 +04:00
uint16_t * mode , size_t * size ,
2004-02-10 14:33:35 +03:00
time_t * c_time , time_t * a_time , time_t * m_time ,
2004-11-01 23:21:54 +03:00
time_t * w_time , ino_t * ino )
2003-08-13 05:53:07 +04:00
{
union smb_fileinfo parms ;
TALLOC_CTX * mem_ctx ;
NTSTATUS status ;
2004-08-04 17:23:35 +04:00
mem_ctx = talloc_init ( " smbcli_qfileinfo " ) ;
2004-02-10 14:33:35 +03:00
if ( ! mem_ctx )
return NT_STATUS_NO_MEMORY ;
2003-08-13 05:53:07 +04:00
parms . all_info . level = RAW_FILEINFO_ALL_INFO ;
2006-03-13 01:48:25 +03:00
parms . all_info . in . file . fnum = fnum ;
2003-08-13 05:53:07 +04:00
2004-02-08 03:51:07 +03:00
status = smb_raw_fileinfo ( tree , mem_ctx , & parms ) ;
2005-01-27 10:08:20 +03:00
talloc_free ( mem_ctx ) ;
2003-08-13 05:53:07 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2004-02-10 14:33:35 +03:00
return status ;
2003-08-13 05:53:07 +04:00
}
if ( c_time ) {
2004-05-25 17:57:39 +04:00
* c_time = nt_time_to_unix ( parms . all_info . out . create_time ) ;
2003-08-13 05:53:07 +04:00
}
if ( a_time ) {
2004-05-25 17:57:39 +04:00
* a_time = nt_time_to_unix ( parms . all_info . out . access_time ) ;
2003-08-13 05:53:07 +04:00
}
if ( m_time ) {
2004-05-25 17:57:39 +04:00
* m_time = nt_time_to_unix ( parms . all_info . out . change_time ) ;
2003-08-13 05:53:07 +04:00
}
if ( w_time ) {
2004-05-25 17:57:39 +04:00
* w_time = nt_time_to_unix ( parms . all_info . out . write_time ) ;
2003-08-13 05:53:07 +04:00
}
if ( mode ) {
* mode = parms . all_info . out . attrib ;
}
if ( size ) {
* size = ( size_t ) parms . all_info . out . size ;
}
if ( ino ) {
* ino = 0 ;
}
2004-02-10 14:33:35 +03:00
return status ;
2003-08-13 05:53:07 +04:00
}
/****************************************************************************
send a qpathinfo SMB_QUERY_FILE_ALT_NAME_INFO call
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2004-08-04 17:23:35 +04:00
NTSTATUS smbcli_qpathinfo_alt_name ( struct smbcli_tree * tree , const char * fname ,
2003-08-13 05:53:07 +04:00
const char * * alt_name )
{
union smb_fileinfo parms ;
TALLOC_CTX * mem_ctx ;
NTSTATUS status ;
parms . alt_name_info . level = RAW_FILEINFO_ALT_NAME_INFO ;
2006-03-13 01:48:25 +03:00
parms . alt_name_info . in . file . path = fname ;
2003-08-13 05:53:07 +04:00
2004-08-04 17:23:35 +04:00
mem_ctx = talloc_init ( " smbcli_qpathinfo_alt_name " ) ;
2003-08-13 05:53:07 +04:00
if ( ! mem_ctx ) return NT_STATUS_NO_MEMORY ;
2004-02-08 03:51:07 +03:00
status = smb_raw_pathinfo ( tree , mem_ctx , & parms ) ;
2003-08-13 05:53:07 +04:00
if ( ! NT_STATUS_IS_OK ( status ) ) {
2005-01-27 10:08:20 +03:00
talloc_free ( mem_ctx ) ;
2003-08-13 05:53:07 +04:00
* alt_name = NULL ;
2004-08-04 17:23:35 +04:00
return smbcli_nt_error ( tree ) ;
2003-08-13 05:53:07 +04:00
}
2003-08-15 19:14:49 +04:00
if ( ! parms . alt_name_info . out . fname . s ) {
* alt_name = strdup ( " " ) ;
} else {
* alt_name = strdup ( parms . alt_name_info . out . fname . s ) ;
}
2003-08-13 05:53:07 +04:00
2005-01-27 10:08:20 +03:00
talloc_free ( mem_ctx ) ;
2003-08-13 05:53:07 +04:00
return NT_STATUS_OK ;
}