s3: Make cli_get_fs_volume_info() use cli_trans()
authorVolker Lendecke <vl@samba.org>
Sun, 7 Feb 2010 11:08:39 +0000 (12:08 +0100)
committerVolker Lendecke <vl@samba.org>
Sun, 7 Feb 2010 11:29:25 +0000 (12:29 +0100)
source3/client/client.c
source3/include/proto.h
source3/libsmb/clifsinfo.c

index f177129dc782cc5920c1e8192ddc5477f1126aa4..1ceb3ab6396d6611b30a1d436ffa0bb8939889f3 100644 (file)
@@ -3376,9 +3376,12 @@ static int cmd_volume(void)
        fstring volname;
        uint32 serial_num;
        time_t create_date;
+       NTSTATUS status;
 
-       if (!cli_get_fs_volume_info(cli, volname, &serial_num, &create_date)) {
-               d_printf("Errr %s getting volume info\n",cli_errstr(cli));
+       status = cli_get_fs_volume_info(cli, volname, &serial_num,
+                                       &create_date);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("Error %s getting volume info\n", nt_errstr(status));
                return 1;
        }
 
index 0660e77c732288598d84512d054f8f61064d009f..0db536d7b90608e0046d6a11ecabde3ba60bbbd2 100644 (file)
@@ -2708,7 +2708,8 @@ struct tevent_req *cli_get_fs_attr_info_send(TALLOC_CTX *mem_ctx,
                                             struct cli_state *cli);
 NTSTATUS cli_get_fs_attr_info_recv(struct tevent_req *req, uint32_t *fs_attr);
 NTSTATUS cli_get_fs_attr_info(struct cli_state *cli, uint32_t *fs_attr);
-bool cli_get_fs_volume_info(struct cli_state *cli, fstring volume_name, uint32 *pserial_number, time_t *pdate);
+NTSTATUS cli_get_fs_volume_info(struct cli_state *cli, fstring volume_name,
+                               uint32 *pserial_number, time_t *pdate);
 bool cli_get_fs_full_size_info(struct cli_state *cli,
                                uint64_t *total_allocation_units,
                                uint64_t *caller_allocation_units,
index 08c0252eb831785ede72b18f44b34e6440e584af..b3c9d5f6e7ff2b2631da7bfcbfebbbc21be338ae 100644 (file)
@@ -348,48 +348,34 @@ fail:
        return status;
 }
 
-bool cli_get_fs_volume_info(struct cli_state *cli, fstring volume_name, uint32 *pserial_number, time_t *pdate)
+NTSTATUS 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;
+       NTSTATUS status;
+       uint16 setup[1];
+       uint8_t param[2];
+       uint8_t *rdata;
+       uint32_t rdata_count;
        unsigned int nlen;
 
-       setup = TRANSACT2_QFSINFO;
-
+       SSVAL(setup, 0, 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;
+       status = cli_trans(talloc_tos(), cli, SMBtrans2,
+                          NULL, 0, 0, 0,
+                          setup, 1, 0,
+                          param, 2, 0,
+                          NULL, 0, 560,
+                          NULL, 0, NULL,
+                          NULL, 0, NULL,
+                          &rdata, 10, &rdata_count);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
        }
 
        if (pdate) {
                struct timespec ts;
-               ts = interpret_long_date(rdata);
+               ts = interpret_long_date((char *)rdata);
                *pdate = ts.tv_sec;
        }
        if (pserial_number) {
@@ -403,11 +389,8 @@ bool cli_get_fs_volume_info(struct cli_state *cli, fstring volume_name, uint32 *
         *       return the other stuff
         */
 
-cleanup:
-       SAFE_FREE(rparam);
-       SAFE_FREE(rdata);
-
-       return ret;
+       TALLOC_FREE(rdata);
+       return NT_STATUS_OK;
 }
 
 bool cli_get_fs_full_size_info(struct cli_state *cli,