s3: Convert cli_get_fs_quota_info to cli_trans
authorVolker Lendecke <vl@samba.org>
Sun, 16 Jan 2011 11:03:07 +0000 (12:03 +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 62b7632205eb9cf8cdb6f161c89ac1023feadbf3..cf16436dc2a1fcc0a0776d20316d43dbd2de7645 100644 (file)
@@ -2260,7 +2260,8 @@ NTSTATUS cli_set_user_quota(struct cli_state *cli, int quota_fnum,
                            SMB_NTQUOTA_STRUCT *pqt);
 NTSTATUS cli_list_user_quota(struct cli_state *cli, int quota_fnum,
                             SMB_NTQUOTA_LIST **pqt_list);
-bool cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt);
+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);
 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 9043fc36f2cbafeb6102a0c72ebfbddfc7d4ea26..bfa24687f0f6b6f5c7170e06fda86e735425f928 100644 (file)
@@ -380,48 +380,41 @@ NTSTATUS cli_list_user_quota(struct cli_state *cli, int quota_fnum,
        return status;
 }
 
-bool cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt)
+NTSTATUS cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum,
+                              SMB_NTQUOTA_STRUCT *pqt)
 {
-       bool ret = False;
-       uint16 setup;
-       char param[2];
-       char *rparam=NULL, *rdata=NULL;
-       unsigned int rparam_count=0, rdata_count=0;
+       uint16_t setup[1];
+       uint8_t param[2];
+       uint8_t *rdata=NULL;
+       uint32_t rdata_count=0;
        SMB_NTQUOTA_STRUCT qt;
+       NTSTATUS status;
+
        ZERO_STRUCT(qt);
 
        if (!cli||!pqt) {
                smb_panic("cli_get_fs_quota_info() called with NULL Pointer!");
        }
 
-       setup = TRANSACT2_QFSINFO;
+       SSVAL(setup + 0, 0, TRANSACT2_QFSINFO);
 
        SSVAL(param,0,SMB_FS_QUOTA_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;
-       }
-
-       if (cli_is_error(cli)) {
-               ret = False;
-               goto cleanup;
-       } else {
-               ret = True;
-       }
+       status = cli_trans(talloc_tos(), cli, SMBtrans2,
+                          NULL, -1, /* name, fid */
+                          0, 0,     /* function, flags */
+                          setup, 1, 0, /* setup */
+                          param, 2, 0, /* param */
+                          NULL, 0, 560, /* data */
+                          NULL,         /* recv_flags2 */
+                          NULL, 0, NULL, /* rsetup */
+                          NULL, 0, NULL, /* rparam */
+                          &rdata, 48, &rdata_count);
 
-       if (rdata_count < 48) {
-               goto cleanup;
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(1, ("SMB_FS_QUOTA_INFORMATION failed: %s\n",
+                         nt_errstr(status)));
+               return status;
        }
 
        /* unknown_1 24 NULL bytes in pdata*/
@@ -435,6 +428,7 @@ bool cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_ST
                ((qt.softlim != 0xFFFFFFFF)||
                 (IVAL(rdata,28)!=0xFFFFFFFF))) {
                /* more than 32 bits? */
+               status = NT_STATUS_INVALID_NETWORK_RESPONSE;
                goto cleanup;
        }
 #endif /* LARGE_SMB_OFF_T */
@@ -448,6 +442,7 @@ bool cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_ST
                ((qt.hardlim != 0xFFFFFFFF)||
                 (IVAL(rdata,36)!=0xFFFFFFFF))) {
                /* more than 32 bits? */
+               status = NT_STATUS_INVALID_NETWORK_RESPONSE;
                goto cleanup;
        }
 #endif /* LARGE_SMB_OFF_T */
@@ -459,12 +454,8 @@ bool cli_get_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_ST
 
        *pqt = qt;
 
-       ret = True;
-cleanup:
-       SAFE_FREE(rparam);
-       SAFE_FREE(rdata);
-
-       return ret;     
+       TALLOC_FREE(rdata);
+       return status;
 }
 
 bool cli_set_fs_quota_info(struct cli_state *cli, int quota_fnum, SMB_NTQUOTA_STRUCT *pqt)
index ee8544ef3baa24e3276eaa78ee3eaed9a382b837..83a069814f4cb1a53cbfada57ee8dbe377ade39e 100644 (file)
@@ -321,17 +321,21 @@ static int do_quota(struct cli_state *cli,
                case SMB_USER_FS_QUOTA_TYPE:
                        switch(cmd) {
                                case QUOTA_GET:
-                                       if (!cli_get_fs_quota_info(cli, quota_fnum, &qt)) {
+                                       status = cli_get_fs_quota_info(
+                                               cli, quota_fnum, &qt);
+                                       if (!NT_STATUS_IS_OK(status)) {
                                                d_printf("%s cli_get_fs_quota_info\n",
-                                                        cli_errstr(cli));
+                                                        nt_errstr(status));
                                                return -1;
                                        }
                                        dump_ntquota(&qt,True,numeric,NULL);
                                        break;
                                case QUOTA_SETLIM:
-                                       if (!cli_get_fs_quota_info(cli, quota_fnum, &qt)) {
+                                       status = cli_get_fs_quota_info(
+                                               cli, quota_fnum, &qt);
+                                       if (!NT_STATUS_IS_OK(status)) {
                                                d_printf("%s cli_get_fs_quota_info\n",
-                                                        cli_errstr(cli));
+                                                        nt_errstr(status));
                                                return -1;
                                        }
                                        qt.softlim = pqt->softlim;
@@ -341,17 +345,21 @@ static int do_quota(struct cli_state *cli,
                                                         cli_errstr(cli));
                                                return -1;
                                        }
-                                       if (!cli_get_fs_quota_info(cli, quota_fnum, &qt)) {
+                                       status = cli_get_fs_quota_info(
+                                               cli, quota_fnum, &qt);
+                                       if (!NT_STATUS_IS_OK(status)) {
                                                d_printf("%s cli_get_fs_quota_info\n",
-                                                        cli_errstr(cli));
+                                                        nt_errstr(status));
                                                return -1;
                                        }
                                        dump_ntquota(&qt,True,numeric,NULL);
                                        break;
                                case QUOTA_SETFLAGS:
-                                       if (!cli_get_fs_quota_info(cli, quota_fnum, &qt)) {
+                                       status = cli_get_fs_quota_info(
+                                               cli, quota_fnum, &qt);
+                                       if (!NT_STATUS_IS_OK(status)) {
                                                d_printf("%s cli_get_fs_quota_info\n",
-                                                        cli_errstr(cli));
+                                                        nt_errstr(status));
                                                return -1;
                                        }
                                        qt.qflags = pqt->qflags;
@@ -360,9 +368,11 @@ static int do_quota(struct cli_state *cli,
                                                         cli_errstr(cli));
                                                return -1;
                                        }
-                                       if (!cli_get_fs_quota_info(cli, quota_fnum, &qt)) {
+                                       status = cli_get_fs_quota_info(
+                                               cli, quota_fnum, &qt);
+                                       if (!NT_STATUS_IS_OK(status)) {
                                                d_printf("%s cli_get_fs_quota_info\n",
-                                                        cli_errstr(cli));
+                                                        nt_errstr(status));
                                                return -1;
                                        }
                                        dump_ntquota(&qt,True,numeric,NULL);