Esempio n. 1
0
static int get_uak_expiry_date(void)
{
	int rc;
	char date[UAK_EXPIRY_DATE_DATA_LENGTH] = {0};
	char error_buf[ERR_BUF_SIZE];

	rc = rtas_get_sysparm(SYS_PARAM_UAK_EXPIRY_DATE, ARRAY_SIZE(date),
			      date);

	if (rc == 0) {
		/* +2 since first 2 bytes in date buffer filled by the RTAS call
		 * are used for storing length of the buffer excluding the first
		 * two bytes and including ending '\0'
		 */
		printf("Update Access Key expiry date (yyyymmdd) is: %s\n",
		       date + 2);
	} else {
		switch (rc) {
		case -1:
			warnx("Hardware Error");
			break;
		case -2:
			warnx("Busy, Try again later");
			break;
		case -3:
			warnx("System parameter not supported");
			break;
		case -9002:
			warnx("Not authorized");
			break;
		case -9999:
			warnx("Parameter Error");
			break;
		case 9900 ... 9905:
			warnx("Delay of %ld milliseconds is expected "
			      "before calling ibm,get-system-parameter with "
			      "the same parameter index",
			      (long) pow(10, rc-9900));
			break;
		default:
			if (is_librtas_error(rc)) {
				librtas_error(rc, error_buf, ERR_BUF_SIZE);
				warnx("%s", error_buf);
			} else {
				warnx("Unknown error");
			}
		}

		rc = UAK_ERROR;
	}

	return rc;
}
Esempio n. 2
0
	string RtasCollector::rtasSystemParm(int code)
	{
		char buf[RTAS_BUF_SIZE];
		int ret = -1;

#ifdef DEBUGRTAS
		printf("Collecting RTAS info: [%d] %s\n", __LINE__, __FILE__);
#endif
		ret = rtas_get_sysparm(code, RTAS_BUF_SIZE, buf);

		if (ret == 0) {
			/*
			 * The first two bytes of the buffer contain the
			 * length of the data returned, including the
			 * terminating null.
			 */
			return string(buf+2);
		} else {
			return string();
		}
	}