s3: Remove the use of cli_send_trans from cli_get_fs_full_size_info
authorVolker Lendecke <vl@samba.org>
Thu, 4 Nov 2010 18:23:06 +0000 (19:23 +0100)
committerVolker Lendecke <vlendec@samba.org>
Thu, 4 Nov 2010 22:08:52 +0000 (22:08 +0000)
Autobuild-User: Volker Lendecke <vlendec@samba.org>
Autobuild-Date: Thu Nov  4 22:08:53 UTC 2010 on sn-devel-104

source3/include/proto.h
source3/libsmb/clifsinfo.c
source3/libsmb/libsmb_stat.c

index 058424359dd4f209793344c8de5b278c4501fbf1..1989fb1a8604c0c173fecb0769d2eb9502f59cff 100644 (file)
@@ -2158,12 +2158,12 @@ 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);
 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,
-                               uint64_t *actual_allocation_units,
-                               uint64_t *sectors_per_allocation_unit,
-                               uint64_t *bytes_per_sector);
+NTSTATUS cli_get_fs_full_size_info(struct cli_state *cli,
+                                  uint64_t *total_allocation_units,
+                                  uint64_t *caller_allocation_units,
+                                  uint64_t *actual_allocation_units,
+                                  uint64_t *sectors_per_allocation_unit,
+                                  uint64_t *bytes_per_sector);
 bool cli_get_posix_fs_info(struct cli_state *cli,
                            uint32 *optimal_transfer_size,
                            uint32 *block_size,
index 5ca76ac16a8410c09b6997695524c6e331e4cb10..8a158782670df216576ad0e6d4eb1e2638204d45 100644 (file)
@@ -405,47 +405,33 @@ NTSTATUS cli_get_fs_volume_info(struct cli_state *cli, fstring volume_name,
        return NT_STATUS_OK;
 }
 
-bool cli_get_fs_full_size_info(struct cli_state *cli,
-                               uint64_t *total_allocation_units,
-                               uint64_t *caller_allocation_units,
-                               uint64_t *actual_allocation_units,
-                               uint64_t *sectors_per_allocation_unit,
-                               uint64_t *bytes_per_sector)
+NTSTATUS cli_get_fs_full_size_info(struct cli_state *cli,
+                                  uint64_t *total_allocation_units,
+                                  uint64_t *caller_allocation_units,
+                                  uint64_t *actual_allocation_units,
+                                  uint64_t *sectors_per_allocation_unit,
+                                  uint64_t *bytes_per_sector)
 {
-       bool ret = False;
-       uint16 setup;
-       char param[2];
-       char *rparam=NULL, *rdata=NULL;
-       unsigned int rparam_count=0, rdata_count=0;
-
-       setup = TRANSACT2_QFSINFO;
-
-       SSVAL(param,0,SMB_FS_FULL_SIZE_INFORMATION);
-
-       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;
-       }
+       uint16 setup[1];
+       uint8_t param[2];
+       uint8_t *rdata = NULL;
+       uint32_t rdata_count;
+       NTSTATUS status;
 
-       if (cli_is_error(cli)) {
-               ret = False;
-               goto cleanup;
-       } else {
-               ret = True;
-       }
+       SSVAL(setup, 0, TRANSACT2_QFSINFO);
+       SSVAL(param, 0, SMB_FS_FULL_SIZE_INFORMATION);
 
-       if (rdata_count != 32) {
-               goto cleanup;
+       status = cli_trans(talloc_tos(), cli, SMBtrans2,
+                          NULL, 0, 0, 0,
+                          setup, 1, 0, /* setup */
+                          param, 2, 0,  /* param */
+                          NULL, 0, 560, /* data */
+                          NULL,
+                          NULL, 0, NULL, /* rsetup */
+                          NULL, 0, NULL, /* rparam */
+                          &rdata, 32, &rdata_count);  /* rdata */
+       if (!NT_STATUS_IS_OK(status)) {
+               goto fail;
        }
 
        if (total_allocation_units) {
@@ -464,11 +450,9 @@ bool cli_get_fs_full_size_info(struct cli_state *cli,
                *bytes_per_sector = IVAL(rdata,28);
        }
 
-cleanup:
-       SAFE_FREE(rparam);
-       SAFE_FREE(rdata);
-
-       return ret;
+fail:
+       TALLOC_FREE(rdata);
+       return status;
 }
 
 bool cli_get_posix_fs_info(struct cli_state *cli,
index 0f64502409501d06db2f78e8c221b4e1c4dc38e3..f34294e0c3e1f1447adb4b52afefbe4297c5b335 100644 (file)
@@ -377,14 +377,16 @@ SMBC_fstatvfs_ctx(SMBCCTX *context,
                 uint64_t actual_allocation_units;
                 uint64_t sectors_per_allocation_unit;
                 uint64_t bytes_per_sector;
+               NTSTATUS status;
 
                 /* Nope. If size data is available... */
-                if (cli_get_fs_full_size_info(cli,
-                                              &total_allocation_units,
-                                              &caller_allocation_units,
-                                              &actual_allocation_units,
-                                              &sectors_per_allocation_unit,
-                                              &bytes_per_sector)) {
+               status = cli_get_fs_full_size_info(cli,
+                                                  &total_allocation_units,
+                                                  &caller_allocation_units,
+                                                  &actual_allocation_units,
+                                                  &sectors_per_allocation_unit,
+                                                  &bytes_per_sector);
+               if (NT_STATUS_IS_OK(status)) {
 
                         /* ... then provide it */
                         st->f_bsize =