Esempio n. 1
0
void
pkgstrConvertUllToTimeString_r(unsigned long long a_time,
	char *a_buf, int a_bufLen)
{
	unsigned long long	seconds;
	unsigned long long	minutes;
	unsigned long long	hours;
	unsigned long long	ns;

	/* entry assertions */

	assert(a_buf != (char *)NULL);
	assert(a_bufLen > 0);

	/* if time is 0, return immediate result */

	if (a_time == 0) {
		pkgstrPrintf_r(a_buf, a_bufLen, "%s", "0:00:00.000000000");
		return;
	}

	/* break out individual time components */

	ns = a_time % 1000000000ll;	/* nanoseconds left over from seconds */
	seconds = a_time / 1000000000ll;	/* total seconds */
	minutes = seconds / 60ll;	/* total minutes */
	seconds = seconds % 60ll;	/* seconds left over from minutes */
	hours = minutes / 60ll;		/* total hours */
	minutes = minutes % 60ll;	/* minutes left over from hours */

	/* return a converted string */

	pkgstrPrintf_r(a_buf, a_bufLen, "%llu:%02llu:%02llu.%09llu",
						hours, minutes, seconds, ns);
}
Esempio n. 2
0
static boolean_t
_validateLock(int a_fd, LOCK_T *a_theLock, int a_quiet)
{
	ADMINLOCK_T	*pll;
	char		*pld;
	long		pls;
	char		path[MAXPATHLEN];

	/* localize references to lock object */

	pld = &a_theLock->_lrLockData[0];
	pll = &a_theLock->_lrLock;
	pls = sizeof (a_theLock->_lrLockData);

	/* return true if no process i.d. associated with lock */

	if (pll->lockPid <= 0) {
		log_msg(LOG_MSG_DEBUG, MSG_VALID_NOPID, pll->lockObject);
		return (B_TRUE);
	}

	/* see if the zone i.d. matches */

	if (pll->lockZoneId != getzoneid()) {
		log_msg(LOG_MSG_DEBUG, MSG_VALID_BADZID, pll->lockObject,
		pll->lockZoneId, getzoneid());
		return (B_TRUE);
	} else {
		log_msg(LOG_MSG_DEBUG, MSG_VALID_ZIDOK, pll->lockObject,
		pll->lockZoneId, getzoneid());
	}

	/* see if the process is still active */

	pkgstrPrintf_r(path, sizeof (path), "/proc/%d", pll->lockPid);
	if (access(path, F_OK) == 0) {
		log_msg(LOG_MSG_DEBUG, MSG_VALID_OK, pll->lockObject,
			pll->lockPid, path);
		return (B_TRUE);
	}

	log_msg(LOG_MSG_DEBUG, MSG_VALID_NOTOK, pll->lockObject, pll->lockPid,
		path);

	/* delete this lock */

	log_msg(a_quiet ? LOG_MSG_DEBUG : LOG_MSG_WRN,
		MSG_VALID_STALE, pll->lockObject, pll->lockPid,
		pll->lockZoneId);

	_decrementLockCount(a_fd, a_theLock);

	return (B_FALSE);
}