s3: Convert cli_set_fs_quota_info to cli_trans
authorVolker Lendecke <vl@samba.org>
Sun, 16 Jan 2011 11:14:26 +0000 (12:14 +0100)
committerVolker Lendecke <vl@samba.org>
Mon, 17 Jan 2011 07:03:41 +0000 (08:03 +0100)
source3/include/proto.h
source3/libsmb/cliquota.c
source3/utils/smbcquotas.c

index cf16436dc2a1fcc0a0776d20316d43dbd2de7645..e58fd73e5f49a177ad99ad7e3dbfbe5d3cbc38a6 100644 (file)
@@ -2262,7 +2262,8 @@ NTSTATUS cli_list_user_quota(struct cli_state *cli, int quota_fnum,
                             SMB_NTQUOTA_LIST **pqt_list);
 NTSTATUS cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum,
                               SMB_NTQUOTA_STRUCT *pqt);
-bool cli_set_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt);
+NTSTATUS cli_set_fs_quota_info(struct cli_state *cli, int quota_fnum,
+                              SMB_NTQUOTA_STRUCT *pqt);
 void dump_ntquota(SMB_NTQUOTA_STRUCT *qt, bool _verbose, bool _numeric, void (*_sidtostring)(fstring str, struct dom_sid *sid, bool _numeric));
 void dump_ntquota_list(SMB_NTQUOTA_LIST **qtl, bool _verbose, bool _numeric, void (*_sidtostring)(fstring str, struct dom_sid *sid, bool _numeric));
 
index bfa24687f0f6b6f5c7170e06fda86e735425f928..be52f9b086a5ba6cb1add245fed3d51d04308a95 100644 (file)
@@ -458,15 +458,14 @@ NTSTATUS cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum,
        return status;
 }
 
-bool cli_set_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt)
+NTSTATUS cli_set_fs_quota_info(struct cli_state *cli, int quota_fnum,
+                              SMB_NTQUOTA_STRUCT *pqt)
 {
-       bool ret = False;
-       uint16 setup;
-       char param[4];
-       char data[48];
-       char *rparam=NULL, *rdata=NULL;
-       unsigned int rparam_count=0, rdata_count=0;
+       uint16_t setup[1];
+       uint8_t param[4];
+       uint8_t data[48];
        SMB_NTQUOTA_STRUCT qt;
+       NTSTATUS status;
        ZERO_STRUCT(qt);
        memset(data,'\0',48);
 
@@ -474,7 +473,7 @@ bool cli_set_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_ST
                smb_panic("cli_set_fs_quota_info() called with NULL Pointer!");
        }
 
-       setup = TRANSACT2_SETFSINFO;
+       SSVAL(setup + 0, 0,TRANSACT2_SETFSINFO);
 
        SSVAL(param,0,quota_fnum);
        SSVAL(param,2,SMB_FS_QUOTA_INFORMATION);
@@ -492,33 +491,23 @@ bool cli_set_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_ST
 
        /* Unknown3 6 NULL bytes */
 
-       if (!cli_send_trans(cli, SMBtrans2, 
-                   NULL, 
-                   0, 0,
-                   &setup, 1, 0,
-                   param, 4, 0,
-                   data, 48, 0)) {
-               goto cleanup;
-       }
-
-       if (!cli_receive_trans(cli, SMBtrans2,
-                              &rparam, &rparam_count,
-                              &rdata, &rdata_count)) {
-               goto cleanup;
-       }
+       status = cli_trans(talloc_tos(), cli, SMBtrans2,
+                          NULL, -1, /* name, fid */
+                          0, 0,     /* function, flags */
+                          setup, 1, 0, /* setup */
+                          param, 8, 0, /* param */
+                          data, 48, 0, /* data */
+                          NULL,         /* recv_flags2 */
+                          NULL, 0, NULL, /* rsetup */
+                          NULL, 0, NULL, /* rparam */
+                          NULL, 0, NULL); /* rdata */
 
-       if (cli_is_error(cli)) {
-               ret = False;
-               goto cleanup;
-       } else {
-               ret = True;
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(1, ("SMB_FS_QUOTA_INFORMATION failed: %s\n",
+                         nt_errstr(status)));
        }
 
-cleanup:
-       SAFE_FREE(rparam);
-       SAFE_FREE(rdata);
-
-       return ret;     
+       return status;
 }
 
 static const char *quota_str_static(uint64_t val, bool special, bool _numeric)
index 83a069814f4cb1a53cbfada57ee8dbe377ade39e..8cf1751578fe795082a85a7cd7c409fe3c88471c 100644 (file)
@@ -340,9 +340,11 @@ static int do_quota(struct cli_state *cli,
                                        }
                                        qt.softlim = pqt->softlim;
                                        qt.hardlim = pqt->hardlim;
-                                       if (!cli_set_fs_quota_info(cli, quota_fnum, &qt)) {
+                                       status = cli_set_fs_quota_info(
+                                               cli, quota_fnum, &qt);
+                                       if (!NT_STATUS_IS_OK(status)) {
                                                d_printf("%s cli_set_fs_quota_info\n",
-                                                        cli_errstr(cli));
+                                                        nt_errstr(status));
                                                return -1;
                                        }
                                        status = cli_get_fs_quota_info(
@@ -363,9 +365,11 @@ static int do_quota(struct cli_state *cli,
                                                return -1;
                                        }
                                        qt.qflags = pqt->qflags;
-                                       if (!cli_set_fs_quota_info(cli, quota_fnum, &qt)) {
+                                       status = cli_set_fs_quota_info(
+                                               cli, quota_fnum, &qt);
+                                       if (!NT_STATUS_IS_OK(status)) {
                                                d_printf("%s cli_set_fs_quota_info\n",
-                                                        cli_errstr(cli));
+                                                        nt_errstr(status));
                                                return -1;
                                        }
                                        status = cli_get_fs_quota_info(