]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
r6120: Added "volume" command to smbclient that prints out the volume name and
authorJeremy Allison <jra@samba.org>
Wed, 30 Mar 2005 00:47:57 +0000 (00:47 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:56:23 +0000 (10:56 -0500)
serial number.
Jeremy.

source/client/client.c
source/libsmb/clifsinfo.c

index dbddf764158f49c8310ba20f6dff5c2f73c30555..d739f84b386423e4a1d9c211929635d4c568b874 100644 (file)
@@ -2235,6 +2235,25 @@ static int cmd_rename(void)
        return 0;
 }
 
+/****************************************************************************
+ Print the volume name.
+****************************************************************************/
+
+static int cmd_volume(void)
+{
+       fstring volname;
+       uint32 serial_num;
+       time_t create_date;
+  
+       if (!cli_get_fs_volume_info(cli, volname, &serial_num, &create_date)) {
+               d_printf("Errr %s getting volume info\n",cli_errstr(cli));
+               return 1;
+       }
+       
+       d_printf("Volume: |%s| serial number 0x%x\n", volname, (unsigned int)serial_num);
+       return 0;
+}
+
 /****************************************************************************
  Hard link files using the NT call.
 ****************************************************************************/
@@ -2748,6 +2767,7 @@ static struct
   {"tar",cmd_tar,"tar <c|x>[IXFqbgNan] current directory to/from <file name>",{COMPL_NONE,COMPL_NONE}},
   {"tarmode",cmd_tarmode,"<full|inc|reset|noreset> tar's behaviour towards archive bits",{COMPL_NONE,COMPL_NONE}},
   {"translate",cmd_translate,"toggle text translation for printing",{COMPL_NONE,COMPL_NONE}},
+  {"volume",cmd_volume,"print the volume name",{COMPL_NONE,COMPL_NONE}},
   {"vuid",cmd_vuid,"change current vuid",{COMPL_NONE,COMPL_NONE}},
   {"logon",cmd_logon,"establish new logon",{COMPL_NONE,COMPL_NONE}},
   {"listconnect",cmd_list_connect,"list open connections",{COMPL_NONE,COMPL_NONE}},
index 22c8bff3ba02bd526bb2cbd699b8d4eaf4ad329f..2874ee6ca1cba99dfd0e7a60fcf24612f7d308d6 100644 (file)
@@ -132,3 +132,118 @@ cleanup:
 
        return ret;     
 }
+
+BOOL cli_get_fs_volume_info_old(struct cli_state *cli, fstring volume_name, uint32 *pserial_number)
+{
+       BOOL ret = False;
+       uint16 setup;
+       char param[2];
+       char *rparam=NULL, *rdata=NULL;
+       unsigned int rparam_count=0, rdata_count=0;
+       unsigned char nlen;
+
+       setup = TRANSACT2_QFSINFO;
+       
+       SSVAL(param,0,SMB_INFO_VOLUME);
+
+       if (!cli_send_trans(cli, SMBtrans2, 
+                   NULL, 
+                   0, 0,
+                   &setup, 1, 0,
+                   param, 2, 0,
+                   NULL, 0, 560)) {
+               goto cleanup;
+       }
+       
+       if (!cli_receive_trans(cli, SMBtrans2,
+                              &rparam, &rparam_count,
+                              &rdata, &rdata_count)) {
+               goto cleanup;
+       }
+
+       if (cli_is_error(cli)) {
+               ret = False;
+               goto cleanup;
+       } else {
+               ret = True;
+       }
+
+       if (rdata_count < 5) {
+               goto cleanup;
+       }
+
+       if (pserial_number) {
+               *pserial_number = IVAL(rdata,0);
+       }
+       nlen = CVAL(rdata,l2_vol_cch);
+       clistr_pull(cli, volume_name, rdata + l2_vol_szVolLabel, sizeof(fstring), nlen, STR_NOALIGN);
+
+       /* todo: but not yet needed 
+        *       return the other stuff
+        */
+
+cleanup:
+       SAFE_FREE(rparam);
+       SAFE_FREE(rdata);
+
+       return ret;     
+}
+
+BOOL cli_get_fs_volume_info(struct cli_state *cli, fstring volume_name, uint32 *pserial_number, time_t *pdate)
+{
+       BOOL ret = False;
+       uint16 setup;
+       char param[2];
+       char *rparam=NULL, *rdata=NULL;
+       unsigned int rparam_count=0, rdata_count=0;
+       unsigned int nlen;
+
+       setup = TRANSACT2_QFSINFO;
+       
+       SSVAL(param,0,SMB_QUERY_FS_VOLUME_INFO);
+
+       if (!cli_send_trans(cli, SMBtrans2, 
+                   NULL, 
+                   0, 0,
+                   &setup, 1, 0,
+                   param, 2, 0,
+                   NULL, 0, 560)) {
+               goto cleanup;
+       }
+       
+       if (!cli_receive_trans(cli, SMBtrans2,
+                              &rparam, &rparam_count,
+                              &rdata, &rdata_count)) {
+               goto cleanup;
+       }
+
+       if (cli_is_error(cli)) {
+               ret = False;
+               goto cleanup;
+       } else {
+               ret = True;
+       }
+
+       if (rdata_count < 19) {
+               goto cleanup;
+       }
+
+       if (pdate) {
+               *pdate = interpret_long_date(rdata);
+       }
+       if (pserial_number) {
+               *pserial_number = IVAL(rdata,8);
+       }
+       nlen = IVAL(rdata,12);
+       clistr_pull(cli, volume_name, rdata + 18, sizeof(fstring), nlen, STR_UNICODE);
+
+       /* todo: but not yet needed 
+        *       return the other stuff
+        */
+
+cleanup:
+       SAFE_FREE(rparam);
+       SAFE_FREE(rdata);
+
+       return ret;     
+}