libsmb/clifsinfo.c

説明を見る。
00001 /* 
00002    Unix SMB/CIFS implementation.
00003    FS info functions
00004    Copyright (C) Stefan (metze) Metzmacher      2003
00005    
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015    
00016    You should have received a copy of the GNU General Public License
00017    along with this program; if not, write to the Free Software
00018    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019 */
00020 
00021 #include "includes.h"
00022 
00023 /****************************************************************************
00024  Get UNIX extensions version info.
00025 ****************************************************************************/
00026                                                                                                                    
00027 BOOL cli_unix_extensions_version(struct cli_state *cli, uint16 *pmajor, uint16 *pminor,
00028                                         uint32 *pcaplow, uint32 *pcaphigh)
00029 {
00030         BOOL ret = False;
00031         uint16 setup;
00032         char param[2];
00033         char *rparam=NULL, *rdata=NULL;
00034         unsigned int rparam_count=0, rdata_count=0;
00035 
00036         setup = TRANSACT2_QFSINFO;
00037         
00038         SSVAL(param,0,SMB_QUERY_CIFS_UNIX_INFO);
00039 
00040         if (!cli_send_trans(cli, SMBtrans2, 
00041                     NULL, 
00042                     0, 0,
00043                     &setup, 1, 0,
00044                     param, 2, 0,
00045                     NULL, 0, 560)) {
00046                 goto cleanup;
00047         }
00048         
00049         if (!cli_receive_trans(cli, SMBtrans2,
00050                               &rparam, &rparam_count,
00051                               &rdata, &rdata_count)) {
00052                 goto cleanup;
00053         }
00054 
00055         if (cli_is_error(cli)) {
00056                 ret = False;
00057                 goto cleanup;
00058         } else {
00059                 ret = True;
00060         }
00061 
00062         if (rdata_count < 12) {
00063                 goto cleanup;
00064         }
00065 
00066         *pmajor = SVAL(rdata,0);
00067         *pminor = SVAL(rdata,2);
00068         *pcaplow = IVAL(rdata,4);
00069         *pcaphigh = IVAL(rdata,8);
00070 
00071         /* todo: but not yet needed 
00072          *       return the other stuff
00073          */
00074 
00075 cleanup:
00076         SAFE_FREE(rparam);
00077         SAFE_FREE(rdata);
00078 
00079         return ret;     
00080 }
00081 
00082 /****************************************************************************
00083  Set UNIX extensions capabilities.
00084 ****************************************************************************/
00085                                                                                                                    
00086 BOOL cli_set_unix_extensions_capabilities(struct cli_state *cli, uint16 major, uint16 minor,
00087                                         uint32 caplow, uint32 caphigh)
00088 {
00089         BOOL ret = False;
00090         uint16 setup;
00091         char param[4];
00092         char data[12];
00093         char *rparam=NULL, *rdata=NULL;
00094         unsigned int rparam_count=0, rdata_count=0;
00095 
00096         setup = TRANSACT2_SETFSINFO;
00097         
00098         SSVAL(param,0,0);
00099         SSVAL(param,2,SMB_SET_CIFS_UNIX_INFO);
00100 
00101         SSVAL(data,0,major);
00102         SSVAL(data,2,minor);
00103         SIVAL(data,4,caplow);
00104         SIVAL(data,8,caphigh);
00105 
00106         if (!cli_send_trans(cli, SMBtrans2, 
00107                     NULL, 
00108                     0, 0,
00109                     &setup, 1, 0,
00110                     param, 4, 0,
00111                     data, 12, 560)) {
00112                 goto cleanup;
00113         }
00114         
00115         if (!cli_receive_trans(cli, SMBtrans2,
00116                               &rparam, &rparam_count,
00117                               &rdata, &rdata_count)) {
00118                 goto cleanup;
00119         }
00120 
00121         if (cli_is_error(cli)) {
00122                 ret = False;
00123                 goto cleanup;
00124         } else {
00125                 ret = True;
00126         }
00127 
00128 cleanup:
00129         SAFE_FREE(rparam);
00130         SAFE_FREE(rdata);
00131 
00132         return ret;     
00133 }
00134 
00135 BOOL cli_get_fs_attr_info(struct cli_state *cli, uint32 *fs_attr)
00136 {
00137         BOOL ret = False;
00138         uint16 setup;
00139         char param[2];
00140         char *rparam=NULL, *rdata=NULL;
00141         unsigned int rparam_count=0, rdata_count=0;
00142 
00143         if (!cli||!fs_attr)
00144                 smb_panic("cli_get_fs_attr_info() called with NULL Pionter!");
00145 
00146         setup = TRANSACT2_QFSINFO;
00147         
00148         SSVAL(param,0,SMB_QUERY_FS_ATTRIBUTE_INFO);
00149 
00150         if (!cli_send_trans(cli, SMBtrans2, 
00151                     NULL, 
00152                     0, 0,
00153                     &setup, 1, 0,
00154                     param, 2, 0,
00155                     NULL, 0, 560)) {
00156                 goto cleanup;
00157         }
00158         
00159         if (!cli_receive_trans(cli, SMBtrans2,
00160                               &rparam, &rparam_count,
00161                               &rdata, &rdata_count)) {
00162                 goto cleanup;
00163         }
00164 
00165         if (cli_is_error(cli)) {
00166                 ret = False;
00167                 goto cleanup;
00168         } else {
00169                 ret = True;
00170         }
00171 
00172         if (rdata_count < 12) {
00173                 goto cleanup;
00174         }
00175 
00176         *fs_attr = IVAL(rdata,0);
00177 
00178         /* todo: but not yet needed 
00179          *       return the other stuff
00180          */
00181 
00182 cleanup:
00183         SAFE_FREE(rparam);
00184         SAFE_FREE(rdata);
00185 
00186         return ret;     
00187 }
00188 
00189 BOOL cli_get_fs_volume_info_old(struct cli_state *cli, fstring volume_name, uint32 *pserial_number)
00190 {
00191         BOOL ret = False;
00192         uint16 setup;
00193         char param[2];
00194         char *rparam=NULL, *rdata=NULL;
00195         unsigned int rparam_count=0, rdata_count=0;
00196         unsigned char nlen;
00197 
00198         setup = TRANSACT2_QFSINFO;
00199         
00200         SSVAL(param,0,SMB_INFO_VOLUME);
00201 
00202         if (!cli_send_trans(cli, SMBtrans2, 
00203                     NULL, 
00204                     0, 0,
00205                     &setup, 1, 0,
00206                     param, 2, 0,
00207                     NULL, 0, 560)) {
00208                 goto cleanup;
00209         }
00210         
00211         if (!cli_receive_trans(cli, SMBtrans2,
00212                               &rparam, &rparam_count,
00213                               &rdata, &rdata_count)) {
00214                 goto cleanup;
00215         }
00216 
00217         if (cli_is_error(cli)) {
00218                 ret = False;
00219                 goto cleanup;
00220         } else {
00221                 ret = True;
00222         }
00223 
00224         if (rdata_count < 5) {
00225                 goto cleanup;
00226         }
00227 
00228         if (pserial_number) {
00229                 *pserial_number = IVAL(rdata,0);
00230         }
00231         nlen = CVAL(rdata,l2_vol_cch);
00232         clistr_pull(cli, volume_name, rdata + l2_vol_szVolLabel, sizeof(fstring), nlen, STR_NOALIGN);
00233 
00234         /* todo: but not yet needed 
00235          *       return the other stuff
00236          */
00237 
00238 cleanup:
00239         SAFE_FREE(rparam);
00240         SAFE_FREE(rdata);
00241 
00242         return ret;     
00243 }
00244 
00245 BOOL cli_get_fs_volume_info(struct cli_state *cli, fstring volume_name, uint32 *pserial_number, time_t *pdate)
00246 {
00247         BOOL ret = False;
00248         uint16 setup;
00249         char param[2];
00250         char *rparam=NULL, *rdata=NULL;
00251         unsigned int rparam_count=0, rdata_count=0;
00252         unsigned int nlen;
00253 
00254         setup = TRANSACT2_QFSINFO;
00255         
00256         SSVAL(param,0,SMB_QUERY_FS_VOLUME_INFO);
00257 
00258         if (!cli_send_trans(cli, SMBtrans2, 
00259                     NULL, 
00260                     0, 0,
00261                     &setup, 1, 0,
00262                     param, 2, 0,
00263                     NULL, 0, 560)) {
00264                 goto cleanup;
00265         }
00266         
00267         if (!cli_receive_trans(cli, SMBtrans2,
00268                               &rparam, &rparam_count,
00269                               &rdata, &rdata_count)) {
00270                 goto cleanup;
00271         }
00272 
00273         if (cli_is_error(cli)) {
00274                 ret = False;
00275                 goto cleanup;
00276         } else {
00277                 ret = True;
00278         }
00279 
00280         if (rdata_count < 19) {
00281                 goto cleanup;
00282         }
00283 
00284         if (pdate) {
00285                 struct timespec ts;
00286                 ts = interpret_long_date(rdata);
00287                 *pdate = ts.tv_sec;
00288         }
00289         if (pserial_number) {
00290                 *pserial_number = IVAL(rdata,8);
00291         }
00292         nlen = IVAL(rdata,12);
00293         clistr_pull(cli, volume_name, rdata + 18, sizeof(fstring), nlen, STR_UNICODE);
00294 
00295         /* todo: but not yet needed 
00296          *       return the other stuff
00297          */
00298 
00299 cleanup:
00300         SAFE_FREE(rparam);
00301         SAFE_FREE(rdata);
00302 
00303         return ret;     
00304 }

Sambaに対してSat Aug 29 21:23:04 2009に生成されました。  doxygen 1.4.7