[PATCH 03/12] quota: Avoid printing id for the commands which are known to ignore it

Eugene Syromyatnikov evgsyr at gmail.com
Wed Sep 21 03:11:09 UTC 2016


id argument is not used for Q_QUOTAOFF, Q_GETFMT, Q_V2_GETINFO,
Q_GETINFO, Q_V2_SEETINFO, Q_SETINFO, Q_SYNC, Q_XQUOTAON, Q_XQUOTAOFF,
Q_XQUOTARM, Q_XGETQSTAT, Q_XGETQSTATV, Q_XQUOTASYNC, Q_V1_GETSTATS,
Q_V2_GETSTATS subcommands, so it makes sense to avoid printing it.

* quota.c (decode_cmd_data): Add id argument parameter, add printing of
  id argument for Q_GETQUOTA, Q_SETQUOTA, Q_GETNEXTQUOTA, Q_V1_GETQUOTA,
  Q_V1_SETQUOTA, Q_V2_GETQUOTA, Q_V2_SETQUOTA, Q_XGETQUOTA,
  Q_XGETNEXTQUOTA, Q_XSETQLIM subcommands and the default case;
  (SYS_FUNC(quotactl)): remove printing of id argument, add id argument
  to decode_cmd_data call.
---
 quota.c |  115 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 100 insertions(+), 15 deletions(-)

diff --git a/quota.c b/quota.c
index efef4ed..495bd5f 100644
--- a/quota.c
+++ b/quota.c
@@ -212,16 +212,29 @@ struct fs_quota_statv {
 };
 
 static int
-decode_cmd_data(struct tcb *tcp, uint32_t cmd, unsigned long data)
+decode_cmd_data(struct tcb *tcp, uint32_t id, uint32_t cmd, unsigned long data)
 {
 	switch (cmd) {
+		case Q_QUOTAOFF:
+			break;
 		case Q_GETQUOTA:
-			if (entering(tcp))
+			if (entering(tcp)) {
+				printuid(", ", id);
+				tprints(", ");
+
 				return 0;
+			}
+
+			/* Fall-through */
 		case Q_SETQUOTA:
 		{
 			struct if_dqblk dq;
 
+			if (entering(tcp)) {
+				printuid(", ", id);
+				tprints(", ");
+			}
+
 			if (umove_or_printaddr(tcp, data, &dq))
 				break;
 			tprintf("{bhardlimit=%" PRIu64 ", ", dq.dqb_bhardlimit);
@@ -245,8 +258,13 @@ decode_cmd_data(struct tcb *tcp, uint32_t cmd, unsigned long data)
 		{
 			struct if_nextdqblk dq;
 
-			if (entering(tcp))
+			if (entering(tcp)) {
+				printuid(", ", id);
+				tprints(", ");
+
 				return 0;
+			}
+
 			if (umove_or_printaddr(tcp, data, &dq))
 				break;
 			tprintf("{bhardlimit=%" PRIu64 ", ", dq.dqb_bhardlimit);
@@ -267,12 +285,23 @@ decode_cmd_data(struct tcb *tcp, uint32_t cmd, unsigned long data)
 			break;
 		}
 		case Q_V1_GETQUOTA:
-			if (entering(tcp))
+			if (entering(tcp)) {
+				printuid(", ", id);
+				tprints(", ");
+
 				return 0;
+			}
+
+			/* Fall-through */
 		case Q_V1_SETQUOTA:
 		{
 			struct v1_dqblk dq;
 
+			if (entering(tcp)) {
+				printuid(", ", id);
+				tprints(", ");
+			}
+
 			if (umove_or_printaddr(tcp, data, &dq))
 				break;
 			tprintf("{bhardlimit=%u, ", dq.dqb_bhardlimit);
@@ -286,12 +315,23 @@ decode_cmd_data(struct tcb *tcp, uint32_t cmd, unsigned long data)
 			break;
 		}
 		case Q_V2_GETQUOTA:
-			if (entering(tcp))
+			if (entering(tcp)) {
+				printuid(", ", id);
+				tprints(", ");
+
 				return 0;
+			}
+
+			/* Fall-through */
 		case Q_V2_SETQUOTA:
 		{
 			struct v2_dqblk dq;
 
+			if (entering(tcp)) {
+				printuid(", ", id);
+				tprints(", ");
+			}
+
 			if (umove_or_printaddr(tcp, data, &dq))
 				break;
 			tprintf("{ihardlimit=%u, ", dq.dqb_ihardlimit);
@@ -306,12 +346,23 @@ decode_cmd_data(struct tcb *tcp, uint32_t cmd, unsigned long data)
 		}
 		case Q_XGETQUOTA:
 		case Q_XGETNEXTQUOTA:
-			if (entering(tcp))
+			if (entering(tcp)) {
+				printuid(", ", id);
+				tprints(", ");
+
 				return 0;
+			}
+
+			/* Fall-through */
 		case Q_XSETQLIM:
 		{
 			struct xfs_dqblk dq;
 
+			if (entering(tcp)) {
+				printuid(", ", id);
+				tprints(", ");
+			}
+
 			if (umove_or_printaddr(tcp, data, &dq))
 				break;
 			tprintf("{version=%d, ", dq.d_version);
@@ -342,8 +393,12 @@ decode_cmd_data(struct tcb *tcp, uint32_t cmd, unsigned long data)
 		{
 			uint32_t fmt;
 
-			if (entering(tcp))
+			if (entering(tcp)) {
+				tprints(", ");
+
 				return 0;
+			}
+
 			if (umove_or_printaddr(tcp, data, &fmt))
 				break;
 			tprints("[");
@@ -352,12 +407,20 @@ decode_cmd_data(struct tcb *tcp, uint32_t cmd, unsigned long data)
 			break;
 		}
 		case Q_GETINFO:
-			if (entering(tcp))
+			if (entering(tcp)) {
+				tprints(", ");
+
 				return 0;
+			}
+
+			/* Fall-through */
 		case Q_SETINFO:
 		{
 			struct if_dqinfo dq;
 
+			if (entering(tcp))
+				tprints(", ");
+
 			if (umove_or_printaddr(tcp, data, &dq))
 				break;
 			tprintf("{bgrace=%" PRIu64 ", ", dq.dqi_bgrace);
@@ -370,12 +433,20 @@ decode_cmd_data(struct tcb *tcp, uint32_t cmd, unsigned long data)
 			break;
 		}
 		case Q_V2_GETINFO:
-			if (entering(tcp))
+			if (entering(tcp)) {
+				tprints(", ");
+
 				return 0;
+			}
+
+			/* Fall-through */
 		case Q_V2_SETINFO:
 		{
 			struct v2_dqinfo dq;
 
+			if (entering(tcp))
+				tprints(", ");
+
 			if (umove_or_printaddr(tcp, data, &dq))
 				break;
 			tprintf("{bgrace=%u, ", dq.dqi_bgrace);
@@ -391,6 +462,8 @@ decode_cmd_data(struct tcb *tcp, uint32_t cmd, unsigned long data)
 		{
 			struct v1_dqstats dq;
 
+			tprints(", ");
+
 			if (entering(tcp))
 				return 0;
 			if (umove_or_printaddr(tcp, data, &dq))
@@ -409,6 +482,8 @@ decode_cmd_data(struct tcb *tcp, uint32_t cmd, unsigned long data)
 		{
 			struct v2_dqstats dq;
 
+			tprints(", ");
+
 			if (entering(tcp))
 				return 0;
 			if (umove_or_printaddr(tcp, data, &dq))
@@ -428,8 +503,12 @@ decode_cmd_data(struct tcb *tcp, uint32_t cmd, unsigned long data)
 		{
 			struct xfs_dqstats dq;
 
-			if (entering(tcp))
+			if (entering(tcp)) {
+				tprints(", ");
+
 				return 0;
+			}
+
 			if (umove_or_printaddr(tcp, data, &dq))
 				break;
 			tprintf("{version=%d, ", dq.qs_version);
@@ -458,8 +537,12 @@ decode_cmd_data(struct tcb *tcp, uint32_t cmd, unsigned long data)
 		{
 			struct fs_quota_statv dq;
 
-			if (entering(tcp))
+			if (entering(tcp)) {
+				tprints(", ");
+
 				return 0;
+			}
+
 			if (umove_or_printaddr(tcp, data, &dq))
 				break;
 			tprintf("{version=%d, ", dq.qs_version);
@@ -492,6 +575,8 @@ decode_cmd_data(struct tcb *tcp, uint32_t cmd, unsigned long data)
 		{
 			uint32_t flag;
 
+			tprints(", ");
+
 			if (umove_or_printaddr(tcp, data, &flag))
 				break;
 			tprints("[");
@@ -500,6 +585,8 @@ decode_cmd_data(struct tcb *tcp, uint32_t cmd, unsigned long data)
 			break;
 		}
 		default:
+			printuid(", ", id);
+			tprints(", ");
 			printaddr(data);
 			break;
 	}
@@ -526,17 +613,15 @@ SYS_FUNC(quotactl)
 		printxval(quotatypes, type, "???QUOTA");
 		tprints("), ");
 		printpath(tcp, tcp->u_arg[1]);
-		tprints(", ");
 		switch (cmd) {
 			case Q_QUOTAON:
 			case Q_V1_QUOTAON:
+				tprints(", ");
 				printxval(quota_formats, id, "QFMT_VFS_???");
 				tprints(", ");
 				printpath(tcp, tcp->u_arg[3]);
 				return RVAL_DECODED;
 		}
-		printuid("", id);
-		tprints(", ");
 	}
-	return decode_cmd_data(tcp, cmd, tcp->u_arg[3]);
+	return decode_cmd_data(tcp, id, cmd, tcp->u_arg[3]);
 }
-- 
1.7.10.4





More information about the Strace-devel mailing list