示例#1
0
static bool
decode_tc_sizespec(struct tcb *const tcp,
		   const kernel_ulong_t addr,
		   const unsigned int len,
		   const void *const opaque_data)
{
#ifdef HAVE_STRUCT_TC_SIZESPEC
	struct tc_sizespec s;

	if (len < sizeof(s))
		return false;
	else if (!umove_or_printaddr(tcp, addr, &s)) {
		PRINT_FIELD_U("{", s, cell_log);
		PRINT_FIELD_U(", ", s, size_log);
		PRINT_FIELD_D(", ", s, cell_align);
		PRINT_FIELD_D(", ", s, overhead);
		PRINT_FIELD_U(", ", s, linklayer);
		PRINT_FIELD_U(", ", s, mpu);
		PRINT_FIELD_U(", ", s, mtu);
		PRINT_FIELD_U(", ", s, tsize);
		tprints("}");
	}

	return true;
#else
	return false;
#endif
}
示例#2
0
bool
decode_netlink_selinux(struct tcb *const tcp,
		       const struct nlmsghdr *const nlmsghdr,
		       const kernel_ulong_t addr,
		       const unsigned int len)
{
	switch (nlmsghdr->nlmsg_type) {
	case SELNL_MSG_SETENFORCE: {
		struct selnl_msg_setenforce msg;

		if (len < sizeof(msg))
			printstr_ex(tcp, addr, len, QUOTE_FORCE_HEX);
		else if (!umove_or_printaddr(tcp, addr, &msg)) {
			PRINT_FIELD_D("{", msg, val);
			tprints("}");
		}
		break;
	}
	case SELNL_MSG_POLICYLOAD: {
		struct selnl_msg_policyload msg;

		if (len < sizeof(msg))
			printstr_ex(tcp, addr, len, QUOTE_FORCE_HEX);
		else if (!umove_or_printaddr(tcp, addr, &msg)) {
			PRINT_FIELD_U("{", msg, seqno);
			tprints("}");
		}
		break;
	}
	default:
		return false;
	}

	return true;
}
示例#3
0
void
print_xdisk_quota(int rc, void *ptr, void *arg)
{
	struct fs_disk_quota *dq = ptr;
	long out_arg = (long) arg;

	if (((rc != 0) && out_arg) || (out_arg > 1)) {
		printf("%p", dq);
		return;
	}

	PRINT_FIELD_D("{", dq, d_version);
	printf(", d_flags=");
	printflags(xfs_dqblk_flags, (uint8_t) dq->d_flags, "XFS_???_QUOTA");

	PRINT_FIELD_X(", ", dq, d_fieldmask);
	PRINT_FIELD_U(", ", dq, d_id);
	PRINT_FIELD_U(", ", dq, d_blk_hardlimit);
	PRINT_FIELD_U(", ", dq, d_blk_softlimit);
	PRINT_FIELD_U(", ", dq, d_ino_hardlimit);
	PRINT_FIELD_U(", ", dq, d_ino_softlimit);
	PRINT_FIELD_U(", ", dq, d_bcount);
	PRINT_FIELD_U(", ", dq, d_icount);

# if VERBOSE
	PRINT_FIELD_D(", ", dq, d_itimer);
	PRINT_FIELD_D(", ", dq, d_btimer);
	PRINT_FIELD_U(", ", dq, d_iwarns);
	PRINT_FIELD_U(", ", dq, d_bwarns);
	PRINT_FIELD_U(", ", dq, d_rtb_hardlimit);
	PRINT_FIELD_U(", ", dq, d_rtb_softlimit);
	PRINT_FIELD_U(", ", dq, d_rtbcount);
	PRINT_FIELD_D(", ", dq, d_rtbtimer);
	PRINT_FIELD_U(", ", dq, d_rtbwarns);
# else
	printf(", ...");
# endif /* !VERBOSE */
	printf("}");
}
示例#4
0
void
print_xquota_statv(int rc, void *ptr, void *arg)
{
	struct fs_quota_statv *qs = ptr;
	long out_arg = (long) arg;

	if (((rc != 0) && out_arg) || (out_arg > 1)) {
		printf("%p", qs);
		return;
	}

	PRINT_FIELD_D("{", qs, qs_version);

# if VERBOSE
	printf(", qs_flags=");
	printflags(xfs_quota_flags, qs->qs_flags, "XFS_QUOTA_???");
	PRINT_FIELD_U(", ", qs, qs_incoredqs);
	PRINT_FIELD_U(", qs_uquota={", &qs->qs_uquota, qfs_ino);
	PRINT_FIELD_U(", ", &qs->qs_uquota, qfs_nblks);
	PRINT_FIELD_U(", ", &qs->qs_uquota, qfs_nextents);
	PRINT_FIELD_U("}, qs_gquota={", &qs->qs_gquota, qfs_ino);
	PRINT_FIELD_U(", ", &qs->qs_gquota, qfs_nblks);
	PRINT_FIELD_U(", ", &qs->qs_gquota, qfs_nextents);
	PRINT_FIELD_U("}, qs_pquota={", &qs->qs_pquota, qfs_ino);
	PRINT_FIELD_U(", ", &qs->qs_pquota, qfs_nblks);
	PRINT_FIELD_U(", ", &qs->qs_pquota, qfs_nextents);
	PRINT_FIELD_D("}, ", qs, qs_btimelimit);
	PRINT_FIELD_D(", ", qs, qs_itimelimit);
	PRINT_FIELD_D(", ", qs, qs_rtbtimelimit);
	PRINT_FIELD_U(", ", qs, qs_bwarnlimit);
	PRINT_FIELD_U(", ", qs, qs_iwarnlimit);
# else
	printf(", ...");
# endif /* !VERBOSE */
	printf("}");
}
示例#5
0
static bool
decode_tc_estimator(struct tcb *const tcp,
		    const kernel_ulong_t addr,
		    const unsigned int len,
		    const void *const opaque_data)
{
	struct tc_estimator est;

	if (len < sizeof(est))
		return false;
	else if (!umove_or_printaddr(tcp, addr, &est)) {
		PRINT_FIELD_D("{", est, interval);
		PRINT_FIELD_U(", ", est, ewma_log);
		tprints("}");
	}

	return true;
}
示例#6
0
static void
test_selnl_msg_setenforce(const int fd)
{
	void *const nlh0 = tail_alloc(NLMSG_HDRLEN);

	static const struct selnl_msg_setenforce msg = {
		.val = 0xfbdcdfab
	};
	TEST_NETLINK_OBJECT(fd, nlh0,
			    SELNL_MSG_SETENFORCE, NLM_F_REQUEST, msg,
			    PRINT_FIELD_D("{", msg, val);
			    printf("}"));
}

static void
test_selnl_msg_policyload(const int fd)
{
	void *const nlh0 = tail_alloc(NLMSG_HDRLEN);

	static const struct selnl_msg_policyload msg = {
		.seqno = 0xabdcfabc
	};
	TEST_NETLINK_OBJECT(fd, nlh0,
			    SELNL_MSG_POLICYLOAD, NLM_F_REQUEST, msg,
			    PRINT_FIELD_U("{", msg, seqno);
			    printf("}"));
}

int main(void)
{
	skip_if_unavailable("/proc/self/fd/");

	int fd = create_nl_socket(NETLINK_SELINUX);

	test_nlmsg_type(fd);
	test_selnl_msg_unspec(fd);
	test_selnl_msg_setenforce(fd);
	test_selnl_msg_policyload(fd);

	printf("+++ exited with 0 +++\n");

	return 0;
}